akera commited on
Commit
dbf8c10
·
verified ·
1 Parent(s): 6941e5d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +166 -0
README.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ language:
4
+ - en
5
+ - lg
6
+ - xog
7
+ - nyn
8
+ - nyo
9
+ - ach
10
+ - teo
11
+ base_model: google/gemma-4-e2b
12
+ tags:
13
+ - audio
14
+ - multimodal
15
+ - gemma
16
+ - gemma-4
17
+ - speech-qa
18
+ - ugandan-languages
19
+ - low-resource-languages
20
+ - sunbird
21
+ library_name: transformers
22
+ pipeline_tag: audio-text-to-text
23
+ ---
24
+
25
+ # Sunbird Tutor · Gemma 4 E2B
26
+
27
+ A Gemma 4 E2B fine-tune for spoken question-answering in English and Ugandan languages. Audio in, text answer out, no intermediate transcription step.
28
+
29
+ This is the multilingual SFT checkpoint described in the Sunbird Tutor writeup (Kaggle Gemma 4 Good Hackathon, 2026). It powers the [Sunflower educational assistant app](https://github.com/SunbirdAI/sunflower-app), an Android app that runs the model fully offline so a child in a Ugandan classroom can ask a science question in Luganda and get an answer back in Luganda, without an internet connection.
30
+
31
+ **Training code**: [SunbirdAI/sunbird-tutor-modelling](https://github.com/SunbirdAI/sunbird-tutor-modelling) contains the multilingual training pipeline, data prep, and evaluation harness used to produce this model.
32
+
33
+ ## What it does
34
+
35
+ Accepts 16 kHz mono PCM audio directly through Gemma 4's native audio tower, with no separate ASR step. The audio understanding lives inside the same context window that produces the answer, so a single forward pass takes you from a spoken question to a written reply. Depending on the prompt, the model can answer the question, transcribe the speech, translate it into another supported language, or explain what was said.
36
+
37
+ Vision was not exercised during fine-tuning. Text plus audio input only.
38
+
39
+ ## Languages
40
+
41
+ | ISO 639-3 | Language | Status |
42
+ |---|---|---|
43
+ | `eng` | English | strong |
44
+ | `lug` | Luganda | strongest non-English. chrF ~0.51 on the project eval. |
45
+ | `ach` | Acholi | second tier. chrF ~0.40, classroom-usable for shorter responses. |
46
+ | `nyn` | Runyankole | transcription and short translation reliable; QA degrades. |
47
+ | `xog` | Lusoga | transcription and short translation reliable; QA degrades. |
48
+ | `nyo` | Lunyoro | transcription and short translation reliable; QA degrades. |
49
+ | `teo` | Ateso | transcription and short translation reliable; QA degrades. |
50
+
51
+ Quality scales with training data volume, so Luganda is meaningfully ahead. The broader Sunbird Tutor project targets 12 Ugandan languages across multiple checkpoints; see the [training repo](https://github.com/SunbirdAI/sunbird-tutor-modelling) for the larger picture.
52
+
53
+ ## How to use
54
+
55
+ ### Transformers (Python)
56
+
57
+ ```python
58
+ import torch
59
+ from transformers import AutoProcessor, AutoModelForImageTextToText
60
+
61
+ processor = AutoProcessor.from_pretrained("Sunbird/sunbirdtutor-gemma-4-e2b")
62
+ model = AutoModelForImageTextToText.from_pretrained(
63
+ "Sunbird/sunbirdtutor-gemma-4-e2b",
64
+ torch_dtype=torch.bfloat16,
65
+ device_map="auto",
66
+ )
67
+
68
+ messages = [
69
+ {
70
+ "role": "system",
71
+ "content": (
72
+ "You are an educational assistant that can give explanations, "
73
+ "transcriptions and translations in Ugandan languages."
74
+ ),
75
+ },
76
+ {
77
+ "role": "user",
78
+ "content": [{"type": "audio", "audio": "path/to/16khz_mono.wav"}],
79
+ },
80
+ ]
81
+
82
+ inputs = processor.apply_chat_template(
83
+ messages,
84
+ add_generation_prompt=True,
85
+ tokenize=True,
86
+ return_dict=True,
87
+ return_tensors="pt",
88
+ ).to(model.device)
89
+
90
+ outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
91
+ answer = processor.batch_decode(
92
+ outputs[:, inputs["input_ids"].shape[1]:],
93
+ skip_special_tokens=True,
94
+ )[0]
95
+ print(answer)
96
+ ```
97
+
98
+ The exact auto-class for Gemma 4 audio depends on your transformers version. If `AutoModelForImageTextToText` does not pick up the audio tower, the loader scripts in [sunbird-tutor-modelling](https://github.com/SunbirdAI/sunbird-tutor-modelling) have the working class names.
99
+
100
+ ### On-device
101
+
102
+ For mobile, use the Cactus INT4 quantization: [Sunbird/sunflower-qa-cactus-int4](https://huggingface.co/Sunbird/sunflower-qa-cactus-int4). About 3.8 GB on disk, fully offline. The audio tower stays at FP16 so Luganda speech recognition survives quantization; the decoder is pushed to INT4.
103
+
104
+ ## Prompt format
105
+
106
+ Use this system prompt verbatim. The fine-tune saw it on every training example, and drift here measurably degrades quality:
107
+
108
+ > You are an educational assistant that can give explanations, transcriptions and translations in Ugandan languages.
109
+
110
+ The user content varies by mode:
111
+
112
+ | Mode | User content |
113
+ | ---------------- | ------------------------------------------------ |
114
+ | Answer (default) | empty string. Audio carries the question. |
115
+ | Transcribe | `"Transcribe this audio."` |
116
+ | Translate | `"Translate this audio into {target language}."` |
117
+ | Explain | `"Explain what was said in this audio."` |
118
+
119
+ The canonical runtime strings live in [`lib/model_settings_sheet.dart`](https://github.com/SunbirdAI/sunflower-app/blob/master/lib/model_settings_sheet.dart) inside the Sunflower app.
120
+
121
+ ## Training
122
+
123
+ Fine-tuned from `google/gemma-4-e2b`. The pipeline, documented in full in the [training repository](https://github.com/SunbirdAI/sunbird-tutor-modelling), has three stages:
124
+
125
+ 1. **Continued pretraining** on around 600M characters of Ugandan-language text from web articles, books, translations, and synthetic instruction-following examples.
126
+ 2. **Multilingual SFT on transcription** using speech data from SALT, Google's Waxal, FLEURS, and the Makerere speech benchmark.
127
+ 3. **A short final fine-tune on speech QA**, built from the Ugandan primary school curriculum, machine-translated to Ugandan languages and converted to speech with a TTS model the team had previously trained (Orpheus 3B based).
128
+
129
+ The audio tower was preserved throughout. The decoder adapts to Ugandan-language QA while keeping Gemma 4's native speech understanding intact.
130
+
131
+ For exact configs, training scripts, per-language eval numbers, and the writeup that frames the work, see the [training repo](https://github.com/SunbirdAI/sunbird-tutor-modelling).
132
+
133
+ ## Intended use
134
+
135
+ Primary school science Q&A in Ugandan classrooms. The demo curriculum covers six Primary 5 to Primary 7 topics: photosynthesis, the water cycle, the life cycle of an insect, malaria prevention, digestion, and the solar system. Beyond Q&A, the model handles speech transcription, translation between supported languages from spoken input, and short spoken explanations. It is also useful as a research artifact for adapting multimodal foundation models to low-resource languages.
136
+
137
+ ## Out of scope
138
+
139
+ High-stakes domains, including medical, legal, and financial advice. Languages outside the seven listed. Image input. Long-form generation past a few hundred tokens, which drifts from the single-turn QA distribution the fine-tune was optimised for.
140
+
141
+ ## Limitations
142
+
143
+ Only Luganda reaches the strongest tier of QA quality. Acholi is classroom-usable for shorter responses. The other four Ugandan languages are present in the model but full question-answering degrades outside Luganda and Acholi; transcription and short translation remain reliable. Background-noise robustness has not been formally benchmarked in classroom environments. Audio inference assumes 16 kHz mono PCM input.
144
+
145
+ ## Related artifacts
146
+
147
+ - [SunbirdAI/sunbird-tutor-modelling](https://github.com/SunbirdAI/sunbird-tutor-modelling): training code, data pipeline, evaluation harness.
148
+ - [SunbirdAI/sunflower-app](https://github.com/SunbirdAI/sunflower-app): Android app that runs this model on-device.
149
+ - [Sunbird/sunflower-qa-cactus-int4](https://huggingface.co/Sunbird/sunflower-qa-cactus-int4): Cactus INT4 quantization, ~3.8 GB.
150
+
151
+ ## Acknowledgements
152
+
153
+ Built by the Sunbird AI team. Foundation model: Google's Gemma 4 E2B. Inference engine: [Cactus](https://github.com/cactus-compute/cactus).
154
+
155
+ ## Citation
156
+
157
+ ```bibtex
158
+ @misc{sunbird-tutor-gemma-4-e2b-2026,
159
+ author = {Sunbird AI},
160
+ title = {Sunbird Tutor: Gemma 4 E2B for spoken question-answering in Ugandan languages},
161
+ year = {2026},
162
+ url = {https://huggingface.co/Sunbird/sunbirdtutor-gemma-4-e2b}
163
+ }
164
+ ```
165
+
166
+ Submitted to the Kaggle Gemma 4 Good Hackathon, 2026.