Try it
▶ Open the Colab Demo Notebook
Supported Languages
Coverage varies considerably by language, roughly tracking the amount of training data available.
Translation & Speech Evaluation Covers:
Acholi, Afrikaans, Akan, Alur, Amharic, Bambara, Bari, Bemba, Berber, Chichewa, Dagaare, Dagbani, Dinka, Ewe, French, Fulani, Hausa, Igbo, Ik, Ikposo, Jopadhola, Kabyle, Kakwa, Kalenjin, Kanuri, Karamojong, Kikuyu, Kinyarwanda, Kirundi, Kumam, Kupsabiny, Kwamba, Lango, Lendu, Lingala, Lubwisi, Luganda, Lugbara, Lugungu, Lugwere, Luhya, Lumasaba, Lunyole, Luo, Lusoga, Ma'di, Malagasy, Ndebele, Nigerian Pidgin, Oromo, Pokot, Rukiga, Rukonjo, Runyankole, Runyoro, Ruruuli, Rutooro, Samia, Shona, Somali, Sotho, Swahili, Tswana, Wolof, Xhosa, Yoruba, and Zulu.
Note: A language's presence in this list means it was evaluated; it does not imply equal quality across all languages. See evaluation metrics below for details on performance.
Inference
Sunflower-Gemma4-E2B follows standard Transformers patterns, but expects specific prompt formats for translation and speech transcription. Like Qwen, the base model supports a reasoning phase, but we recommend setting enable_thinking=False for standard translation tasks.
Text Translation
Translation expects a fixed instruction template:
Translate from English to {language name}: {text}
messages = [
{"role": "system", "content": "You are Sunflower, a helpful assistant made by Sunbird AI who knows many African languages."},
{"role": "user", "content": "Translate from English to Luganda: Where is the nearest hospital?"}
]
Tip: Use do_sample=False (greedy decoding) and temperature=0 for translation tasks.
Audio Transcription
The model was trained with prompts that explicitly name the spoken language. Convert audio to a 16 kHz mono waveform and keep it to 30 seconds or less.
messages = [
{"role": "system", "content": "You are Sunflower, a helpful assistant made by Sunbird AI who knows many African languages."},
{
"role": "user",
"content": [
{"type": "audio", "audio": audio_array},
{"type": "text", "text": "Please transcribe this Luganda audio."},
],
},
]
vLLM (Text-Only Inference)
vLLM is highly recommended for fast deployments. Because this is a multimodal model, text-only vLLM setup requires disabling vision/audio inputs to save memory.
import os
os.environ["VLLM_ENABLE_V1_MULTIPROCESSING"] = "0"
from vllm import LLM, SamplingParams
from transformers import AutoProcessor
MODEL_ID = "Sunbird/Sunflower-Gemma4-E2B"
llm = LLM(
MODEL_ID,
dtype="bfloat16",
max_model_len=1024,
limit_mm_per_prompt={"image": 0, "audio": 0},
enforce_eager=True,
)
processor = AutoProcessor.from_pretrained(MODEL_ID)
def make_prompt(text, target_lang):
messages = [
{"role": "system", "content": "You are Sunflower, a helpful assistant made by Sunbird AI who knows many African languages."},
{"role": "user", "content": f"Translate from English to {target_lang}: {text}"}
]
return processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
sampling = SamplingParams(temperature=0.0, max_tokens=256)
examples = [
("Good morning, how are you?", "Luganda"),
("The children are going to school today.", "Acholi"),
("I would like to buy three kilograms of rice.", "Swahili"),
]
outputs = llm.generate([make_prompt(t, l) for t, l in examples], sampling)
for (text, lang), out in zip(examples, outputs):
print(f"[{lang}] {text}\n -> {out.outputs[0].text.strip()}\n")
import torch
import librosa
import numpy as np
from transformers import AutoModelForMultimodalLM, AutoProcessor
MODEL_ID = "Sunbird/Sunflower-Gemma4-E2B"
dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
processor = AutoProcessor.from_pretrained(MODEL_ID)
model = AutoModelForMultimodalLM.from_pretrained(
MODEL_ID, dtype=dtype, device_map="auto", attn_implementation="sdpa"
).eval()
audio, _ = librosa.load("audio.wav", sr=16_000, mono=True)
audio = np.asarray(audio, dtype=np.float32)
if len(audio) > 480_000:
raise ValueError("Please provide no more than 30 seconds of audio.")
messages = [
{"role": "system", "content": "You are Sunflower, a helpful assistant made by Sunbird AI who knows many African languages."},
{"role": "user", "content": [
{"type": "audio", "audio": audio},
{"type": "text", "text": "Please transcribe this Luganda audio."}
]}
]
prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(
text=[prompt], audio=[audio], return_tensors="pt",
text_kwargs={"padding": False, "truncation": False, "add_special_tokens": False},
audio_kwargs={"max_length": 480_000}
).to(model.device)
inputs["input_features"] = inputs["input_features"].to(dtype=dtype)
with torch.inference_mode():
output = model.generate(**inputs, max_new_tokens=256, do_sample=False)
new_tokens = output[0][inputs["input_ids"].shape[-1]:]
raw_response = processor.decode(new_tokens, skip_special_tokens=False)
print(processor.parse_response(raw_response)["content"])
Training
The model was adapted via the following stages:
- Continued pretraining on multilingual African-language text (documents, parallel text, transcripts, web, and synthetic text).
- Speech SFT on audio-transcription examples.
- Mixed text-and-audio SFT on translation, instruction, and speech-transcription tasks.
- GRPO post-training to improve translation and general response quality using task-specific reward signals.
Evaluation
Text Translation
Translation quality measured as chrF on the Sunbird/salt69 test split (100 examples per language).
Table with columns: Languages, Directions, Macro BLEU, Macro chrF, Mean Length Ratio| Languages | Directions | Macro BLEU | Macro chrF | Mean Length Ratio |
|---|
| 69 | 138 | 12.20 | 0.3413 | 1.06 |
Table with columns: Code, Language, EN→X BLEU, EN→X chrF, X→EN BLEU, X→EN chrF, Mean chrF| Code | Language | EN→X BLEU | EN→X chrF | X→EN BLEU | X→EN chrF | Mean chrF |
|---|
| afr | Afrikaans | 57.68 | 0.7747 | 57.86 | 0.7649 | 0.7698 |
| pcm | Nigerian Pidgin | 32.76 | 0.6438 | 48.27 | 0.7306 | 0.6872 |
Speech Transcription
Reported ASR results span 110 dataset configurations from Sunbird/speech. Performance varies substantially by language and recording source.
Table with columns: Languages, Scored Examples, Macro Language WER, Macro Language CER, Macro Mean Utterance WER, Macro Mean Utterance CER| Languages | Scored Examples | Macro Language WER | Macro Language CER | Macro Mean Utterance WER | Macro Mean Utterance CER |
|---|
| 51 | 5201 | 0.4720 | 0.1890 | 0.5110 | 0.2016 |
(Rates shown on a 0–1 scale; lower is better. WER can exceed 1.0 when insertions outnumber reference words.)
Table with columns: Code, Language, Scored, Corpus WER, Corpus CER| Code | Language | Scored | Corpus WER | Corpus CER |
|---|
| ach | Acholi | 92 | 0.4086 | 0.1758 |
| afr | Afrikaans | 170 | 0.1413 | 0.0646 |
| aka | Akan | 50 | 0.4182 | 0.1779 |
| amh |
Limitations
- Preview weights: Output will change before the stable release.
- Uneven multilingual quality: Lower-resource languages have substantially lower automatic scores. The low-resource end of the table is genuinely weak, and output there should be verified by a speaker before use.
- Translation variants: BLEU and chrF compare against a single reference and can penalize acceptable wording, dialect, or orthographic variants.
- Speech variation: Accent, dialect, code-switching, background noise, and domain vocabulary can materially affect transcription.
- Language prompting: The model was trained with language-specific transcription prompts and may perform poorly when the spoken language is omitted or named incorrectly.
- Hallucinations: Like any LLM, it can produce fluent, confident, but incorrect translations or transcripts. This matters more in low-resource languages where errors are harder for non-speakers to spot.
License
Released under the Apache 2.0 license, matching the Gemma 4 base model.
Citation
@misc{sunbird2026sunflowergemma4e2b,
title = {Sunflower-Gemma4-E2B},
author = {{Sunbird AI}},
year = {2026},
howpublished = {\url{https://huggingface.co/Sunbird/Sunflower-Gemma4-E2B}},
note = {Preview release: Multilingual text and speech model for African languages}
}