BeardedMonster's picture
Standalone in-process notebook; train split also loads train_extra
ffdc21e verified
|
Raw History Blame Contribute Delete
23.8 kB
metadata
size_categories:
  - 10K<n<100K
tags:
  - african-languages
  - code-switching
  - idioms
  - benchmark
  - synthetic
license: other
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
task_categories:
  - text-generation
dataset_info:
  features:
    - name: id
      dtype: string
    - name: subset
      dtype: string
    - name: task
      dtype: string
    - name: task_type
      dtype: string
    - name: input_type
      dtype: string
    - name: lang
      dtype: string
    - name: switch
      dtype: string
    - name: pair_in_training_table
      dtype: bool
    - name: prompt
      dtype: string
    - name: input
      dtype: string
    - name: english
      dtype: string
    - name: source_dataset
      dtype: string
    - name: source_register
      dtype: string
    - name: reference
      dtype: string
    - name: reference_judge
      struct:
        - name: meaning
          dtype: float64
        - name: base_language
          dtype: float64
        - name: switch_language
          dtype: float64
        - name: language_compliance
          dtype: float64
        - name: switching_naturalness
          dtype: float64
        - name: language_correctness
          dtype: float64
        - name: idiom_use
          dtype: float64
        - name: naturalness
          dtype: float64
        - name: overall
          dtype: float64
    - name: candidates
      list:
        - name: k
          dtype: int64
        - name: greedy
          dtype: bool
        - name: text
          dtype: string
        - name: finished
          dtype: bool
        - name: devices
          list: string
        - name: final
          dtype: string
        - name: format_ok
          dtype: bool
        - name: ev
          dtype: float64
        - name: system
          dtype: string
        - name: reward
          dtype: float64
        - name: chrf
          dtype: float64
        - name: judge
          struct:
            - name: meaning
              dtype: float64
            - name: base_language
              dtype: float64
            - name: switch_language
              dtype: float64
            - name: language_compliance
              dtype: float64
            - name: switching_naturalness
              dtype: float64
            - name: language_correctness
              dtype: float64
            - name: idiom_use
              dtype: float64
            - name: naturalness
              dtype: float64
            - name: overall
              dtype: float64
    - name: output
      list: string
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train*.jsonl.gz
      - split: test
        path: data/test.jsonl.gz

African Code-Switch Benchmark

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.

Two rewrite tasks:

  • 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.
  • ood rewrites the text in lively, everyday language full of idiomatic expressions (including sayings and comparisons) just like a native speaker would.

Train and test

Split Subset English texts or items Rows hm rows ood rows Candidates
train generated 8,919 17,794 8,875 8,919 142,352
test generated 11,100 22,147 11,048 11,099 177,176
test curated 6,230 6,230 2,380 3,850 18,675

The subset column tells the two kinds of rows apart.

test is the benchmark. It has two parts:

  • 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 (AletheiaAING/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.
  • 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.

Report scores per language as well as the average.

train holds the remaining 8,919 generated texts.

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.

What you can use it for

  • Turn single-language chat or instruction data into code-switched user queries or assistant replies.
  • Build text for ASR language models, TTS scripts and word lists with switched phrases (have a native speaker check it first).
  • Test chatbots, translation and language-ID systems on code-switched inputs.
  • Train and evaluate code-switch detectors with the labelled switched phrases (the devices field).
  • Measure progress on African-language code-switching with the test split.
  • Study how to pick good code-switched text from several candidates.

Columns

Each row is one input text with one task. Columns that don't apply to a row are null.

Row columns

Column Meaning
id id of the item. For generated rows the hm and ood rows of one text share it.
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).
task what is asked: hm (code-switching) or ood (idiom-rich rewrite).
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.
input_type the language of the input: english, base_language or code_switched.
lang base language code, for example yor.
switch switch language code for hm tasks and hm_ood, otherwise null.
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.
prompt the exact prompt given to the model, for example <hm> <kon>+<fra>: Hey there! ....
input the text the model had to rewrite (also inside prompt).
english the English source text, null when the input is not English.
source_dataset, source_register where the English text comes from and its register (chat, story, complex); curated rows have source_dataset = curated.
reference the curated reference rewrite, with tags and device block removed. curated rows only.
reference_judge judge grades of the reference (see below). curated rows only.
candidates the candidate outputs, one entry each (columns below).
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.

