# Gemma 2 Swahili ๐
Gemma 2 Swahili is a comprehensive suite of language models specifically adapted for Swahili language understanding and generation. This project brings advanced AI capabilities to over 200M Swahili speakers through efficient adaptation of Google's Gemma 2 models.
## Models ๐
| Model | Parameters | Type | Memory | Links |
|-------|------------|------|---------|-------|
| Gemma2-2B-Swahili-Preview | 2B | Base | ~4GB | HF \| Kaggle |
| Gemma2-2B-Swahili-IT | 2B | Instruction-tuned | ~4GB | HF \| Kaggle |
| Gemma2-9B-Swahili-IT | 9B | Instruction-tuned | ~18GB | HF \| Kaggle |
| Gemma2-27B-Swahili-IT | 27B | Instruction-tuned | ~54GB | HF \| Kaggle |
## Features โจ
- Native Swahili language generation
- Advanced instruction following in Swahili
- Strong performance on academic and professional tasks
- Cultural context awareness for East African content
- Efficient deployment options across different scales
## Performance ๐
### Benchmark Results
| Model | MMLU (SW) | Sentiment | Translation |
|-------|-----------|-----------|-------------|
| 2B-IT | 34.17% (+19.17) | 66.50% (+17.50) | 0.3735 BLEU-1 |
| 9B-IT | 55.83% (+12.50) | 86.50% (+3.08) | 0.4709 BLEU-1 |
| 27B-IT | 54.17% (+34.17) | 88.50% (+1.00) | 0.4994 BLEU-1 |
## Quick Start ๐
### Installation
```bash
pip install transformers accelerate
```
### Basic Usage
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load model and tokenizer
model_path = "gemma2-swahili/gemma2-2b-swahili-it"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map="auto",
torch_dtype=torch.bfloat16
)
# Generate text
prompt = "Eleza umuhimu wa teknolojia ya kidijitali"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=500,
do_sample=True,
temperature=0.7,
top_p=0.95
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
### Using 4-bit Qua โฆ