Instructions to use theophilusowiti/Caracal_AfroLlama_int4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use theophilusowiti/Caracal_AfroLlama_int4 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Jacaranda/AfroLlama_V1") model = PeftModel.from_pretrained(base_model, "theophilusowiti/Caracal_AfroLlama_int4") - Transformers
How to use theophilusowiti/Caracal_AfroLlama_int4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="theophilusowiti/Caracal_AfroLlama_int4")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("theophilusowiti/Caracal_AfroLlama_int4", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use theophilusowiti/Caracal_AfroLlama_int4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "theophilusowiti/Caracal_AfroLlama_int4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "theophilusowiti/Caracal_AfroLlama_int4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/theophilusowiti/Caracal_AfroLlama_int4
- SGLang
How to use theophilusowiti/Caracal_AfroLlama_int4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "theophilusowiti/Caracal_AfroLlama_int4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "theophilusowiti/Caracal_AfroLlama_int4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "theophilusowiti/Caracal_AfroLlama_int4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "theophilusowiti/Caracal_AfroLlama_int4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use theophilusowiti/Caracal_AfroLlama_int4 with Docker Model Runner:
docker model run hf.co/theophilusowiti/Caracal_AfroLlama_int4
model description
#3
by Papizo - opened
README.md
CHANGED
|
@@ -5,10 +5,15 @@ 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
|
|
@@ -16,29 +21,68 @@ 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
|
| 20 |
It achieves the following results on the evaluation set:
|
| 21 |
- Loss: 1.8681
|
|
|
|
| 22 |
|
| 23 |
## Model description
|
| 24 |
|
| 25 |
-
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
## Intended uses & limitations
|
| 28 |
|
| 29 |
-
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
##
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
|
|
|
|
| 39 |
|
|
|
|
|
|
|
| 40 |
|
|
|
|
| 41 |
|
|
|
|
| 42 |
|
| 43 |
The following hyperparameters were used during training:
|
| 44 |
- learning_rate: 2e-05
|
|
@@ -52,6 +96,16 @@ The following hyperparameters were used during training:
|
|
| 52 |
- lr_scheduler_warmup_steps: 0.03
|
| 53 |
- num_epochs: 2
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
### Training results
|
| 56 |
|
| 57 |
| Training Loss | Epoch | Step | Validation Loss |
|
|
|
|
| 5 |
- base_model:adapter:Jacaranda/AfroLlama_V1
|
| 6 |
- lora
|
| 7 |
- transformers
|
| 8 |
+
- africa
|
| 9 |
+
- low-resource
|
| 10 |
+
- int4
|
| 11 |
+
- quantization
|
| 12 |
pipeline_tag: text-generation
|
| 13 |
model-index:
|
| 14 |
- name: Caracal_AfroLlama_int4
|
| 15 |
results: []
|
| 16 |
+
license: apache-2.0
|
| 17 |
---
|
| 18 |
|
| 19 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
|
|
|
| 21 |
|
| 22 |
# Caracal_AfroLlama_int4
|
| 23 |
|
| 24 |
+
This model is a fine-tuned, 4-bit quantized adapter version of [Jacaranda/AfroLlama_V1](https://huggingface.co/Jacaranda/AfroLlama_V1) on an instruction-tuning and downstream optimization dataset.
|
| 25 |
It achieves the following results on the evaluation set:
|
| 26 |
- Loss: 1.8681
|
| 27 |
+
- Over a 2-epoch training
|
| 28 |
|
| 29 |
## Model description
|
| 30 |
|
| 31 |
+
**Caracal_AfroLlama_int4** leverages Low-Rank Adaptation (LoRA) integrated with 4-bit precision quantization to yield a highly parameter-efficient model tailored for low-resource African languages. By building upon the robust multilingual foundations of `AfroLlama_V1`, this variant optimizes performance boundaries across diverse structural contexts while drastically reducing deployment memory constraints and hardware requirements.
|
| 32 |
|
| 33 |
+
[cite_start]During the AfriLLMQuant pilot, parameter-efficient fine-tuning (PEFT) via QLORA was leveraged over a four-day period to train and quantize this model to INT4 precision[cite: 347]. [cite_start]Notably, this quantization process successfully compressed the memory footprint for the AfroLlama architecture from 16 GB down to approximately 5 GB[cite: 366]. [cite_start]This significant reduction dramatically lowers hardware deployment barriers, enabling African-language AI to run on consumer-grade devices accessible in low-resource settings[cite: 302, 366].
|
| 34 |
+
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 39 |
+
|
| 40 |
+
model_id = "theophilusowiti/Caracal_AfroLlama_int4"
|
| 41 |
+
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 43 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
|
| 44 |
+
|
| 45 |
+
prompt = "<s><Input>\nAsha 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 ?\n</Input>\n<Answer>\n"
|
| 46 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 47 |
+
output = model.generate(**inputs, max_new_tokens=64)
|
| 48 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 49 |
+
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
### Expected output
|
| 53 |
+
|
| 54 |
+
The model expects the `<Input>...</Input>` / `<Answer>...</Answer>` instruction format used during SFT, e.g.:
|
| 55 |
+
|
| 56 |
+
```
|
| 57 |
+
<s><Input>
|
| 58 |
+
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 ?
|
| 59 |
+
</Input>
|
| 60 |
+
<Answer>
|
| 61 |
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
| 62 |
+
```
|
| 63 |
+
---
|
| 64 |
## Intended uses & limitations
|
| 65 |
|
| 66 |
+
### Intended Uses
|
| 67 |
+
Multilingual Instruction Following: Well-suited for zero-shot and few-shot task adaptation in primary African languages.
|
| 68 |
|
| 69 |
+
Downstream Fine-Tuning: Serves as a lightweight baseline for intent classification, sentiment parsing, and text generation.
|
| 70 |
|
| 71 |
+
Edge Deployment: Highly optimized for lower-tier GPU environments or edge devices requiring a minimal INT4 footprint.
|
| 72 |
|
| 73 |
+
### Limitations
|
| 74 |
+
Hallucination Vectors: Like its base model, it remains susceptible to generating inaccurate facts when prompted outside its core linguistic domain.
|
| 75 |
|
| 76 |
+
Code-Switching Variance: Performance may degrade gracefully but noticeably when parsing extreme conversational dialect mixing or localized slang not captured during training.
|
| 77 |
|
| 78 |
+
## Training and evaluation data
|
| 79 |
|
| 80 |
+
Training and Evaluation Data
|
| 81 |
+
The model was adapted using specialized multilingual instruction sets focusing heavily on regional representation. Training subsets prioritize structural semantic integrity across high-priority regional vernaculars across East, West, Central, and Southern Africa. Specifically, for instruction fine-tuning tasks, this model utilized the MURI dataset, which resulted in approximately 60,000 instruction-tuning examples.
|
| 82 |
|
| 83 |
+
## Training procedure
|
| 84 |
|
| 85 |
+
### Training hyperparameters
|
| 86 |
|
| 87 |
The following hyperparameters were used during training:
|
| 88 |
- learning_rate: 2e-05
|
|
|
|
| 96 |
- lr_scheduler_warmup_steps: 0.03
|
| 97 |
- num_epochs: 2
|
| 98 |
|
| 99 |
+
### Top Performing Languages
|
| 100 |
+
|
| 101 |
+
East Africa: Swahili (swa), Amharic (amh), Luganda (lug), Kinyarwanda (kin)
|
| 102 |
+
|
| 103 |
+
West Africa: Hausa (hau), Yoruba (yor), Igbo (ibo)
|
| 104 |
+
|
| 105 |
+
Central Africa: Lingala (lin)
|
| 106 |
+
|
| 107 |
+
Southern Africa: Xhosa (xho)
|
| 108 |
+
|
| 109 |
### Training results
|
| 110 |
|
| 111 |
| Training Loss | Epoch | Step | Validation Loss |
|