Columns inside each entry of candidates

Column Meaning
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.
greedy true if this is a greedy (temperature 0) output.
text the raw output: language tags, <dev> block and text.
finished true if the model stopped by itself and was not cut off at the length limit (null for curated rows).
devices the switched phrases (hm) or idioms (ood) the model listed, as they appear in the text.
final the text without tags and device block.
format_ok true if the output has the language tags, one device block and a non-empty text.
ev learned quality score, 1 to 10, null when missing.
system curated rows only: sft (supervised), rl_best or rl_last (reinforcement-learned, best and last checkpoint).
reward curated rows only: the rule-based reward (can be negative; higher is better).
chrf curated rows only: chrF++ of final against reference, 0 to 100.
judge curated rows only: judge grades of this output, a record with the criteria below.

Use output[i] for the text of candidates[i].

How the scores were derived

None of these scores comes from a person.

  • 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.
  • 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.
  • 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.
  • 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.

Example row, shortened:

{"id": "persona:7cad82bb1996", "task": "hm", "lang": "kon", "switch": "fra", "pair_in_training_table": true,
 "prompt": "<hm> <kon>+<fra>:  Hey there! Hi there! I love to read books. ...", "english": "Hey there! Hi there! I love to read books. ...",
 "source_dataset": "persona", "source_register": "chat",
 "candidates": [{"k": 0, "greedy": true, "text": "<kon><fra><dev>les livres | Tes | ...</dev> Eh, mono kele kuna! ...", "finished": true,
                 "devices": ["les livres", "Tes"], "final": "Eh, mono kele kuna! ...", "format_ok": true, "ev": 3.1}, "... 7 more ..."],
 "output": ["Eh, mono kele kuna! ...", "... 7 more ..."]}

How to use it

from datasets import load_dataset

ds = load_dataset("AletheiaAING/african-code-switch-benchmark")          # splits: train, test
row = ds["test"][0]
print(row["prompt"]); print(row["output"][0])    # the greedy candidate as clean text

To pick the highest-scoring valid candidate of every prompt:

best = []
for r in ds["test"]:
    ok = [(c["ev"], o) for c, o in zip(r["candidates"], r["output"]) if c["format_ok"] and "ev" in c]
    if ok: best.append((max(ok)[0], r["lang"], r["task"], max(ok)[1]))

Statistics

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.

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.

English source texts. The texts keep the licences of their sources (see License). Rows by source:

source_dataset train test
soda 5744 7238
writingprompts 5296 6572
persona 3682 4497
fineweb_edu 1876 2266
gutenberg 1196 1574

By base language. test has the same number of texts for every language.

Language Code train texts test texts train rows test rows
Afrikaans afr 240 300 480 600
Amharic amh 240 300 480 600
Bambara bam 241 300 482 600
Cameroonian Pidgin wes 241 300 446 557
Chichewa nya 239 300 478 600
Ewe ewe 241 300 482 599
Fon fon 241 300 482 600
Fulah ful 241 300 482 600
Ghanaian Pidgin gpe 242 300 476 591
Hausa hau 241 300 482 600
Igbo ibo 241 300 482 600
Kikuyu kik 241 300 482 600
Kinyarwanda kin 242 300 484 600
Kirundi run 241 300 482 600
Kongo kon 241 300 482 600
Lingala lin 242 300 484 600
Luganda lug 242 300 484 600
Luo luo 241 300 482 600
Malagasy mlg 242 300 484 600
Nigerian Pidgin pcm 242 300 484 600
North Ndebele nde 241 300 482 600
Oromo orm 240 300 480 600
Sepedi nso 242 300 484 600
Sesotho sot 241 300 482 600
Setswana tsn 241 300 482 600
Shona sna 241 300 482 600
Somali som 241 300 482 600
Swahili swh 242 300 484 600
Swati ssw 239 300 478 600
Tigrinya tir 241 300 482 600
Tsonga tso 242 300 484 600
Tumbuka tum 241 300 482 600
Twi twi 241 300 482 600
Wolof wol 241 300 482 600
Xhosa xho 242 300 484 600
Yoruba yor 240 300 480 600
Zulu zul 241 300 482 600

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.

