Theafricatechguy ToluClassics commited on
Commit
fa0bb46
·
0 Parent(s):

Duplicate from masakhane/afriqa

Browse files

Co-authored-by: Odunayo Ogundepo <ToluClassics@users.noreply.huggingface.co>

Files changed (3) hide show
  1. .gitattributes +54 -0
  2. README.md +208 -0
  3. afriqa.py +116 -0
.gitattributes ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
12
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
13
+ *.model filter=lfs diff=lfs merge=lfs -text
14
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
15
+ *.npy filter=lfs diff=lfs merge=lfs -text
16
+ *.npz filter=lfs diff=lfs merge=lfs -text
17
+ *.onnx filter=lfs diff=lfs merge=lfs -text
18
+ *.ot filter=lfs diff=lfs merge=lfs -text
19
+ *.parquet filter=lfs diff=lfs merge=lfs -text
20
+ *.pb filter=lfs diff=lfs merge=lfs -text
21
+ *.pickle filter=lfs diff=lfs merge=lfs -text
22
+ *.pkl filter=lfs diff=lfs merge=lfs -text
23
+ *.pt filter=lfs diff=lfs merge=lfs -text
24
+ *.pth filter=lfs diff=lfs merge=lfs -text
25
+ *.rar filter=lfs diff=lfs merge=lfs -text
26
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
27
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ # Audio files - uncompressed
37
+ *.pcm filter=lfs diff=lfs merge=lfs -text
38
+ *.sam filter=lfs diff=lfs merge=lfs -text
39
+ *.raw filter=lfs diff=lfs merge=lfs -text
40
+ # Audio files - compressed
41
+ *.aac filter=lfs diff=lfs merge=lfs -text
42
+ *.flac filter=lfs diff=lfs merge=lfs -text
43
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
44
+ *.ogg filter=lfs diff=lfs merge=lfs -text
45
+ *.wav filter=lfs diff=lfs merge=lfs -text
46
+ # Image files - uncompressed
47
+ *.bmp filter=lfs diff=lfs merge=lfs -text
48
+ *.gif filter=lfs diff=lfs merge=lfs -text
49
+ *.png filter=lfs diff=lfs merge=lfs -text
50
+ *.tiff filter=lfs diff=lfs merge=lfs -text
51
+ # Image files - compressed
52
+ *.jpg filter=lfs diff=lfs merge=lfs -text
53
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
54
+ *.webp filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-sa-4.0
3
+ task_categories:
4
+ - question-answering
5
+ language:
6
+ - bem
7
+ - fon
8
+ - ha
9
+ - ig
10
+ - kin
11
+ - sw
12
+ - wo
13
+ - yo
14
+ - zu
15
+ - tw
16
+ pretty_name: AfriQA
17
+ size_categories:
18
+ - 10K<n<100K
19
+ multilinguality:
20
+ - multilingual
21
+ tags:
22
+ - cross-lingual
23
+ - question-answering
24
+ - qa
25
+ ---
26
+
27
+ # Dataset Card for AfriQA
28
+
29
+ ## Table of Contents
30
+ - [Table of Contents](#table-of-contents)
31
+ - [Dataset Description](#dataset-description)
32
+ - [Dataset Summary](#dataset-summary)
33
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
34
+ - [Languages](#languages)
35
+ - [Dataset Structure](#dataset-structure)
36
+ - [Data Instances](#data-instances)
37
+ - [Data Splits](#data-splits)
38
+ - [Dataset Creation](#dataset-creation)
39
+ - [Curation Rationale](#curation-rationale)
40
+ - [Source Data](#source-data)
41
+ - [Annotations](#annotations)
42
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
43
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
44
+ - [Social Impact of Dataset](#social-impact-of-dataset)
45
+ - [Discussion of Biases](#discussion-of-biases)
46
+ - [Other Known Limitations](#other-known-limitations)
47
+ - [Additional Information](#additional-information)
48
+ - [Dataset Curators](#dataset-curators)
49
+ - [Licensing Information](#licensing-information)
50
+ - [Citation Information](#citation-information)
51
+ - [Contributions](#contributions)
52
+
53
+ ## Dataset Description
54
+
55
+ - **Homepage:** [homepage](https://github.com/masakhane-io/afriqa)
56
+ - **Repository:** [github](https://github.com/masakhane-io/afriqa)
57
+ - **Paper:** [paper]()
58
+ - **Point of Contact:** [Masakhane](https://www.masakhane.io/) or oogundep@uwaterloo.ca
59
+
60
+ ### Dataset Summary
61
+
62
+ AfriQA is the first cross-lingual question answering (QA) dataset with a focus on African languages. The dataset includes over 12,000 XOR QA examples across 10 African languages, making it an invaluable resource for developing more equitable QA technology.
63
+
64
+ The train/validation/test sets are available for all the 10 languages.
65
+
66
+
67
+ ### Supported Tasks and Leaderboards
68
+
69
+ - `question-answering`: The performance in this task is measured with [F1](https://huggingface.co/metrics/f1) (higher is better) and [Exact Match Accuracy](https://huggingface.co/spaces/evaluate-metric/exact_match).
70
+
71
+ ### Languages
72
+
73
+ There are 20 languages available :
74
+ - Bemba (bem)
75
+ - Fon (fon)
76
+ - Hausa (hau)
77
+ - Igbo (ibo)
78
+ - Kinyarwanda (kin)
79
+ - Swahili (swą)
80
+ - Twi (twi)
81
+ - Wolof (wol)
82
+ - Yorùbá (yor)
83
+ - Zulu (zul)
84
+
85
+ ## Dataset Structure
86
+
87
+ ### Data Instances
88
+
89
+ - Data Format:
90
+ - id : Question ID
91
+ - question : Question in African Language
92
+ - translated_question : Question translated into a pivot language (English/French)
93
+ - answers : Answer in African Language
94
+ - lang : Datapoint Language (African Language) e.g `bem`
95
+ - split : Dataset Split
96
+ - translated_answer : Answer in Pivot Language
97
+ - translation_type : Translation type of question and answers
98
+
99
+
100
+ ```bash
101
+ { "id": 0,
102
+ "question": "Bushe icaalo ca Egypt caali tekwapo ne caalo cimbi?",
103
+ "translated_question": "Has the country of Egypt been colonized before?",
104
+ "answers": "['Emukwai']",
105
+ "lang": "bem",
106
+ "split": "dev",
107
+ "translated_answer": "['yes']",
108
+ "translation_type": "human_translation"
109
+ }
110
+ ```
111
+
112
+ ### Data Splits
113
+
114
+ For all languages, there are three splits.
115
+
116
+ The original splits were named `train`, `dev` and `test` and they correspond to the `train`, `validation` and `test` splits.
117
+
118
+ The splits have the following sizes :
119
+
120
+ | Language | train | dev | test |
121
+ |-----------------|------:|-----------:|-----:|
122
+ | Bemba | 502 | 503 | 314 |
123
+ | Fon | 427 | 428 | 386 |
124
+ | Hausa | 435 | 436 | 300 |
125
+ | Igbo | 417 | 418 | 409 |
126
+ | Kinyarwanda | 407 | 409 | 347 |
127
+ | Swahili | 415 | 417 | 302 |
128
+ | Twi | 451 | 452 | 490 |
129
+ | Wolof | 503 | 504 | 334 |
130
+ | Yoruba | 360 | 361 | 332 |
131
+ | Zulu | 387 | 388 | 325 |
132
+ | <b>Total</b> | <b>4333</b> | <b>4346</b> |<b>3560</b> |
133
+
134
+ ## Dataset Creation
135
+
136
+ ### Curation Rationale
137
+
138
+ The dataset was introduced to introduce question-answering resources to 10 languages that were under-served for natural language processing.
139
+
140
+ [More Information Needed]
141
+
142
+ ### Source Data
143
+
144
+ ...
145
+
146
+ #### Initial Data Collection and Normalization
147
+
148
+ ...
149
+
150
+ #### Who are the source language producers?
151
+
152
+ ...
153
+
154
+ ### Annotations
155
+
156
+ #### Annotation process
157
+
158
+ Details can be found here ...
159
+
160
+ #### Who are the annotators?
161
+
162
+ Annotators were recruited from [Masakhane](https://www.masakhane.io/)
163
+
164
+ ### Personal and Sensitive Information
165
+
166
+ ...
167
+
168
+ ## Considerations for Using the Data
169
+
170
+ ### Social Impact of Dataset
171
+ [More Information Needed]
172
+
173
+
174
+ ### Discussion of Biases
175
+ [More Information Needed]
176
+
177
+
178
+ ### Other Known Limitations
179
+
180
+ Users should keep in mind that the dataset only contains news text, which might limit the applicability of the developed systems to other domains.
181
+
182
+ ## Additional Information
183
+
184
+ ### Dataset Curators
185
+
186
+
187
+ ### Licensing Information
188
+
189
+ The licensing status of the data is CC 4.0 Non-Commercial
190
+
191
+ ### Citation Information
192
+
193
+ Provide the [BibTex](http://www.bibtex.org/)-formatted reference for the dataset. For example:
194
+
195
+ ```
196
+ @misc{ogundepo2023afriqa,
197
+ title={AfriQA: Cross-lingual Open-Retrieval Question Answering for African Languages},
198
+ author={Odunayo Ogundepo and Tajuddeen R. Gwadabe and Clara E. Rivera and Jonathan H. Clark and Sebastian Ruder and David Ifeoluwa Adelani and Bonaventure F. P. Dossou and Abdou Aziz DIOP and Claytone Sikasote and Gilles Hacheme and Happy Buzaaba and Ignatius Ezeani and Rooweither Mabuya and Salomey Osei and Chris Emezue and Albert Njoroge Kahira and Shamsuddeen H. Muhammad and Akintunde Oladipo and Abraham Toluwase Owodunni and Atnafu Lambebo Tonja and Iyanuoluwa Shode and Akari Asai and Tunde Oluwaseyi Ajayi and Clemencia Siro and Steven Arthur and Mofetoluwa Adeyemi and Orevaoghene Ahia and Aremu Anuoluwapo and Oyinkansola Awosan and Chiamaka Chukwuneke and Bernard Opoku and Awokoya Ayodele and Verrah Otiende and Christine Mwase and Boyd Sinkala and Andre Niyongabo Rubungo and Daniel A. Ajisafe and Emeka Felix Onwuegbuzia and Habib Mbow and Emile Niyomutabazi and Eunice Mukonde and Falalu Ibrahim Lawan and Ibrahim Said Ahmad and Jesujoba O. Alabi and Martin Namukombo and Mbonu Chinedu and Mofya Phiri and Neo Putini and Ndumiso Mngoma and Priscilla A. Amuok and Ruqayya Nasir Iro and Sonia Adhiambo},
199
+ year={2023},
200
+ eprint={2305.06897},
201
+ archivePrefix={arXiv},
202
+ primaryClass={cs.CL}
203
+ }
204
+ ```
205
+
206
+ ### Contributions
207
+
208
+ Thanks to [@ToluClassics](https://github.com/ToluClassics) for adding this dataset.
afriqa.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """AfriQA dataset."""
2
+
3
+
4
+ import json
5
+ import os
6
+ from textwrap import dedent
7
+
8
+ import datasets
9
+
10
+
11
+ _HOMEPAGE = "https://github.com/masakhane-io/afriqa"
12
+
13
+ _DESCRIPTION = """\
14
+ AfriQA: Cross-lingual Open-Retrieval Question Answering for African Languages
15
+
16
+ AfriQA is the first cross-lingual question answering (QA) dataset with a focus on African languages.
17
+ The dataset includes over 12,000 XOR QA examples across 10 African languages, making it an invaluable resource for developing more equitable QA technology.
18
+ """
19
+
20
+ _CITATION = """\
21
+
22
+ """
23
+
24
+ _URL = "https://github.com/masakhane-io/afriqa/raw/main/data/queries/"
25
+
26
+ _LANG_2_PIVOT = {
27
+ "bem": "en",
28
+ "fon": "fr",
29
+ "hau": "en",
30
+ "ibo": "en",
31
+ "kin": "en",
32
+ "swa": "en",
33
+ "twi": "en",
34
+ "wol": "fr",
35
+ "yor": "en",
36
+ "zul": "en",
37
+ }
38
+
39
+ class AfriQAConfig(datasets.BuilderConfig):
40
+ """BuilderConfig for AfriQA"""
41
+
42
+ def __init__(self, **kwargs):
43
+ """BuilderConfig for AfriQA.
44
+ Args:
45
+ **kwargs: keyword arguments forwarded to super.
46
+ """
47
+ super(AfriQAConfig, self).__init__(**kwargs)
48
+
49
+
50
+ class AfriQA(datasets.GeneratorBasedBuilder):
51
+ """AfriQA dataset."""
52
+
53
+ VERSION = datasets.Version("1.0.0")
54
+
55
+ BUILDER_CONFIGS = [
56
+ AfriQAConfig(name="bem", version=datasets.Version("1.0.0"), description="AfriQA Bemba dataset"),
57
+ AfriQAConfig(name="fon", version=datasets.Version("1.0.0"), description="AfriQA Fon dataset"),
58
+ AfriQAConfig(name="hau", version=datasets.Version("1.0.0"), description="AfriQA Hausa dataset"),
59
+ AfriQAConfig(name="ibo", version=datasets.Version("1.0.0"), description="AfriQA Igbo dataset"),
60
+ AfriQAConfig(name="kin", version=datasets.Version("1.0.0"), description="AfriQA Kinyarwanda dataset"),
61
+ AfriQAConfig(name="swa", version=datasets.Version("1.0.0"), description="AfriQA Swahili dataset"),
62
+ AfriQAConfig(name="twi", version=datasets.Version("1.0.0"), description="AfriQA Twi dataset"),
63
+ AfriQAConfig(name="wol", version=datasets.Version("1.0.0"), description="AfriQA Wolof dataset"),
64
+ AfriQAConfig(name="yor", version=datasets.Version("1.0.0"), description="AfriQA Yoruba dataset"),
65
+ AfriQAConfig(name="zul", version=datasets.Version("1.0.0"), description="AfriQA Zulu dataset"),
66
+ ]
67
+
68
+ def _info(self):
69
+ return datasets.DatasetInfo(
70
+ description=_DESCRIPTION,
71
+ features=datasets.Features(
72
+ {
73
+ "question": datasets.Value("string"),
74
+ "answers": datasets.Value("string"),
75
+ "lang": datasets.Value("string"),
76
+ "split": datasets.Value("string"),
77
+ "translated_question": datasets.Value("string"),
78
+ "translated_answer": datasets.Value("string"),
79
+ "translation_type": datasets.Value("string"),
80
+ }
81
+ ),
82
+ homepage=_HOMEPAGE,
83
+ citation=_CITATION,
84
+ )
85
+
86
+ def _split_generators(self, dl_manager):
87
+ """Returns SplitGenerators."""
88
+ urls_to_download = {
89
+ "train": f"{_URL}{self.config.name}/queries.afriqa.{self.config.name}.{_LANG_2_PIVOT[self.config.name]}.train.json",
90
+ "dev": f"{_URL}{self.config.name}/queries.afriqa.{self.config.name}.{_LANG_2_PIVOT[self.config.name]}.dev.json",
91
+ "test": f"{_URL}{self.config.name}/queries.afriqa.{self.config.name}.{_LANG_2_PIVOT[self.config.name]}.test.json",
92
+ }
93
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
94
+
95
+ return [
96
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
97
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
98
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
99
+ ]
100
+
101
+ def _generate_examples(self, filepath):
102
+ """Yields examples."""
103
+ with open(filepath, encoding="utf-8-sig") as f:
104
+ for _, row in enumerate(f):
105
+ example = json.loads(row)
106
+ _id = example["id"]
107
+
108
+ yield _id, {
109
+ "question": example["question"],
110
+ "answers": example["answers"],
111
+ "lang": example["lang"],
112
+ "split": example["split"],
113
+ "translated_question": example["translated_question"],
114
+ "translated_answer": example["translated_answer"],
115
+ "translation_type": example["translation_type"],
116
+ }