Everlyn commited on
Commit
78d8980
·
verified ·
1 Parent(s): 0f1340e

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +256 -0
README.md ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - sw
4
+ license: cc-by-4.0
5
+ task_categories:
6
+ - question-answering
7
+ tags:
8
+ - swahili
9
+ - kiswahili
10
+ - low-resource-languages
11
+ - african-languages
12
+ - extractive-qa
13
+ - reading-comprehension
14
+ pretty_name: KenSwQuAD
15
+ size_categories:
16
+ - 1K<n<10K
17
+ ---
18
+
19
+ # KenSwQuAD: A Question Answering Dataset for Swahili
20
+
21
+ ## Dataset Description
22
+
23
+ **KenSwQuAD** (Kenyan Swahili Question Answering Dataset) is a reading comprehension and question answering dataset for **Swahili**, a low-resource African language. The dataset contains **7,506 question-answer pairs** derived from **1,441 unique Swahili contexts** covering diverse topics including agriculture, education, technology, governance, and daily life in Kenya.
24
+
25
+ This dataset is designed for training and evaluating extractive question answering models on Swahili text.
26
+
27
+ ## Dataset Statistics
28
+
29
+ | Metric | Count |
30
+ |--------|-------|
31
+ | Total QA Pairs | 7,506 |
32
+ | Unique Contexts | 1,441 |
33
+ | Avg QA Pairs per Context | 5.21 |
34
+ | Avg Question Length | 41 characters |
35
+ | Avg Answer Length | 14 characters |
36
+ | Avg Context Length | 2,702 characters |
37
+
38
+ ## Dataset Format
39
+
40
+ The dataset is distributed as **Parquet files** for optimal performance and compatibility:
41
+
42
+ - **Format**: Apache Parquet (columnar storage)
43
+ - **Encoding**: UTF-8
44
+ - **Compatibility**: Works with `datasets` 4.0.0+ without custom loading scripts
45
+
46
+ ---
47
+
48
+ ## Data Fields
49
+
50
+ Each record in the dataset contains:
51
+
52
+ - **id**: `string` - Unique identifier for the QA pair (format: `{story_id}_{qa_index}`)
53
+ - **story_id**: `string` - Identifier for the source context/story (e.g., `3830_swa`)
54
+ - **context**: `string` - The passage/story from which questions are derived
55
+ - **question**: `string` - The question in Swahili
56
+ - **answer**: `string` - The answer text
57
+ - **paragraph_id**: `string` - Optional paragraph/position indicator
58
+
59
+ ### Example Record
60
+
61
+ ```python
62
+ {
63
+ 'id': '3830_swa_0',
64
+ 'story_id': '3830_swa',
65
+ 'context': 'MANUFAA YA KILIMO KATIKA UIMARISHAJI WA UCHUMI WA KENYA Kilimo katika nchi yetu ya Kenya ni muhimu...',
66
+ 'question': 'Ni katika nchi ipi kilimo ni muhimu',
67
+ 'answer': 'Kenya',
68
+ 'paragraph_id': 'x'
69
+ }
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Usage
75
+
76
+ ### Loading with 🤗 Datasets
77
+
78
+ **Compatible with datasets 4.0.0+** (No `trust_remote_code` needed!)
79
+
80
+ ```python
81
+ from datasets import load_dataset
82
+
83
+ # Load the dataset
84
+ dataset = load_dataset("Kencorpus/KenSwQuAD")
85
+
86
+ # Access the training split
87
+ train = dataset['train']
88
+
89
+ # View first example
90
+ print(train[0])
91
+ ```
92
+
93
+ ### Example: Training a QA Model
94
+
95
+ ```python
96
+ from datasets import load_dataset
97
+ from transformers import AutoTokenizer, AutoModelForQuestionAnswering, TrainingArguments, Trainer
98
+
99
+ # Load dataset
100
+ dataset = load_dataset("Kencorpus/KenSwQuAD")
101
+
102
+ # Load a multilingual model (supports Swahili)
103
+ model_name = "xlm-roberta-base"
104
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
105
+ model = AutoModelForQuestionAnswering.from_pretrained(model_name)
106
+
107
+ # Tokenize function
108
+ def tokenize_function(examples):
109
+ return tokenizer(
110
+ examples['question'],
111
+ examples['context'],
112
+ truncation=True,
113
+ padding='max_length',
114
+ max_length=384
115
+ )
116
+
117
+ # Tokenize dataset
118
+ tokenized_dataset = dataset.map(tokenize_function, batched=True)
119
+
120
+ # Train model (example)
121
+ training_args = TrainingArguments(
122
+ output_dir="./kenswquad-model",
123
+ evaluation_strategy="epoch",
124
+ learning_rate=2e-5,
125
+ per_device_train_batch_size=16,
126
+ num_train_epochs=3,
127
+ )
128
+
129
+ trainer = Trainer(
130
+ model=model,
131
+ args=training_args,
132
+ train_dataset=tokenized_dataset['train'],
133
+ )
134
+
135
+ trainer.train()
136
+ ```
137
+
138
+ ### Example: Exploring the Data
139
+
140
+ ```python
141
+ from datasets import load_dataset
142
+ import pandas as pd
143
+
144
+ # Load dataset
145
+ dataset = load_dataset("Kencorpus/KenSwQuAD")
146
+ df = pd.DataFrame(dataset['train'])
147
+
148
+ # Count QA pairs per story
149
+ qa_per_story = df.groupby('story_id').size().describe()
150
+ print("QA pairs per story distribution:")
151
+ print(qa_per_story)
152
+
153
+ # View sample context
154
+ sample = df[df['story_id'] == '3830_swa'].iloc[0]
155
+ print(f"\nContext: {sample['context'][:200]}...")
156
+ print(f"\nQuestion: {sample['question']}")
157
+ print(f"Answer: {sample['answer']}")
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Dataset Topics
163
+
164
+ The contexts cover a wide variety of topics relevant to Kenyan society:
165
+
166
+ - 🌾 **Agriculture & Farming** - Crop cultivation, livestock, economic impact
167
+ - 🏫 **Education** - Schools, technology in education, student life
168
+ - 💻 **Technology** - Digital tools, internet, communication
169
+ - 🏛️ **Governance & Politics** - Leadership, government policies, elections
170
+ - 💰 **Economy & Business** - Trade, employment, economic development
171
+ - 🏥 **Health** - COVID-19, medical services, public health
172
+ - 🌍 **Society & Culture** - Daily life, traditions, social issues
173
+
174
+ ---
175
+
176
+ ## Data Collection
177
+
178
+ The dataset was created by:
179
+ 1. Collecting Swahili texts from various sources (articles, social media, essays)
180
+ 2. Manual annotation of question-answer pairs by native Swahili speakers
181
+ 3. Quality control and validation
182
+
183
+ **Source Contexts:**
184
+ - 2,585 texts from general sources (`collected_data_text_swa_final_2585_out_of_2585`)
185
+ - 324 texts from Twitter/social media (`collected_data_text_swa_tweets_324_out_of_324`)
186
+
187
+ ---
188
+
189
+ ## Intended Uses
190
+
191
+ ### Primary Uses
192
+ - Training extractive question answering models for Swahili
193
+ - Evaluating reading comprehension capabilities
194
+ - Transfer learning for low-resource African languages
195
+ - Multilingual model evaluation
196
+
197
+ ### Out-of-Scope Uses
198
+ - Generative question answering (dataset is designed for extractive QA)
199
+ - Tasks requiring answers not present in the context
200
+ - Languages other than Swahili
201
+
202
+ ---
203
+
204
+ ## Limitations
205
+
206
+ - **Extractive nature**: Answers are expected to be spans within the context
207
+ - **Domain coverage**: While diverse, may not cover all Swahili domains
208
+ - **Answer length**: Most answers are short (avg. 14 characters)
209
+ - **Regional variation**: Primarily Kenyan Swahili, may not represent all Swahili dialects
210
+
211
+ ---
212
+
213
+ ## Dataset Curators
214
+
215
+ - **Barack Wanjawa** (University of Nairobi)
216
+ - **Lilian D.A. Wanzare** (Maseno University)
217
+ - **Florence Indede** (Maseno University)
218
+ - **Owen McOnyango** (Maseno University)
219
+ - **Lawrence Muchemi** (University of Nairobi)
220
+ - **Edward Ombui** (Africa Nazarene University)
221
+
222
+ ---
223
+
224
+ ## Citation
225
+
226
+ If you use this dataset in your research, please cite:
227
+
228
+ ```bibtex
229
+ @article{wanjawa2022kencorpus,
230
+ title={Kencorpus: A Kenyan Language Corpus of Swahili, Dholuo and Luhya for Natural Language Processing Tasks},
231
+ author={Wanjawa, Barack W. and Wanzare, Lilian D. and Indede, Florence and McOnyango, Owen and Ombui, Edward and Muchemi, Lawrence},
232
+ journal={arXiv preprint arXiv:2208.12081},
233
+ year={2022}
234
+ }
235
+ ```
236
+
237
+ ---
238
+
239
+ ## Links
240
+
241
+ - **Research Paper**: https://arxiv.org/abs/2208.12081
242
+ - **Dataverse**: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/OTL0LM
243
+ - **ResearchGate**: https://www.researchgate.net/publication/371767223
244
+ - **Semantic Scholar**: https://www.semanticscholar.org/paper/8cf70c5cd8b195ed7a399ea2cdc0b0e8f08c61ce
245
+
246
+ ---
247
+
248
+ ## License
249
+
250
+ This dataset is licensed under **CC-BY-4.0**.
251
+
252
+ ---
253
+
254
+ ## Acknowledgments
255
+
256
+ This dataset is part of the **Kencorpus** project, which aims to create NLP resources for low-resource Kenyan languages. We thank all annotators and contributors who made this dataset possible.