Base Code Switch Code train test total in the 1B training table
Afrikaans afr English eng 117 146 263 yes
Afrikaans afr Zulu zul 123 154 277 no
Amharic amh Arabic ara 131 164 295 no
Amharic amh English eng 109 136 245 yes
Bambara bam French fra 115 143 258 yes
Bambara bam Wolof wol 126 157 283 no
Cameroonian Pidgin wes Duala dua 53 68 121 no
Cameroonian Pidgin wes Ewondo ewo 79 97 176 no
Cameroonian Pidgin wes French fra 73 92 165 yes
Chichewa nya English eng 111 141 252 yes
Chichewa nya Tumbuka tum 128 159 287 yes
Ewe ewe English eng 117 147 264 yes
Ewe ewe French fra 124 153 277 yes
Fon fon French fra 128 160 288 yes
Fon fon Yoruba yor 113 140 253 yes
Fulah ful English eng 121 151 272 yes
Fulah ful French fra 120 149 269 yes
Ghanaian Pidgin gpe Ewe ewe 78 96 174 yes
Ghanaian Pidgin gpe Ga gaa 73 92 165 yes
Ghanaian Pidgin gpe Twi twi 83 103 186 yes
Hausa hau Arabic ara 119 150 269 yes
Hausa hau English eng 122 150 272 yes
Igbo ibo English eng 112 139 251 yes
Igbo ibo Nigerian Pidgin pcm 129 161 290 yes
Kikuyu kik English eng 116 143 259 yes
Kikuyu kik Swahili swh 125 157 282 yes
Kinyarwanda kin English eng 83 103 186 yes
Kinyarwanda kin French fra 78 96 174 yes
Kinyarwanda kin Swahili swh 81 101 182 yes
Kirundi run French fra 128 159 287 yes
Kirundi run Swahili swh 113 141 254 yes
Kongo kon French fra 117 145 262 yes
Kongo kon Lingala lin 124 155 279 yes
Lingala lin French fra 108 134 242 yes
Lingala lin Kongo kon 134 166 300 no
Luganda lug English eng 114 142 256 yes
Luganda lug Swahili swh 128 158 286 yes
Luo luo English eng 117 146 263 yes
Luo luo Swahili swh 124 154 278 yes
Malagasy mlg English eng 120 149 269 no
Malagasy mlg French fra 122 151 273 yes
Nigerian Pidgin pcm Hausa hau 83 103 186 yes
Nigerian Pidgin pcm Igbo ibo 81 102 183 yes
Nigerian Pidgin pcm Yoruba yor 78 95 173 yes
North Ndebele nde English eng 125 155 280 yes
North Ndebele nde Shona sna 116 145 261 yes
Oromo orm Amharic amh 117 145 262 yes
Oromo orm English eng 123 155 278 yes
Sepedi nso Afrikaans afr 124 154 278 no
Sepedi nso English eng 118 146 264 yes
Sesotho sot Afrikaans afr 123 152 275 yes
Sesotho sot English eng 118 148 266 yes
Setswana tsn Afrikaans afr 115 143 258 yes
Setswana tsn English eng 126 157 283 yes
Shona sna English eng 131 162 293 yes
Shona sna North Ndebele nde 110 138 248 no
Somali som Amharic amh 54 66 120 no
Somali som Arabic ara 65 81 146 yes
Somali som English eng 58 74 132 yes
Somali som Italian ita 64 79 143 no
Swahili swh Arabic ara 73 91 164 yes
Swahili swh English eng 86 108 194 yes
Swahili swh Sheng sheng 83 101 184 yes
Swati ssw English eng 116 145 261 yes
Swati ssw Zulu zul 123 155 278 yes
Tigrinya tir Amharic amh 118 147 265 yes
Tigrinya tir English eng 123 153 276 yes
Tsonga tso English eng 122 151 273 yes
Tsonga tso Zulu zul 120 149 269 yes
Tumbuka tum Chichewa nya 112 139 251 yes
Tumbuka tum English eng 129 161 290 yes
Twi twi English eng 126 155 281 yes
Twi twi Ghanaian Pidgin gpe 115 145 260 yes
Wolof wol Arabic ara 127 158 285 no
Wolof wol French fra 114 142 256 yes
Xhosa xho Afrikaans afr 122 151 273 no
Xhosa xho English eng 120 149 269 yes
Yoruba yor English eng 115 143 258 yes
Yoruba yor Nigerian Pidgin pcm 125 157 282 yes
Zulu zul Afrikaans afr 125 155 280 no
Zulu zul English eng 116 145 261 yes

