File size: 2,911 Bytes
c57b6a4 10c6f41 cd561fd 4817c73 cd561fd 42e3042 cd561fd 10c6f41 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
---
license: apache-2.0
datasets:
- Alfaxad/Inkuba-Mono-Swahili
language:
- sw
pipeline_tag: text-generation
library_name: transformers
tags:
- gemma2
- text-2-text
- text-generation
- llms
base_model:
- google/gemma-2-2b
---
# Gemma2-2B-Swahili-Preview
Gemma2-2B-Swahili-Preview is a Swahili variation of the base language model Gemma2 2B fine-tuned on the Inkuba-Mono Swahili dataset, designed to enhance Swahili language understanding through monolingual training.
## Model Details
- **Developer:** Alfaxad Eyembe
- **Base Model:** google/gemma-2-2b
- **Model Type:** Decoder-only transformer
- **Language:** Swahili
- **License:** Apache 2.0
- **Fine-tuning Approach:** Low-Rank Adaptation (LoRA)
## Training Data
The model was fine-tuned on a focused subset of the Inkuba-Mono dataset:
- 1,000,000 randomly selected examples
- Total tokens: 60,831,073
- Average text length: 101.33 characters
- Diverse Swahili text sources including news, social media, and various domains
## Training Details
- **Fine-tuning Method:** LoRA
- **Training Steps:** 2,500
- **Batch Size:** 2
- **Gradient Accumulation Steps:** 32
- **Learning Rate:** 2e-4
- **Training Time:** ~7.5 hours

## Model Capabilities
This model is designed for:
- Swahili text continuation
- Natural language understanding
- Contextual text generation
- Base language modeling for Swahili
## Usage
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("alfaxadeyembe/gemma2-2b-swahili-preview")
model = AutoModelForCausalLM.from_pretrained(
"alfaxadeyembe/gemma2-2b-swahili-preview",
device_map="auto",
torch_dtype=torch.bfloat16
)
# Set to evaluation mode
model.eval()
# Example usage
prompt = "Katika soko la Kariakoo, teknolojia mpya imewezesha"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=500,
do_sample=True,
temperature=0.7,
top_p=0.95
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
```
## Key Features
- Natural Swahili text continuation
- Strong cultural context understanding
- Efficient parameter updates through LoRA
- Diverse domain knowledge integration
## Limitations
- Not instruction-tuned
- Base language modeling capabilities
- Performance varies across different text domains
## Citation
```bibtex
@misc{gemma2-2b-swahili-preview,
author = {Alfaxad Eyembe},
title = {Gemma2-2B-Swahili-Preview: Swahili Variation of Gemma2 2B},
year = {2025},
publisher = {Hugging Face},
journal = {Hugging Face Model Hub},
}
```
## Contact
For questions or feedback, please reach out through:
- HuggingFace: [@alfaxadeyembe](https://huggingface.co/alfaxad)
- X : [@alfxad](https://twitter.com/alfxad) |