gemma-3-1b-translate-sft-best
English to African Languages Translator
2 min read
This model is a specialized version of Google Gemma 3 with approximately one billion parameters, fine-tuned using SFT (supervised fine-tuning) methods to translate text from English into 125 African languages. It takes an English sentence or short paragraph as input and outputs the translation with the corresponding language tag. The model serves as an excellent starting point for further fine-tuning or generation customization. To achieve stable results, using a token frequency penalty (frequency_penalty) is recommended.
Key features
- Support for 125 language tags for African dialects and languages
- Built on the compact and efficient Google Gemma 3-1B-it architecture
- Designed for translating individual sentences or small paragraphs
- Serves as a base checkpoint for further reinforcement learning (RL)
What you can do
- Integrate the model into a chatbot for translating texts into rare languages
- Use the checkpoint as a foundation for your own language experiments and RL fine-tuning
- Translate short documents by splitting them into individual sentences first
Example
import re, torch
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "BeardedMonster/gemma-3-1b-translate-sft-best"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.bfloat16).cuda().eval()
def translate(text, language, max_new_tokens=256):
msgs = [{"role": "user", "content": f"Translate the text to {language}: {text}"}]
enc = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt", return_dict=True).to("cuda")
with torch.no_grad():
out = model.generate(**enc, max_new_tokens=max_new_tokens, do_sample=False)
raw = tok.decode(out[0, enc["input_ids"].shape[1]:], skip_special_tokens=True)
return re.sub(r"^<[a-z]{3}>\s*", "", raw.strip())
print(translate("Good morning, how are you?", "Yoruba"))Read more
DetailschrF++ metric: 25.66 (greedy decoding) and 29.11 (with frequency_penalty=0.1)
Model size: about 1.0B parameters (bfloat16 support required)
Limitations: for stable generation without looping, frequency_penalty=0.1 is recommended in vLLM










Comments