Curated test items by language and task (test, subset = curated).

Language Code eng_hm m_hm eng_ood m_ood hm_ood total
Afrikaans afr 100 100 99 99 99 497
Amharic amh 99 99 97 97 97 489
Bambara bam 2 2 2 2 2 10
Cameroonian Pidgin wes 1 1 72 72 1 147
Chichewa nya 52 52 53 53 51 261
Fon fon 8 8 10 10 8 44
Ghanaian Pidgin gpe 2 2 71 71 1 147
Hausa hau 74 74 99 99 74 420
Igbo ibo 21 21 25 25 21 113
Kikuyu kik 30 30 25 25 25 135
Kinyarwanda kin 9 9 9 9 9 45
Kirundi run 5 5 5 5 5 25
Kongo kon 4 4 6 6 3 23
Lingala lin 5 5 6 6 5 27
Luo luo 11 11 10 10 10 52
Malagasy mlg 84 84 91 91 79 429
Nigerian Pidgin pcm 74 74 90 90 74 402
North Ndebele nde 99 99 74 74 73 419
Oromo orm 27 27 27 27 27 135
Sepedi nso 37 37 37 37 37 185
Sesotho sot 23 23 22 22 22 112
Setswana tsn 25 25 25 25 25 125
Shona sna 23 23 23 23 23 115
Somali som 91 91 92 92 90 456
Swahili swh 95 95 99 99 93 481
Swati ssw 45 45 43 43 41 217
Tigrinya tir 15 15 14 14 14 72
Tsonga tso 21 21 20 20 20 102
Tumbuka tum 35 35 33 33 32 168
Twi twi 5 5 11 11 5 37
Wolof wol 13 13 14 14 13 67
Xhosa xho 15 15 15 15 14 74
Yoruba yor 31 31 31 31 30 154
Zulu zul 9 9 9 9 9 45
Total 1190 1190 1359 1359 1132 6230

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).

system what it is items ev (1-10) chrf (0-100) judge overall (1-5)
sft supervised 6,225 3.53 43.9 2.27
rl_best reinforcement-learned, best checkpoint 6,225 3.75 43.5 2.15
rl_last reinforcement-learned, last checkpoint 6,225 3.73 43.5 2.15
reference the curated reference text 6,225 n/a n/a 3.99

Supported prompt formats

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.

Limitations

  • 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.
  • Expect unnatural phrasing, invented idioms, wrong tone marks and changes of meaning in the candidates. Pidgin outputs keep a lot of English.
  • 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.
  • Rows with pair_in_training_table set to false are less reliable, as explained above.

License

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 apply to them. Credit "AletheiaAING" if you use the dataset.