BeardedMonster commited on
Commit
a7b155e
·
verified ·
1 Parent(s): 2f49aad

Copy of AletheiaAING/african-code-switch-benchmark

Browse files
README.md ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ size_categories: [10K<n<100K]
3
+ tags: [african-languages, code-switching, idioms, benchmark, synthetic]
4
+ license: other
5
+ language: [afr, amh, bam, ewe, fon, ful, gpe, hau, ibo, kik, kin, kon, lin, lug, luo, mlg, nde, nso, nya, orm, pcm, run, sna, som, sot, ssw, swh, tir, tsn, tso, tum, twi, wes, wol, xho, yor, zul, en]
6
+ task_categories: [text-generation]
7
+ dataset_info:
8
+ features:
9
+ - {name: id, dtype: string}
10
+ - {name: subset, dtype: string}
11
+ - {name: task, dtype: string}
12
+ - {name: task_type, dtype: string}
13
+ - {name: input_type, dtype: string}
14
+ - {name: lang, dtype: string}
15
+ - {name: switch, dtype: string}
16
+ - {name: pair_in_training_table, dtype: bool}
17
+ - {name: prompt, dtype: string}
18
+ - {name: input, dtype: string}
19
+ - {name: english, dtype: string}
20
+ - {name: source_dataset, dtype: string}
21
+ - {name: source_register, dtype: string}
22
+ - {name: reference, dtype: string}
23
+ - name: reference_judge
24
+ struct:
25
+ - {name: meaning, dtype: float64}
26
+ - {name: base_language, dtype: float64}
27
+ - {name: switch_language, dtype: float64}
28
+ - {name: language_compliance, dtype: float64}
29
+ - {name: switching_naturalness, dtype: float64}
30
+ - {name: language_correctness, dtype: float64}
31
+ - {name: idiom_use, dtype: float64}
32
+ - {name: naturalness, dtype: float64}
33
+ - {name: overall, dtype: float64}
34
+ - name: candidates
35
+ list:
36
+ - {name: k, dtype: int64}
37
+ - {name: greedy, dtype: bool}
38
+ - {name: text, dtype: string}
39
+ - {name: finished, dtype: bool}
40
+ - name: devices
41
+ list: string
42
+ - {name: final, dtype: string}
43
+ - {name: format_ok, dtype: bool}
44
+ - {name: ev, dtype: float64}
45
+ - {name: system, dtype: string}
46
+ - {name: reward, dtype: float64}
47
+ - {name: chrf, dtype: float64}
48
+ - name: judge
49
+ struct:
50
+ - {name: meaning, dtype: float64}
51
+ - {name: base_language, dtype: float64}
52
+ - {name: switch_language, dtype: float64}
53
+ - {name: language_compliance, dtype: float64}
54
+ - {name: switching_naturalness, dtype: float64}
55
+ - {name: language_correctness, dtype: float64}
56
+ - {name: idiom_use, dtype: float64}
57
+ - {name: naturalness, dtype: float64}
58
+ - {name: overall, dtype: float64}
59
+ - name: output
60
+ list: string
61
+ configs:
62
+ - config_name: default
63
+ data_files:
64
+ - split: train
65
+ path: data/train*.jsonl.gz
66
+ - split: test
67
+ path: data/test.jsonl.gz
68
+ ---
69
+
70
+ # African Code-Switch Benchmark
71
+
72
+ A dataset for code-switching and idiom-rich writing in 37 African languages. Every row is a prompt (English text, or text in the base language) with candidate rewrites and a cleaned `output` column you can use directly. The `test` split is meant to become the benchmark for measuring progress on African-language code-switching, and the `train` split is for building better models. Nobody has checked the candidates with native speakers yet.
73
+
74
+ Two rewrite tasks:
75
+
76
+ - **`hm`** (human-style mixing) writes the text in a base language with a second language mixed in, the way people really talk. Example: Yoruba with English words in the middle of a sentence.
77
+ - **`ood`** rewrites the text in lively, everyday language full of idiomatic expressions (including sayings and comparisons) just like a native speaker would.
78
+
79
+ ## Train and test
80
+
81
+ | Split | Subset | English texts or items | Rows | `hm` rows | `ood` rows | Candidates |
82
+ |---|---|---|---|---|---|---|
83
+ | `train` | generated | 8,919 | 17,794 | 8,875 | 8,919 | 142,352 |
84
+ | `test` | generated | 11,100 | 22,147 | 11,048 | 11,099 | 177,176 |
85
+ | `test` | curated | 6,230 | 6,230 | 2,380 | 3,850 | 18,675 |
86
+
87
+ The `subset` column tells the two kinds of rows apart.
88
+
89
+ **`test` is the benchmark.** It has two parts:
90
+
91
+ - **`generated`**: 11,100 English texts, **exactly 300 per language** (37 languages), so no language counts more than another when you average scores. Every text has an `hm` and an `ood` row with eight candidates written by our 1B model (`BeardedMonster/gemma-3-1b-csw-best`). The language pairs and text types follow the same mix as `train` (under 1% difference on source mix, under 0.5% on language pairs), and all 81 base-switch pairs appear, with 66 to 166 `hm` rows each.
92
+ - **`curated`**: 6,230 held-out items in 34 languages and five tasks (`eng_hm`, `m_hm`, `eng_ood`, `m_ood`, `hm_ood`, explained under Columns). Each item has a curated `reference` and the outputs of three csw systems, each with four scores: `ev`, `reward`, `chrf` and `judge` (how they are derived is explained under How the scores were derived). The reference has judge grades too.
93
+
94
+ Report scores per language as well as the average.
95
+
96
+ **`train`** holds the remaining 8,919 generated texts.
97
+
98
+ **How the split was made.** The split is by English text, so the `hm` and `ood` rows of one text always stay together. Near-duplicate texts (for example conversations that share most of their sentences) are kept on the same side, so the model never sees a near copy of a test text during training. Texts were sampled per language to match the overall mix of switch-language pairs and text types.
99
+
100
+ ## What you can use it for
101
+
102
+ - Turn single-language chat or instruction data into code-switched user queries or assistant replies.
103
+ - Build text for ASR language models, TTS scripts and word lists with switched phrases (have a native speaker check it first).
104
+ - Test chatbots, translation and language-ID systems on code-switched inputs.
105
+ - Train and evaluate code-switch detectors with the labelled switched phrases (the `devices` field).
106
+ - Measure progress on African-language code-switching with the `test` split.
107
+ - Study how to pick good code-switched text from several candidates.
108
+
109
+ ## Columns
110
+
111
+ Each row is one input text with one task. Columns that don't apply to a row are `null`.
112
+
113
+ **Row columns**
114
+
115
+ | Column | Meaning |
116
+ |---|---|
117
+ | `id` | id of the item. For `generated` rows the `hm` and `ood` rows of one text share it. |
118
+ | `subset` | `generated` (English texts with candidates written by our 1B model) or `curated` (the held-out test items with a reference, see Train and test). |
119
+ | `task` | what is asked: `hm` (code-switching) or `ood` (idiom-rich rewrite). |
120
+ | `task_type` | the full task name: `eng_hm`, `m_hm`, `eng_ood`, `m_ood` or `hm_ood`. `eng_` means the input is English, `m_` means it is already in the base language, and `hm_ood` means it is already code-switched and you want the idiom-rich version. `generated` rows are all `eng_hm` or `eng_ood`. |
121
+ | `input_type` | the language of the input: `english`, `base_language` or `code_switched`. |
122
+ | `lang` | base language code, for example `yor`. |
123
+ | `switch` | switch language code for `hm` tasks and `hm_ood`, otherwise `null`. |
124
+ | `pair_in_training_table` | `false` for the 3,348 `hm` rows whose base-switch pair is outside the 67 pairs our 1B model was trained on (see the pair table), `true` otherwise. Use it to keep only the supported pairs. |
125
+ | `prompt` | the exact prompt given to the model, for example `<hm> <kon>+<fra>: Hey there! ...`. |
126
+ | `input` | the text the model had to rewrite (also inside `prompt`). |
127
+ | `english` | the English source text, `null` when the input is not English. |
128
+ | `source_dataset`, `source_register` | where the English text comes from and its register (`chat`, `story`, `complex`); `curated` rows have `source_dataset = curated`. |
129
+ | `reference` | the curated reference rewrite, with tags and device block removed. `curated` rows only. |
130
+ | `reference_judge` | judge grades of the `reference` (see below). `curated` rows only. |
131
+ | `candidates` | the candidate outputs, one entry each (columns below). |
132
+ | `output` | the cleaned text of each candidate, in the same order as `candidates`: language tags and the `<dev>...</dev>` block removed, so you can use it directly. |
133
+
134
+ **Columns inside each entry of `candidates`**
135
+
136
+ | Column | Meaning |
137
+ |---|---|
138
+ | `k` | candidate number. For `generated` rows 0 is the greedy output and 1 to 7 are samples; for `curated` rows it numbers the three systems. |
139
+ | `greedy` | `true` if this is a greedy (temperature 0) output. |
140
+ | `text` | the raw output: language tags, `<dev>` block and text. |
141
+ | `finished` | `true` if the model stopped by itself and was not cut off at the length limit (`null` for `curated` rows). |
142
+ | `devices` | the switched phrases (`hm`) or idioms (`ood`) the model listed, as they appear in the text. |
143
+ | `final` | the text without tags and device block. |
144
+ | `format_ok` | `true` if the output has the language tags, one device block and a non-empty text. |
145
+ | `ev` | learned quality score, 1 to 10, `null` when missing. |
146
+ | `system` | `curated` rows only: `sft` (supervised), `rl_best` or `rl_last` (reinforcement-learned, best and last checkpoint). |
147
+ | `reward` | `curated` rows only: the rule-based reward (can be negative; higher is better). |
148
+ | `chrf` | `curated` rows only: chrF++ of `final` against `reference`, 0 to 100. |
149
+ | `judge` | `curated` rows only: judge grades of this output, a record with the criteria below. |
150
+
151
+ Use `output[i]` for the text of `candidates[i]`.
152
+
153
+ ## How the scores were derived
154
+
155
+ None of these scores comes from a person.
156
+
157
+ - **`ev`**: a learned quality model (a multilingual encoder we fine-tuned on rated code-switched outputs). It reads the prompt and an output and predicts a 1 to 10 quality score. It is only computed for outputs with the right format. It likes short, simple code-switching, so don't use it as the only filter.
158
+ - **`reward`**: the reward used to train the two reinforcement-learned systems. It is the learned quality score combined with a format check and rule penalties for things like unused devices, the wrong language, repetition, wrong length, English leaking in and copying the input.
159
+ - **`chrf`**: sentence-level chrF++ (word order 2, sacreBLEU) between the cleaned output and the cleaned `reference`. It measures closeness to the reference, not quality on its own.
160
+ - **`judge`, `reference_judge`**: grades from 1 to 5 (mostly whole numbers) given by a large-language-model judge with a fixed rubric. The judge saw the input and the output but not which system wrote it. Anchors: 5 means a native speaker would change nothing, 1 means unusable. `hm` rows are graded on `meaning`, `base_language`, `switch_language`, `language_compliance`, `switching_naturalness` and `overall`; `ood` rows on `meaning`, `language_correctness`, `idiom_use`, `naturalness`, `language_compliance` and `overall`. A criterion the judge could not assess is `null`, and criteria that don't apply to the task are `null`. A few outputs could not be parsed and have no grades.
161
+
162
+ Example row, shortened:
163
+
164
+ ```json
165
+ {"id": "persona:7cad82bb1996", "task": "hm", "lang": "kon", "switch": "fra", "pair_in_training_table": true,
166
+ "prompt": "<hm> <kon>+<fra>: Hey there! Hi there! I love to read books. ...", "english": "Hey there! Hi there! I love to read books. ...",
167
+ "source_dataset": "persona", "source_register": "chat",
168
+ "candidates": [{"k": 0, "greedy": true, "text": "<kon><fra><dev>les livres | Tes | ...</dev> Eh, mono kele kuna! ...", "finished": true,
169
+ "devices": ["les livres", "Tes"], "final": "Eh, mono kele kuna! ...", "format_ok": true, "ev": 3.1}, "... 7 more ..."],
170
+ "output": ["Eh, mono kele kuna! ...", "... 7 more ..."]}
171
+ ```
172
+
173
+ ## How to use it
174
+
175
+ ```python
176
+ from datasets import load_dataset
177
+
178
+ ds = load_dataset("BeardedMonster/african-code-switch-benchmark") # splits: train, test
179
+ row = ds["test"][0]
180
+ print(row["prompt"]); print(row["output"][0]) # the greedy candidate as clean text
181
+ ```
182
+
183
+ To pick the highest-scoring valid candidate of every prompt:
184
+
185
+ ```python
186
+ best = []
187
+ for r in ds["test"]:
188
+ ok = [(c["ev"], o) for c, o in zip(r["candidates"], r["output"]) if c["format_ok"] and "ev" in c]
189
+ if ok: best.append((max(ok)[0], r["lang"], r["task"], max(ok)[1]))
190
+ ```
191
+
192
+ ## Statistics
193
+
194
+ Rows are (English text, task) pairs; every generated text has an `hm` and an `ood` row (a few have only one). The tables below describe the generated subset, except the curated tables at the end.
195
+
196
+ **Overall.** 20,019 generated English texts, 39,941 rows, 319,528 candidates, 37 base languages, 81 base-switch pairs, plus 6,230 curated test items. The mean quality score `ev` of a valid candidate is 4.12 (train 4.12, test 4.12); `ev` comes from a learned model, not from people.
197
+
198
+ **English source texts.** The texts keep the licences of their sources (see License). Rows by source:
199
+
200
+ | `source_dataset` | train | test |
201
+ |---|---|---|
202
+ | `soda` | 5744 | 7238 |
203
+ | `writingprompts` | 5296 | 6572 |
204
+ | `persona` | 3682 | 4497 |
205
+ | `fineweb_edu` | 1876 | 2266 |
206
+ | `gutenberg` | 1196 | 1574 |
207
+
208
+ **By base language.** `test` has the same number of texts for every language.
209
+
210
+ | Language | Code | train texts | test texts | train rows | test rows |
211
+ |---|---|---|---|---|---|
212
+ | Afrikaans | `afr` | 240 | 300 | 480 | 600 |
213
+ | Amharic | `amh` | 240 | 300 | 480 | 600 |
214
+ | Bambara | `bam` | 241 | 300 | 482 | 600 |
215
+ | Cameroonian Pidgin | `wes` | 241 | 300 | 446 | 557 |
216
+ | Chichewa | `nya` | 239 | 300 | 478 | 600 |
217
+ | Ewe | `ewe` | 241 | 300 | 482 | 599 |
218
+ | Fon | `fon` | 241 | 300 | 482 | 600 |
219
+ | Fulah | `ful` | 241 | 300 | 482 | 600 |
220
+ | Ghanaian Pidgin | `gpe` | 242 | 300 | 476 | 591 |
221
+ | Hausa | `hau` | 241 | 300 | 482 | 600 |
222
+ | Igbo | `ibo` | 241 | 300 | 482 | 600 |
223
+ | Kikuyu | `kik` | 241 | 300 | 482 | 600 |
224
+ | Kinyarwanda | `kin` | 242 | 300 | 484 | 600 |
225
+ | Kirundi | `run` | 241 | 300 | 482 | 600 |
226
+ | Kongo | `kon` | 241 | 300 | 482 | 600 |
227
+ | Lingala | `lin` | 242 | 300 | 484 | 600 |
228
+ | Luganda | `lug` | 242 | 300 | 484 | 600 |
229
+ | Luo | `luo` | 241 | 300 | 482 | 600 |
230
+ | Malagasy | `mlg` | 242 | 300 | 484 | 600 |
231
+ | Nigerian Pidgin | `pcm` | 242 | 300 | 484 | 600 |
232
+ | North Ndebele | `nde` | 241 | 300 | 482 | 600 |
233
+ | Oromo | `orm` | 240 | 300 | 480 | 600 |
234
+ | Sepedi | `nso` | 242 | 300 | 484 | 600 |
235
+ | Sesotho | `sot` | 241 | 300 | 482 | 600 |
236
+ | Setswana | `tsn` | 241 | 300 | 482 | 600 |
237
+ | Shona | `sna` | 241 | 300 | 482 | 600 |
238
+ | Somali | `som` | 241 | 300 | 482 | 600 |
239
+ | Swahili | `swh` | 242 | 300 | 484 | 600 |
240
+ | Swati | `ssw` | 239 | 300 | 478 | 600 |
241
+ | Tigrinya | `tir` | 241 | 300 | 482 | 600 |
242
+ | Tsonga | `tso` | 242 | 300 | 484 | 600 |
243
+ | Tumbuka | `tum` | 241 | 300 | 482 | 600 |
244
+ | Twi | `twi` | 241 | 300 | 482 | 600 |
245
+ | Wolof | `wol` | 241 | 300 | 482 | 600 |
246
+ | Xhosa | `xho` | 242 | 300 | 484 | 600 |
247
+ | Yoruba | `yor` | 240 | 300 | 480 | 600 |
248
+ | Zulu | `zul` | 241 | 300 | 482 | 600 |
249
+
250
+ **By base-switch language pair** (`hm` rows). The last column tells whether our 1B model was trained on this pair. The 3,348 rows of the pairs marked "no" come from an earlier, wider pair list; the model's candidates for them are less reliable, so filter on `pair_in_training_table` if you need only the supported pairs.
251
+
252
+ | Base | Code | Switch | Code | train | test | total | in the 1B training table |
253
+ |---|---|---|---|---|---|---|---|
254
+ | Afrikaans | `afr` | English | `eng` | 117 | 146 | 263 | yes |
255
+ | Afrikaans | `afr` | Zulu | `zul` | 123 | 154 | 277 | no |
256
+ | Amharic | `amh` | Arabic | `ara` | 131 | 164 | 295 | no |
257
+ | Amharic | `amh` | English | `eng` | 109 | 136 | 245 | yes |
258
+ | Bambara | `bam` | French | `fra` | 115 | 143 | 258 | yes |
259
+ | Bambara | `bam` | Wolof | `wol` | 126 | 157 | 283 | no |
260
+ | Cameroonian Pidgin | `wes` | Duala | `dua` | 53 | 68 | 121 | no |
261
+ | Cameroonian Pidgin | `wes` | Ewondo | `ewo` | 79 | 97 | 176 | no |
262
+ | Cameroonian Pidgin | `wes` | French | `fra` | 73 | 92 | 165 | yes |
263
+ | Chichewa | `nya` | English | `eng` | 111 | 141 | 252 | yes |
264
+ | Chichewa | `nya` | Tumbuka | `tum` | 128 | 159 | 287 | yes |
265
+ | Ewe | `ewe` | English | `eng` | 117 | 147 | 264 | yes |
266
+ | Ewe | `ewe` | French | `fra` | 124 | 153 | 277 | yes |
267
+ | Fon | `fon` | French | `fra` | 128 | 160 | 288 | yes |
268
+ | Fon | `fon` | Yoruba | `yor` | 113 | 140 | 253 | yes |
269
+ | Fulah | `ful` | English | `eng` | 121 | 151 | 272 | yes |
270
+ | Fulah | `ful` | French | `fra` | 120 | 149 | 269 | yes |
271
+ | Ghanaian Pidgin | `gpe` | Ewe | `ewe` | 78 | 96 | 174 | yes |
272
+ | Ghanaian Pidgin | `gpe` | Ga | `gaa` | 73 | 92 | 165 | yes |
273
+ | Ghanaian Pidgin | `gpe` | Twi | `twi` | 83 | 103 | 186 | yes |
274
+ | Hausa | `hau` | Arabic | `ara` | 119 | 150 | 269 | yes |
275
+ | Hausa | `hau` | English | `eng` | 122 | 150 | 272 | yes |
276
+ | Igbo | `ibo` | English | `eng` | 112 | 139 | 251 | yes |
277
+ | Igbo | `ibo` | Nigerian Pidgin | `pcm` | 129 | 161 | 290 | yes |
278
+ | Kikuyu | `kik` | English | `eng` | 116 | 143 | 259 | yes |
279
+ | Kikuyu | `kik` | Swahili | `swh` | 125 | 157 | 282 | yes |
280
+ | Kinyarwanda | `kin` | English | `eng` | 83 | 103 | 186 | yes |
281
+ | Kinyarwanda | `kin` | French | `fra` | 78 | 96 | 174 | yes |
282
+ | Kinyarwanda | `kin` | Swahili | `swh` | 81 | 101 | 182 | yes |
283
+ | Kirundi | `run` | French | `fra` | 128 | 159 | 287 | yes |
284
+ | Kirundi | `run` | Swahili | `swh` | 113 | 141 | 254 | yes |
285
+ | Kongo | `kon` | French | `fra` | 117 | 145 | 262 | yes |
286
+ | Kongo | `kon` | Lingala | `lin` | 124 | 155 | 279 | yes |
287
+ | Lingala | `lin` | French | `fra` | 108 | 134 | 242 | yes |
288
+ | Lingala | `lin` | Kongo | `kon` | 134 | 166 | 300 | no |
289
+ | Luganda | `lug` | English | `eng` | 114 | 142 | 256 | yes |
290
+ | Luganda | `lug` | Swahili | `swh` | 128 | 158 | 286 | yes |
291
+ | Luo | `luo` | English | `eng` | 117 | 146 | 263 | yes |
292
+ | Luo | `luo` | Swahili | `swh` | 124 | 154 | 278 | yes |
293
+ | Malagasy | `mlg` | English | `eng` | 120 | 149 | 269 | no |
294
+ | Malagasy | `mlg` | French | `fra` | 122 | 151 | 273 | yes |
295
+ | Nigerian Pidgin | `pcm` | Hausa | `hau` | 83 | 103 | 186 | yes |
296
+ | Nigerian Pidgin | `pcm` | Igbo | `ibo` | 81 | 102 | 183 | yes |
297
+ | Nigerian Pidgin | `pcm` | Yoruba | `yor` | 78 | 95 | 173 | yes |
298
+ | North Ndebele | `nde` | English | `eng` | 125 | 155 | 280 | yes |
299
+ | North Ndebele | `nde` | Shona | `sna` | 116 | 145 | 261 | yes |
300
+ | Oromo | `orm` | Amharic | `amh` | 117 | 145 | 262 | yes |
301
+ | Oromo | `orm` | English | `eng` | 123 | 155 | 278 | yes |
302
+ | Sepedi | `nso` | Afrikaans | `afr` | 124 | 154 | 278 | no |
303
+ | Sepedi | `nso` | English | `eng` | 118 | 146 | 264 | yes |
304
+ | Sesotho | `sot` | Afrikaans | `afr` | 123 | 152 | 275 | yes |
305
+ | Sesotho | `sot` | English | `eng` | 118 | 148 | 266 | yes |
306
+ | Setswana | `tsn` | Afrikaans | `afr` | 115 | 143 | 258 | yes |
307
+ | Setswana | `tsn` | English | `eng` | 126 | 157 | 283 | yes |
308
+ | Shona | `sna` | English | `eng` | 131 | 162 | 293 | yes |
309
+ | Shona | `sna` | North Ndebele | `nde` | 110 | 138 | 248 | no |
310
+ | Somali | `som` | Amharic | `amh` | 54 | 66 | 120 | no |
311
+ | Somali | `som` | Arabic | `ara` | 65 | 81 | 146 | yes |
312
+ | Somali | `som` | English | `eng` | 58 | 74 | 132 | yes |
313
+ | Somali | `som` | Italian | `ita` | 64 | 79 | 143 | no |
314
+ | Swahili | `swh` | Arabic | `ara` | 73 | 91 | 164 | yes |
315
+ | Swahili | `swh` | English | `eng` | 86 | 108 | 194 | yes |
316
+ | Swahili | `swh` | Sheng | `sheng` | 83 | 101 | 184 | yes |
317
+ | Swati | `ssw` | English | `eng` | 116 | 145 | 261 | yes |
318
+ | Swati | `ssw` | Zulu | `zul` | 123 | 155 | 278 | yes |
319
+ | Tigrinya | `tir` | Amharic | `amh` | 118 | 147 | 265 | yes |
320
+ | Tigrinya | `tir` | English | `eng` | 123 | 153 | 276 | yes |
321
+ | Tsonga | `tso` | English | `eng` | 122 | 151 | 273 | yes |
322
+ | Tsonga | `tso` | Zulu | `zul` | 120 | 149 | 269 | yes |
323
+ | Tumbuka | `tum` | Chichewa | `nya` | 112 | 139 | 251 | yes |
324
+ | Tumbuka | `tum` | English | `eng` | 129 | 161 | 290 | yes |
325
+ | Twi | `twi` | English | `eng` | 126 | 155 | 281 | yes |
326
+ | Twi | `twi` | Ghanaian Pidgin | `gpe` | 115 | 145 | 260 | yes |
327
+ | Wolof | `wol` | Arabic | `ara` | 127 | 158 | 285 | no |
328
+ | Wolof | `wol` | French | `fra` | 114 | 142 | 256 | yes |
329
+ | Xhosa | `xho` | Afrikaans | `afr` | 122 | 151 | 273 | no |
330
+ | Xhosa | `xho` | English | `eng` | 120 | 149 | 269 | yes |
331
+ | Yoruba | `yor` | English | `eng` | 115 | 143 | 258 | yes |
332
+ | Yoruba | `yor` | Nigerian Pidgin | `pcm` | 125 | 157 | 282 | yes |
333
+ | Zulu | `zul` | Afrikaans | `afr` | 125 | 155 | 280 | no |
334
+ | Zulu | `zul` | English | `eng` | 116 | 145 | 261 | yes |
335
+
336
+ **Curated test items by language and task** (`test`, `subset = curated`).
337
+
338
+ | Language | Code | eng_hm | m_hm | eng_ood | m_ood | hm_ood | total |
339
+ |---|---|---|---|---|---|---|---|
340
+ | Afrikaans | `afr` | 100 | 100 | 99 | 99 | 99 | 497 |
341
+ | Amharic | `amh` | 99 | 99 | 97 | 97 | 97 | 489 |
342
+ | Bambara | `bam` | 2 | 2 | 2 | 2 | 2 | 10 |
343
+ | Cameroonian Pidgin | `wes` | 1 | 1 | 72 | 72 | 1 | 147 |
344
+ | Chichewa | `nya` | 52 | 52 | 53 | 53 | 51 | 261 |
345
+ | Fon | `fon` | 8 | 8 | 10 | 10 | 8 | 44 |
346
+ | Ghanaian Pidgin | `gpe` | 2 | 2 | 71 | 71 | 1 | 147 |
347
+ | Hausa | `hau` | 74 | 74 | 99 | 99 | 74 | 420 |
348
+ | Igbo | `ibo` | 21 | 21 | 25 | 25 | 21 | 113 |
349
+ | Kikuyu | `kik` | 30 | 30 | 25 | 25 | 25 | 135 |
350
+ | Kinyarwanda | `kin` | 9 | 9 | 9 | 9 | 9 | 45 |
351
+ | Kirundi | `run` | 5 | 5 | 5 | 5 | 5 | 25 |
352
+ | Kongo | `kon` | 4 | 4 | 6 | 6 | 3 | 23 |
353
+ | Lingala | `lin` | 5 | 5 | 6 | 6 | 5 | 27 |
354
+ | Luo | `luo` | 11 | 11 | 10 | 10 | 10 | 52 |
355
+ | Malagasy | `mlg` | 84 | 84 | 91 | 91 | 79 | 429 |
356
+ | Nigerian Pidgin | `pcm` | 74 | 74 | 90 | 90 | 74 | 402 |
357
+ | North Ndebele | `nde` | 99 | 99 | 74 | 74 | 73 | 419 |
358
+ | Oromo | `orm` | 27 | 27 | 27 | 27 | 27 | 135 |
359
+ | Sepedi | `nso` | 37 | 37 | 37 | 37 | 37 | 185 |
360
+ | Sesotho | `sot` | 23 | 23 | 22 | 22 | 22 | 112 |
361
+ | Setswana | `tsn` | 25 | 25 | 25 | 25 | 25 | 125 |
362
+ | Shona | `sna` | 23 | 23 | 23 | 23 | 23 | 115 |
363
+ | Somali | `som` | 91 | 91 | 92 | 92 | 90 | 456 |
364
+ | Swahili | `swh` | 95 | 95 | 99 | 99 | 93 | 481 |
365
+ | Swati | `ssw` | 45 | 45 | 43 | 43 | 41 | 217 |
366
+ | Tigrinya | `tir` | 15 | 15 | 14 | 14 | 14 | 72 |
367
+ | Tsonga | `tso` | 21 | 21 | 20 | 20 | 20 | 102 |
368
+ | Tumbuka | `tum` | 35 | 35 | 33 | 33 | 32 | 168 |
369
+ | Twi | `twi` | 5 | 5 | 11 | 11 | 5 | 37 |
370
+ | Wolof | `wol` | 13 | 13 | 14 | 14 | 13 | 67 |
371
+ | Xhosa | `xho` | 15 | 15 | 15 | 15 | 14 | 74 |
372
+ | Yoruba | `yor` | 31 | 31 | 31 | 31 | 30 | 154 |
373
+ | Zulu | `zul` | 9 | 9 | 9 | 9 | 9 | 45 |
374
+ | **Total** | | 1190 | 1190 | 1359 | 1359 | 1132 | 6230 |
375
+
376
+ **Scores of the three systems on the curated items** (mean over the curated items; none of these scores comes from a person; see How the scores were derived).
377
+
378
+ | `system` | what it is | items | `ev` (1-10) | `chrf` (0-100) | judge `overall` (1-5) |
379
+ |---|---|---|---|---|---|
380
+ | `sft` | supervised | 6,225 | 3.53 | 43.9 | 2.27 |
381
+ | `rl_best` | reinforcement-learned, best checkpoint | 6,225 | 3.75 | 43.5 | 2.15 |
382
+ | `rl_last` | reinforcement-learned, last checkpoint | 6,225 | 3.73 | 43.5 | 2.15 |
383
+ | `reference` | the curated reference text | 6,225 | n/a | n/a | 3.99 |
384
+
385
+ ## Supported prompt formats
386
+
387
+ Prompts use the formats `<hm> <base>+<switch>: TEXT` and `<ood> <base>: TEXT`, with the three-letter language codes in angle brackets and two spaces after the colon.
388
+
389
+ ## Limitations
390
+
391
+ - **Our goal is for this to become the standard benchmark for African-language code-switching**, so that progress can be measured and the languages are better represented. It is not there yet. The candidates were written by a model and have not been checked by native speakers, so for now treat them as references of unknown quality. Human-verified references will replace them, and we welcome contributions, especially from speakers of the 37 languages.
392
+ - Expect unnatural phrasing, invented idioms, wrong tone marks and changes of meaning in the candidates. Pidgin outputs keep a lot of English.
393
+ - The sampled candidates are plain temperature samples, and many are worse than the greedy one. Scores are not comparable across languages, and `ev` likes short, simple code-switching, so don't rank by it blindly.
394
+ - Rows with `pair_in_training_table` set to `false` are less reliable, as explained above.
395
+
396
+ ## License
397
+
398
+ The English source texts keep the licences of their sources: SODA and Synthetic-Persona-Chat are CC BY 4.0, WritingPrompts is MIT, the FineWeb-Edu sample is ODC-By, and Project Gutenberg texts are public domain. CC BY 4.0 and ODC-By require attribution to the original datasets. The generated outputs come from a Gemma-based model, so the [Gemma Terms of Use](https://ai.google.dev/gemma/terms) apply to them. Credit "AletheiaAING" if you use the dataset.
data/new_english_prompts.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:204b946f08654eaa8faf31bcbb37cd4c62065009c36682de1b7e77933b8c8dc6
3
+ size 4100958
data/test.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ad925e90b0cad47deb9700fee72992c3b310811289485255eb6f0cba3fa240c
3
+ size 43110091
data/train.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7245a0b644c785f53a44db649cb257754ed3ffe8d4e5893678267e9c5cb66155
3
+ size 29324473
generate_train_extra.ipynb ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 5,
4
+ "metadata": {
5
+ "accelerator": "GPU",
6
+ "colab": {
7
+ "gpuType": "T4",
8
+ "provenance": []
9
+ },
10
+ "kernelspec": {
11
+ "display_name": "Python 3",
12
+ "name": "python3"
13
+ },
14
+ "language_info": {
15
+ "name": "python"
16
+ }
17
+ },
18
+ "cells": [
19
+ {
20
+ "cell_type": "markdown",
21
+ "metadata": {},
22
+ "source": [
23
+ "# Grow the train set of the African Code-Switch Benchmark\n",
24
+ "\n",
25
+ "This notebook runs **our 8-bit model on the Colab GPU itself** (no server, no API) to write code-switched (`hm`) and idiom-rich (`ood`) versions of about 20,000 new English texts, then **pushes the results to the dataset repo**\n",
26
+ "[`BeardedMonster/african-code-switch-benchmark`](https://huggingface.co/datasets/BeardedMonster/african-code-switch-benchmark).\n",
27
+ "\n",
28
+ "**What happens**\n",
29
+ "1. The model [`BeardedMonster/gemma-3-0.8b-csw`](https://huggingface.co/BeardedMonster/gemma-3-0.8b-csw) (8-bit GGUF, 877 MB) is downloaded from the Hub and loaded on the GPU with `llama-cpp-python`.\n",
30
+ "2. The new English texts (`data/new_english_prompts.jsonl.gz` in the dataset repo, each with a base language and a switch language) are read and turned into rows.\n",
31
+ "3. Every 1,000 rows are written as one shard and uploaded to `data/train_extra/` in the dataset repo, so nothing is lost if Colab disconnects. Run the notebook again and it picks up where it stopped.\n",
32
+ "4. At the end the shards are merged into `data/train_extra.jsonl.gz`, which the dataset's `train` split loads.\n",
33
+ "\n",
34
+ "**Before you run:** choose a GPU runtime (Runtime > Change runtime type > T4 GPU is enough) and add your Hugging Face **write** token as a Colab secret named `HF_TOKEN` (key icon in the left bar), or paste it when asked.\n",
35
+ "\n",
36
+ "**Time.** Several copies of the model run in parallel on the GPU. Expect very roughly 1,000 generated tokens per second on a T4, so about 3 to 5 hours for everything with `N_CANDIDATES = 2`. Test first with `MAX_TEXTS = 100`; a test run does not upload anything. New rows have no `ev` score, because the scoring model is private."
37
+ ]
38
+ },
39
+ {
40
+ "cell_type": "code",
41
+ "metadata": {},
42
+ "source": [
43
+ "import subprocess, sys\n",
44
+ "# Install llama-cpp-python with CUDA: try the prebuilt GPU wheel first, otherwise build it (about 10 minutes)\n",
45
+ "try:\n",
46
+ " import llama_cpp\n",
47
+ "except ImportError:\n",
48
+ " r = subprocess.run(\"pip -q install llama-cpp-python --only-binary=:all: --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124\", shell=True)\n",
49
+ " if r.returncode != 0:\n",
50
+ " subprocess.run('CMAKE_ARGS=\"-DGGML_CUDA=on\" pip -q install llama-cpp-python --no-cache-dir', shell=True, check=True)\n",
51
+ " import llama_cpp\n",
52
+ "subprocess.run(\"pip -q install huggingface_hub\", shell=True, check=True)\n",
53
+ "print(\"llama-cpp-python\", llama_cpp.__version__, \"| GPU offload supported:\", llama_cpp.llama_supports_gpu_offload())"
54
+ ],
55
+ "outputs": [],
56
+ "execution_count": null
57
+ },
58
+ {
59
+ "cell_type": "code",
60
+ "metadata": {},
61
+ "source": [
62
+ "# ---- settings ----\n",
63
+ "DATASET = \"BeardedMonster/african-code-switch-benchmark\"\n",
64
+ "MODEL = \"BeardedMonster/gemma-3-0.8b-csw\"\n",
65
+ "GGUF = \"csw-gemma3-1b-rl3-pruned-Q8_0.gguf\"\n",
66
+ "N_CANDIDATES = 2 # 1 greedy + (N-1) sampled at temperature 0.8. The main dataset has 8 per row; raise it if you have time.\n",
67
+ "WORKERS = 6 # model copies running in parallel on the GPU (6 is fine on a T4; use 3 if you run out of GPU memory)\n",
68
+ "MAX_NEW = 640 # maximum new tokens per output\n",
69
+ "SHARD = 1000 # rows per uploaded shard\n",
70
+ "MAX_TEXTS = None # for a quick test use e.g. 100 (nothing is uploaded); None = all texts"
71
+ ],
72
+ "outputs": [],
73
+ "execution_count": null
74
+ },
75
+ {
76
+ "cell_type": "code",
77
+ "metadata": {},
78
+ "source": [
79
+ "import os, io, gzip, json, re, time, queue, glob, getpass, collections as C\n",
80
+ "from concurrent.futures import ThreadPoolExecutor\n",
81
+ "from huggingface_hub import HfApi, hf_hub_download\n",
82
+ "\n",
83
+ "try:\n",
84
+ " from google.colab import userdata\n",
85
+ " HF_TOKEN = userdata.get(\"HF_TOKEN\")\n",
86
+ "except Exception:\n",
87
+ " HF_TOKEN = os.environ.get(\"HF_TOKEN\") or getpass.getpass(\"Hugging Face write token: \")\n",
88
+ "api = HfApi(token=HF_TOKEN)\n",
89
+ "print(\"logged in as\", api.whoami()[\"name\"])\n",
90
+ "UPLOAD = MAX_TEXTS is None\n",
91
+ "WORK = \"csw_extra\"; os.makedirs(WORK, exist_ok=True)"
92
+ ],
93
+ "outputs": [],
94
+ "execution_count": null
95
+ },
96
+ {
97
+ "cell_type": "code",
98
+ "metadata": {},
99
+ "source": [
100
+ "# Download the model and the new English prompts (runs once)\n",
101
+ "gguf_path = hf_hub_download(MODEL, GGUF)\n",
102
+ "prompts_path = hf_hub_download(DATASET, \"data/new_english_prompts.jsonl.gz\", repo_type=\"dataset\", token=HF_TOKEN)\n",
103
+ "rows = [json.loads(l) for l in gzip.open(prompts_path, \"rt\", encoding=\"utf-8\")]\n",
104
+ "if MAX_TEXTS:\n",
105
+ " keep = set(sorted({r[\"id\"] for r in rows})[:MAX_TEXTS]); rows = [r for r in rows if r[\"id\"] in keep]\n",
106
+ "rows.sort(key=lambda r: (r[\"id\"], r[\"task\"]))\n",
107
+ "print(len(rows), \"prompts,\", len({r[\"id\"] for r in rows}), \"texts,\", len({r[\"lang\"] for r in rows}), \"languages\")\n",
108
+ "print(\"model file:\", gguf_path)"
109
+ ],
110
+ "outputs": [],
111
+ "execution_count": null
112
+ },
113
+ {
114
+ "cell_type": "code",
115
+ "metadata": {},
116
+ "source": [
117
+ "# Load WORKERS copies of the model on the GPU (each copy is about 1 GB)\n",
118
+ "from llama_cpp import Llama\n",
119
+ "N_GPU = int(os.environ.get(\"N_GPU_LAYERS\", \"-1\"))\n",
120
+ "pool = queue.Queue()\n",
121
+ "for _ in range(WORKERS):\n",
122
+ " pool.put(Llama(model_path=gguf_path, n_ctx=1536, n_gpu_layers=N_GPU, n_batch=512, verbose=False))\n",
123
+ "probe = pool.queue[0]\n",
124
+ "EOT = probe.tokenize(b\"<end_of_turn>\", add_bos=False, special=True)[0]; EOS = probe.token_eos()\n",
125
+ "print(\"loaded\", WORKERS, \"copies; end-of-turn token id\", EOT)"
126
+ ],
127
+ "outputs": [],
128
+ "execution_count": null
129
+ },
130
+ {
131
+ "cell_type": "code",
132
+ "metadata": {},
133
+ "source": [
134
+ "TAGS = re.compile(r\"^((?:<(?!/?dev>)\\w{1,8}>)+)\"); DEV = re.compile(r\"^\\s*<dev>(.*?)</dev>\", re.S)\n",
135
+ "\n",
136
+ "def generate(llm, prompt, temperature, seed):\n",
137
+ " text = f\"<start_of_turn>user\\n{prompt}<end_of_turn>\\n<start_of_turn>model\\n\" # the Gemma chat format the model was trained on\n",
138
+ " toks = llm.tokenize(text.encode(\"utf-8\"), add_bos=True, special=True)\n",
139
+ " llm.set_seed(seed); out, finished = [], False\n",
140
+ " for t in llm.generate(toks, top_k=1 if temperature == 0 else 0, top_p=1.0, min_p=0.0, temp=temperature, repeat_penalty=1.0, reset=True):\n",
141
+ " if t in (EOT, EOS): finished = True; break\n",
142
+ " out.append(t)\n",
143
+ " if len(out) >= MAX_NEW: break\n",
144
+ " return llm.detokenize(out, special=True).decode(\"utf-8\", errors=\"ignore\").strip(), finished\n",
145
+ "\n",
146
+ "def parse(text):\n",
147
+ " m = TAGS.match(text); has_tags = bool(m); c = text[m.end():].lstrip() if m else text\n",
148
+ " d = DEV.match(c); final = c[d.end():].strip() if d else c\n",
149
+ " return final, ([x.strip() for x in d.group(1).split(\"|\") if x.strip()] if d else []), bool(has_tags and d and final)\n",
150
+ "\n",
151
+ "def make_row(r):\n",
152
+ " llm = pool.get()\n",
153
+ " try:\n",
154
+ " cands = []\n",
155
+ " for k in range(N_CANDIDATES):\n",
156
+ " text, finished = generate(llm, r[\"prompt\"], 0.0 if k == 0 else 0.8, 1000 + k)\n",
157
+ " final, devices, ok = parse(text)\n",
158
+ " cands.append({\"k\": k, \"greedy\": k == 0, \"text\": text, \"finished\": finished, \"devices\": devices, \"final\": final,\n",
159
+ " \"format_ok\": ok and finished, \"ev\": None, \"system\": None, \"reward\": None, \"chrf\": None, \"judge\": None})\n",
160
+ " finally:\n",
161
+ " pool.put(llm)\n",
162
+ " return {\"id\": r[\"id\"], \"subset\": \"generated\", \"task\": r[\"task\"], \"task_type\": \"eng_\" + r[\"task\"], \"input_type\": \"english\", \"lang\": r[\"lang\"], \"switch\": r[\"switch\"],\n",
163
+ " \"pair_in_training_table\": True, \"prompt\": r[\"prompt\"], \"input\": r[\"english\"], \"english\": r[\"english\"], \"source_dataset\": r[\"source_dataset\"],\n",
164
+ " \"source_register\": r[\"source_register\"], \"reference\": None, \"reference_judge\": None, \"candidates\": cands, \"output\": [c[\"final\"] for c in cands]}"
165
+ ],
166
+ "outputs": [],
167
+ "execution_count": null
168
+ },
169
+ {
170
+ "cell_type": "code",
171
+ "metadata": {},
172
+ "source": [
173
+ "# Generate in shards. Finished shards are uploaded to the dataset repo and skipped when you run this cell again.\n",
174
+ "done_remote = set(f for f in api.list_repo_files(DATASET, repo_type=\"dataset\") if f.startswith(\"data/train_extra/shard_\")) if UPLOAD else set()\n",
175
+ "n_shards = (len(rows) + SHARD - 1) // SHARD; t0 = time.time(); n_done = 0\n",
176
+ "for s in range(n_shards):\n",
177
+ " name = f\"shard_{s:04d}.jsonl.gz\"; local = os.path.join(WORK, name)\n",
178
+ " if f\"data/train_extra/{name}\" in done_remote: continue\n",
179
+ " chunk = rows[s * SHARD:(s + 1) * SHARD]\n",
180
+ " with ThreadPoolExecutor(WORKERS) as ex: out = list(ex.map(make_row, chunk))\n",
181
+ " with gzip.open(local, \"wt\", encoding=\"utf-8\") as fo:\n",
182
+ " for r in out: fo.write(json.dumps(r, ensure_ascii=False) + \"\\n\")\n",
183
+ " if UPLOAD:\n",
184
+ " api.upload_file(path_or_fileobj=local, path_in_repo=f\"data/train_extra/{name}\", repo_id=DATASET, repo_type=\"dataset\", commit_message=f\"train_extra shard {s}\")\n",
185
+ " n_done += len(chunk)\n",
186
+ " print(f\"shard {s + 1}/{n_shards} done and {'uploaded' if UPLOAD else 'saved'} | {n_done} rows | {(time.time() - t0) / 60:.1f} min\", flush=True)"
187
+ ],
188
+ "outputs": [],
189
+ "execution_count": null
190
+ },
191
+ {
192
+ "cell_type": "code",
193
+ "metadata": {},
194
+ "source": [
195
+ "# Merge all shards into data/train_extra.jsonl.gz (the train split loads this file) and print a summary\n",
196
+ "merged = os.path.join(WORK, \"train_extra.jsonl.gz\"); allrows = []\n",
197
+ "for s in range(n_shards):\n",
198
+ " name = f\"shard_{s:04d}.jsonl.gz\"; local = os.path.join(WORK, name)\n",
199
+ " if not os.path.exists(local) and UPLOAD:\n",
200
+ " local = hf_hub_download(DATASET, f\"data/train_extra/{name}\", repo_type=\"dataset\", token=HF_TOKEN)\n",
201
+ " allrows += [json.loads(l) for l in gzip.open(local, \"rt\", encoding=\"utf-8\")]\n",
202
+ "with gzip.open(merged, \"wt\", encoding=\"utf-8\") as fo:\n",
203
+ " for r in allrows: fo.write(json.dumps(r, ensure_ascii=False) + \"\\n\")\n",
204
+ "cs = [c for r in allrows for c in r[\"candidates\"]]\n",
205
+ "print(len(allrows), \"rows,\", len({r[\"id\"] for r in allrows}), \"texts,\", len(cs), \"candidates, format ok:\", round(sum(c[\"format_ok\"] for c in cs) / max(1, len(cs)), 3))\n",
206
+ "print(\"rows per language, lowest and highest:\", C.Counter(r[\"lang\"] for r in allrows).most_common()[-1], C.Counter(r[\"lang\"] for r in allrows).most_common()[0])\n",
207
+ "print(allrows[0][\"prompt\"][:100]); print(allrows[0][\"output\"][0][:200])\n",
208
+ "if UPLOAD:\n",
209
+ " api.upload_file(path_or_fileobj=merged, path_in_repo=\"data/train_extra.jsonl.gz\", repo_id=DATASET, repo_type=\"dataset\", commit_message=\"Add train_extra (generated with gemma-3-0.8b-csw)\")\n",
210
+ " print(\"uploaded data/train_extra.jsonl.gz\")"
211
+ ],
212
+ "outputs": [],
213
+ "execution_count": null
214
+ }
215
+ ]
216
+ }