Downloads · 30 days
22
7% of all-time downloads
AlexLeoTz/zuhura-289m-base
zuhura-289m-base is a machine learning model from AlexLeoTz. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Zuhura 289M is a Swahili-centric language model based on the Llama architecture, pre-trained from scratch on a massive corpus of Swahili text.
Downloads · 30 days
22
7% of all-time downloads
All-time downloads
323
Public
Parameters
289M
1.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors578 MB · 100%
From the Hugging Face model README
Zuhura 289M is a Swahili-centric language model based on the Llama architecture, pre-trained from scratch on a massive corpus of Swahili text.
Live Preview: Test the model here
AlexLeoTz/swahili_large_corpus_i (~5 Billion tokens total)Despite being a fraction of the size, Zuhura 289M fundamentally outperforms Google's Gemma 2B (a 2-billion parameter foundational model) in native Swahili fluency and cultural alignment, proving the immense value of native tokenization and localized pre-training.
Below is a direct, zero-shot continuation comparison between both base models:
Prompt: "Katika mji wa Dar es Salaam, watu"
Prompt: "Tanzania ni nchi nzuri sana ambayo"
Prompt: "Lugha ya Kiswahili inakua kwa kasi kwa sababu"
One of the core strengths of Zuhura 289M is its custom Byte-Level BPE Tokenizer, trained on 5 billion tokens total.
Standard LLM tokenizers (like GPT-2 or Llama-3) are trained primarily on English text and treat Swahili as a "low-resource" language, often fragmenting a single Swahili word into 3-5 meaningless sub-units. This "Fragmentation Inflation" leads to:
| Metric | Standard Tokenizer | Zuhura Tokenizer | Improvement |
|---|---|---|---|
| Tokens Per Word (Swahili) | ~2.5 | 1.13 | 2.21x denser |
| Effective Context (Words) | ~819 words | ~1,812 words | +121% capacity |
Context Equivalence: A 2,048 context window in Zuhura is functionally equivalent to a 4,096 context window of a standard GPT-based model when processing Swahili text.
By using Zuhura, the model effectively doubles its memory for Swahili text without increasing the parameter count. Despite its Swahili-first focus, it maintains ~90% efficiency on English text, making it highly capable in code-switching environments (Swahinglish).
Although Zuhura is rigorously optimized for Swahili, the 20% English code/text mix in its pre-training corpus provides it with surprisingly robust English capabilities. When tested against Google's Gemma 2B (an English-first model 8x larger), Zuhura 289M demonstrated perfect English grammar, creative storytelling, and extreme readiness for "Swahinglish" code-switching.
Below is a direct, zero-shot continuation comparison between both base models on English prompts:
Prompt: "Machine learning is a field of computer science that"
Prompt: "The capital of France is Paris, which is famous for"
Prompt: "The quick brown fox jumps over the lazy"
Zuhura 289M was trained on 5 billion tokens, following the Chinchilla scaling laws for its parameter count. While this makes it highly efficient, it is important to note that this is a significantly smaller scale than massive English-centric or Chinese-centric models which are often trained on trillions of tokens of high-quality web data.
Key Observations:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "AlexLeoTz/zuhura-289m-base"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
prompt = "Mheshimiwa rais wa"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0]))
"""
Jamhuri ya Muungano wa Tanzania, Dkt. John Pombe Magufuli, leo tarehe 23 Machi, 2017 amepokea taarifa ya uchunguzi wa mchanga wa madini uliotakiwa kusafirishwa nje ya nchi kutoka kwenye machimbo ya dhahabu ya Mirerani wilayani Simanjiro Mkoani Manyara na baadaye kuhamishiwa katika migodi mingine nchini."
"""
During training, several optimizations were applied: