Alfaxad/Inkuba-Mono-Swahili
Viewer • Updated • 44.3M • 62
How to use Alfaxad/gemma2-2b-swahili-preview with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Alfaxad/gemma2-2b-swahili-preview") # Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM
tokenizer = AutoTokenizer.from_pretrained("Alfaxad/gemma2-2b-swahili-preview")
model = AutoModelForMultimodalLM.from_pretrained("Alfaxad/gemma2-2b-swahili-preview")How to use Alfaxad/gemma2-2b-swahili-preview with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Alfaxad/gemma2-2b-swahili-preview"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Alfaxad/gemma2-2b-swahili-preview",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/Alfaxad/gemma2-2b-swahili-preview
How to use Alfaxad/gemma2-2b-swahili-preview with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Alfaxad/gemma2-2b-swahili-preview" \
--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": "Alfaxad/gemma2-2b-swahili-preview",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "Alfaxad/gemma2-2b-swahili-preview" \
--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": "Alfaxad/gemma2-2b-swahili-preview",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use Alfaxad/gemma2-2b-swahili-preview with Docker Model Runner:
docker model run hf.co/Alfaxad/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.
The model was fine-tuned on a focused subset of the Inkuba-Mono dataset:
This model is designed for:
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)
@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},
}
For questions or feedback, please reach out through: