Files changed (1) hide show
  1. README.md +220 -20
README.md CHANGED
@@ -4,57 +4,233 @@ base_model: Jacaranda/AfroLlama_V1
4
  tags:
5
  - base_model:adapter:Jacaranda/AfroLlama_V1
6
  - lora
 
 
7
  - transformers
 
 
8
  pipeline_tag: text-generation
9
  model-index:
10
  - name: Caracal_AfroLlama_int4
11
- results: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
15
- should probably proofread and complete it, then remove this comment. -->
16
 
17
  # Caracal_AfroLlama_int4
18
 
19
- This model is a fine-tuned version of [Jacaranda/AfroLlama_V1](https://huggingface.co/Jacaranda/AfroLlama_V1) on an unknown dataset.
20
- It achieves the following results on the evaluation set:
21
- - Loss: 1.8681
22
 
23
- ## Model description
24
 
25
- More information needed
26
 
27
- ## Intended uses & limitations
 
 
 
 
 
 
 
28
 
29
- More information needed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- ## Training and evaluation data
 
 
 
 
32
 
33
- More information needed
34
 
35
- ## Training procedure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  ### Training hyperparameters
38
 
39
- The following hyperparameters were used during training:
 
40
  - learning_rate: 2e-05
41
  - train_batch_size: 16
42
  - eval_batch_size: 16
43
  - seed: 42
44
  - gradient_accumulation_steps: 2
45
  - total_train_batch_size: 32
46
- - optimizer: Use paged_adamw_8bit with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
47
  - lr_scheduler_type: cosine
48
  - lr_scheduler_warmup_steps: 0.03
49
  - num_epochs: 2
50
 
51
  ### Training results
52
 
53
- | Training Loss | Epoch | Step | Validation Loss |
54
- |:-------------:|:-----:|:-----:|:---------------:|
55
- | 1.8109 | 1.0 | 17746 | 1.9012 |
56
- | 1.7053 | 2.0 | 35492 | 1.8681 |
 
 
57
 
 
58
 
59
  ### Framework versions
60
 
@@ -62,4 +238,28 @@ The following hyperparameters were used during training:
62
  - Transformers 5.5.1
63
  - Pytorch 2.12.0+cu126
64
  - Datasets 4.8.5
65
- - Tokenizers 0.22.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  tags:
5
  - base_model:adapter:Jacaranda/AfroLlama_V1
6
  - lora
7
+ - qlora
8
+ - int4
9
  - transformers
10
+ - africa
11
+ - low-resource
12
  pipeline_tag: text-generation
13
  model-index:
14
  - name: Caracal_AfroLlama_int4
15
+ results:
16
+ - task:
17
+ type: text-generation
18
+ name: AfriXNLI (Natural Language Inference)
19
+ dataset:
20
+ name: IrokoBench AfriXNLI
21
+ type: irokobench/afrixnli
22
+ metrics:
23
+ - type: accuracy
24
+ value: 34.01
25
+ name: Accuracy
26
+ license: apache-2.0
27
+ language:
28
+ - amh
29
+ - tir
30
+ - ada
31
+ - kln
32
+ - dav
33
+ - orm
34
+ - fra
35
+ - lin
36
+ - kin
37
+ - kam
38
+ - luy
39
+ - gpe
40
+ - pcm
41
+ - som
42
+ - ibo
43
+ - luo
44
+ - kik
45
+ - lug
46
+ - en
47
+ - eng
48
+ - yor
49
+ - hau
50
+ - swa
51
+ - xho
52
  ---
53
 
54
+ <!-- This model card has been generated according to the AfriLLMQuant pilot project telemetry report.
55
+ You should probably proofread and complete it, then remove this comment. -->
56
 
57
  # Caracal_AfroLlama_int4
58
 
59
+ ## Model Description
 
 
60
 
61
+ **Caracal_AfroLlama_int4** is an INT4-quantized, instruction-following variant of [Jacaranda/AfroLlama_V1](https://huggingface.co/Jacaranda/AfroLlama_V1), produced as part of the **AfriLLMQuant** pilot project (OpenToken / Carnegie Mellon University, Africa). It was adapted via **continued pre-training (CPT)** on African-language text, then **instruction-tuned** on the MURI dataset, then compressed to 4-bit precision using **parameter-efficient fine-tuning (PEFT) via QLoRA** — training low-rank adapters rather than the full model.
62
 
63
+ The goal of the project was to make instruction-following African-language models deployable on resource-constrained hardware, rather than requiring non-consumer-grade GPUs.
64
 
65
+ | | |
66
+ |---|---|
67
+ | **Base model** | Jacaranda/AfroLlama_V1 |
68
+ | **Adapter method** | LoRA / QLoRA (PEFT) |
69
+ | **Quantization** | INT4 |
70
+ | **Memory footprint** | ~16 GB (FP) → **~5 GB** (INT4) |
71
+ | **Quantization training time** | ~4 days on 1x NVIDIA A100 80GB |
72
+ | **License** | Apache 2.0 |
73
 
74
+ ---
75
+
76
+ ## Supported Languages
77
+
78
+ The model covers languages drawn from the CPT and instruction-tuning corpora, with a primary focus on **East Africa** and broader Sub-Saharan African coverage. Perplexity (PPL) figures below are from multi-domain CPT evaluation; lower is better, and a PPL under 100 is generally considered functional for a low-resource language.
79
+
80
+ ### Strong performance (PPL < 20)
81
+
82
+ | Language | ISO | Avg PPL | Samples |
83
+ |---|---|---:|---:|
84
+ | Amharic | `amh` | 1.98 | 1,000 |
85
+ | Tigrinya | `tir` | 1.99 | 1,000 |
86
+ | Adangme | `ada` | 2.75 | 1,000 |
87
+ | Kalenjin | `kln` | 2.84 | 1,000 |
88
+ | Dawida | `dav` | 3.02 | 1,000 |
89
+ | Code-switched | — | 4.47 | 288 |
90
+ | English (Kenyan Agri. domain) | `en` | 5.44 | 300 |
91
+ | Wakhal transcriptions | — | 5.96 | 1,000 |
92
+
93
+ ### Moderate performance (PPL 20–250)
94
+
95
+ | Language | ISO | Avg PPL | Samples |
96
+ |---|---|---:|---:|
97
+ | Oromo | `orm` | 9.82 | 945 |
98
+ | French | `fra` | 10.97 | 1,000 |
99
+ | Lingala | `lin` | 10.97 | 545 |
100
+ | KenSQuAD domain | — | 11.23 | 1,000 |
101
+ | Kinyarwanda | `kin` | 12.14 | 1,000 |
102
+ | Kamba | `kam` | 12.54 | 132 |
103
+ | Luhya | `luy` | 13.34 | 153 |
104
+ | Nigerian Pidgin (gpe) | `gpe` | 17.79 | 1,000 |
105
+ | Nigerian Pidgin (pcm) | `pcm` | 22.19 | 568 |
106
+ | Somali | `som` | 24.46 | 1,000 |
107
+ | Igbo | `ibo` | 39.63 | 1,000 |
108
+ | Luo (Dholuo) | `luo` | 47.08 | 1,000 |
109
+ | Kikuyu (Gĩkũyũ) | `kik` | 59.26 | 1,000 |
110
+ | Luganda | `lug` | 97.74 | 1,000 |
111
+ | English (general) | `en`/`eng` | 118.29 / 136.52 | 1,000 / 1,000 |
112
+ | Yoruba | `yor` | 178.19 | 1,000 |
113
+ | Hausa | `hau` | 205.84 | 1,000 |
114
+
115
+ ### Weaker performance (PPL > 250)
116
+
117
+ | Language | ISO | Avg PPL | Samples |
118
+ |---|---|---:|---:|
119
+ | Swahili | `swa` | 272.91 | 1,000 |
120
+ | Xhosa | `xho` | 457.27 | 1,000 |
121
+ | Acholi | `ach` | 1,619.32 | 1,000 |
122
+ | Shona | `sna` | 2,079.58 | 1,000 |
123
+ | Zulu | `zul` | 2,564.68 | 1,000 |
124
+
125
+ > **Note:** The project report attributes the high-perplexity languages (Acholi, Shona, Zulu) to limited training-data coverage rather than a fundamental modeling limitation, and recommends targeted corpus expansion for these languages in future work. Treat this as a stated hypothesis rather than a verified result — it has not been independently confirmed by additional experiments.
126
+
127
+ ---
128
+
129
+ ## Training Data
130
+
131
+ - **Continued Pre-training (CPT) corpus:** ~0.5B tokens after filtering (from a larger ~1.2B token raw collection), capped at 5M tokens per language. Sources included open-license web data, Wikipedia, and Bible translations for Somali, Dholuo/Luo, Luhya, Gikuyu, Acholi, Luganda, Kamba, Gusii, Kinyarwanda, and Kalenjin, alongside other African and cross-lingual corpora.
132
+ - **Instruction-tuning dataset:** ~60,000 examples from the [MURI dataset](https://arxiv.org/abs/2409.12958) (Apache 2.0 licensed), focused on low-resource language instruction-following with emphasis on Sub-Saharan African languages.
133
+ - **PII and toxicity:** Source data was reviewed to remove personally identifiable information and screened for toxic content prior to training.
134
+
135
+ ### Quantization / Adapter Training
136
+
137
+ Caracal_AfroLlama_int4 used **PEFT via QLoRA** to fine-tune and quantize AfroLlama_V1 to INT4 over a 4-day training run — distinct from the full Quantization-Aware Training (QAT) used for the sibling Caracal-instruct model.
138
+
139
+ ---
140
+
141
+ ## Evaluation
142
+
143
+ | Benchmark | Metric | Score |
144
+ |---|---|---:|
145
+ | AfriXNLI (IrokoBench) | Accuracy | **34.01%** |
146
+
147
+ AfriXNLI is a 3-way natural language inference benchmark for African languages. The reported score is close to the ~33% random-baseline rate for 3-way classification, so this result should be treated as a preliminary signal rather than strong evidence of NLI capability, pending further evaluation.
148
+
149
+ ---
150
+
151
+ ## Usage
152
+
153
+ ```python
154
+ from peft import PeftModel
155
+ from transformers import AutoModelForCausalLM, AutoTokenizer
156
+
157
+ base_model_id = "Jacaranda/AfroLlama_V1"
158
+ adapter_id = "amidblue/Caracal_AfroLlama_int4" # update with actual repo path
159
+
160
+ tokenizer = AutoTokenizer.from_pretrained(base_model_id)
161
+ base_model = AutoModelForCausalLM.from_pretrained(base_model_id, load_in_4bit=True, device_map="auto")
162
+ model = PeftModel.from_pretrained(base_model, adapter_id)
163
 
164
+ prompt = "<s><Input>\nWho is the president of Kenya?\n</Input>\n<Answer>\n"
165
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
166
+ output = model.generate(**inputs, max_new_tokens=64)
167
+ print(tokenizer.decode(output[0], skip_special_tokens=True))
168
+ ```
169
 
170
+ ### Expected input/output format
171
 
172
+ The model expects the `<Input>...</Input>` / `<Answer>...</Answer>` instruction format used during SFT, e.g.:
173
+
174
+ ```
175
+ <s> <Input>
176
+ Asha ana kalamu 7 mwanzoni. Kisha ananunua pakiti 3 za kalamu, ambapo kila pakiti ina kalamu 4. Baadaye, anampatia rafiki yake kalamu 5. Asha anabaki na kalamu ngapi?
177
+ </Input>
178
+ <Answer>
179
+ $$\boxed{14}$$ </Answer>
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Known Limitations
185
+
186
+ Manual spot-checks during the pilot surfaced several recurring failure modes that should be kept in mind before relying on this model:
187
+
188
+ - **Factual unreliability on current events and named entities.** The model can produce confident, fluent, but incorrect answers about real-world facts such as current political office-holders — including conflating different countries, leaders, and historical periods in the same answer. It performed correctly on some queries (e.g., correctly identifying Kenya's president) but not others, so accuracy is inconsistent rather than uniformly wrong.
189
+ - **Fabricated entities.** In some cases the model generates plausible-sounding but nonexistent names or institutions, rather than indicating uncertainty.
190
+ - **Topic drift in free-form generation.** On open-ended Swahili prompts, the model sometimes continues into unrelated tangents and run-on text not requested in the prompt.
191
+ - **Unreliable on health/medical content.** Responses to health-related prompts (e.g., explaining medical conditions) can include inaccurate or fabricated claims stated with unwarranted confidence. **This model should not be used as a source of medical information.**
192
+ - **Inconsistent performance on structured/multiple-choice reasoning.** On simple causal-reasoning (COPA-style) tasks the model can answer correctly, but on basic multiple-choice tasks (e.g., selecting which listed number is even) it has been observed to select an incorrect option while still producing a well-formatted answer — indicating the failure is in reasoning, not output formatting.
193
+ - **High perplexity for several Bantu and Nilotic languages** (notably Acholi, Shona, and Zulu), reflecting limited representation in the training corpus relative to other supported languages.
194
+
195
+ Given these patterns, outputs — especially factual claims, named entities, and anything health- or safety-related — should be independently verified before use in any downstream application.
196
+
197
+ ---
198
+
199
+ ## Intended Uses & Limitations
200
+
201
+ **Intended for:** research into low-resource African-language modeling, lightweight on-device deployment experiments, and as a base for further fine-tuning on downstream African-language tasks.
202
+
203
+ **Not intended for:** medical, legal, financial, or other high-stakes advice; uses requiring reliable factual/current-events accuracy; production deployment without further evaluation and safety review.
204
+
205
+ ---
206
+
207
+ ## Training Procedure
208
 
209
  ### Training hyperparameters
210
 
211
+ The following hyperparameters were used during adapter training:
212
+
213
  - learning_rate: 2e-05
214
  - train_batch_size: 16
215
  - eval_batch_size: 16
216
  - seed: 42
217
  - gradient_accumulation_steps: 2
218
  - total_train_batch_size: 32
219
+ - optimizer: paged_adamw_8bit (betas=(0.9, 0.999), epsilon=1e-08)
220
  - lr_scheduler_type: cosine
221
  - lr_scheduler_warmup_steps: 0.03
222
  - num_epochs: 2
223
 
224
  ### Training results
225
 
226
+ | Training Loss | Epoch | Step | Validation Loss |
227
+ |:---:|:---:|:---:|:---:|
228
+ | 1.8109 | 1.0 | 17,746 | 1.9012 |
229
+ | 1.7053 | 2.0 | 35,492 | 1.8681 |
230
+
231
+ ### Compute
232
 
233
+ Trained on a single dedicated **NVIDIA A100 80GB SXM** instance (LeafCloud, Netherlands), provided under an attribution/SAAC Tier-1 free allocation as part of a 3-week OpenToken grant period (May 2026). Estimated equivalent commercial cost: ~$1,260 (504 hrs × $2.50/hr at hyperscaler rates).
234
 
235
  ### Framework versions
236
 
 
238
  - Transformers 5.5.1
239
  - Pytorch 2.12.0+cu126
240
  - Datasets 4.8.5
241
+ - Tokenizers 0.22.2
242
+
243
+ ---
244
+
245
+ ## Citation
246
+
247
+ ```bibtex
248
+ @misc{caracal-afrollama-int4,
249
+ author = {Theophilus Lincoln Owiti},
250
+ title = {Caracal\_AfroLlama\_int4: INT4-Quantized Instruction-Following AfroLlama for African Languages},
251
+ year = {2026},
252
+ publisher = {Hugging Face},
253
+ note = {Carnegie Mellon University, Africa / AfriLLMQuant},
254
+ url = {https://huggingface.co/amidblue/Caracal_AfroLlama_int4}
255
+ }
256
+ ```
257
+
258
+ **Authors:**
259
+ - **Theophilus Lincoln Owiti** — Carnegie Mellon University, Africa
260
+
261
+ ---
262
+
263
+ ## Model Card Authors
264
+
265
+ Theophilus Lincoln Owiti