-
-
English: a pregnancy-nutrition question answered with a full nutrient breakdown, what's missing, and a specific local food to add
-
Data set- English and Yoruba
-
341 real Nigerian meal combinations from 1,074 labelled photos, composed against a 41-food Yorùbá nutrition knowledge base
-
Training process : Training loss curve , reduced from 1.2 to 0.16 at 0.2 epcoh
-
Merged model (fp16, 8.7 GB) → GGUF Q4_K_M (3.2 GB) via llama.cpp's llama-quantize — a ~2.7× size reduction for CPU-only deployment.
-
Final artifact: 3.2 GB, down from 8.7 GB at full precision — a 2.7× reduction that fits comfortably inside the 8 GB laptop RAM target
-
A demo to show the model running locally on a gradio and a user testing
-
A user asked a question In Yoruba : Yorùbá: — the model identifies the meal, lists its nutrients, and names what food would complete it.
-
provided nutrional guidance
Inspiration
One in Three children in Nigeria faces malnutrition. The damage concentrates in the first 1,000 days — pregnancy to age two — a window that closes and does not reopen. After it, stunting is irreversible.
The interventions are well understood and cheap. What is missing is guidance at the point of decision: a mother standing over a pot, deciding what goes in it today.
Generic nutrition apps fail her twice. They do not know Egusi from salad, they recommend Western foods she cannot find in her market, and they only speak English.
We tested that second failure before writing a line of training code. We asked base
Gemma 4 a nutrition question in Yorùbá. It correctly chose to answer in Yorùbá — and
then produced fluent-sounding text about morals and parenting. Not one word about
nutrition. When we put English nutrition data in front of the same question, it
collapsed into a repetition loop, ìgbẹ́kẹ̀lé twenty-five times, and never reached
the question at all. The identical question in English returned a clean, accurate,
useful answer.
That gap is the project. A mother who cannot read the advice cannot act on it, and the households where malnutrition concentrates are the least likely to operate in English.
What it does
NutriMama is the nutrition intelligence. It answers the question mothers actually ask — *is this meal enoughfor my child?
- — about the food actually on the plate: àmàlà, ẹ̀gúsí, mọ́ínmọ́ín, ògì, ẹ̀wà.
It replies in whichever language the question was asked in.
It does not recite nutrient tables. It reads the food groups present on a plate and works out what nutrient is missing, then names a local food that completes it:
Q (Yorùbá): Ǹjẹ́ aláboyún lè jẹ ẹ̀bà pẹ̀lú ọbẹ̀ ẹ̀gúsí? A: Ẹ̀bà (Carbohydrates, Fibre) … Ọbẹ̀ ẹ̀gúsí (Protein, Fat, Magnesium) … Ìmọ̀ràn: Oúnjẹ yìí kò tíì pé — fi ewébẹ̀ tútù kún un. (This meal is not yet complete — add fresh vegetables.)
Energy and protein are on that plate; the protective group is not. The model worked that out from the food, not from a template.
The whole thing runs on the CPU of an 8 GB laptop with no internet connection.
How we built it
Base model: Gemma 4 E2B. Natively multilingual, so Yorùbá is adaptation rather than a cold start; effective-2B fits the 8 GB profile with headroom; supported by llama.cpp.
Training: LoRA (r=32, α=64, lr=1e-4, 2 epochs) with embed_tokens and lm_head
frozen — instruction-following lives in those layers and we did not want to disturb
it. 12,070 examples across four objectives:
| slice | n | job |
|---|---|---|
| Yorùbá fluency (en→yo rendering) | 5,000 | fixes the generation collapse |
| Nutrition Q&A, bilingual | 4,296 | domain knowledge in both languages |
| General food Q&A, bilingual | 910 | equal coverage of open questions |
| English health Q&A | 790 | protects the already-strong English path |
| Nigerian dish identification | 1,074 | 41-dish label vocabulary |
Variety comes from data, not paraphrase. Answers are composed from a 41-food
Yorùbá knowledge base against 341 real plate combinations found in our own labelled
dataset, producing 2,649 distinct answers. Ẹ̀bà + Ẹ̀gúsí + Ẹja gbígbẹ is a different
nutritional picture from Ògì + Àkàrà, and the model composes from the actual foods.
Every Yorùbá token was verified before training. We built a 68,665-token attested
vocabulary from a human-reviewed Yorùbá corpus plus human-written reference answers,
then gated all generated Yorùbá against it. Out-of-vocabulary rate: 0.00% across
278,624 tokens. The gate caught real authoring errors at source — including ìdodo
(navel) mistakenly used for toothpaste.
Deployment: merged, converted to GGUF, quantized to Q4_K_M — 3.2 GB, peak RSS 2.6 GB, running under llama.cpp with zero network calls.
Challenges we ran into
The tokenizer shreds Yorùbá. We measured it:
| tokens per word | |
|---|---|
| English | 1.16 |
| Yorùbá | 2.75 |
'Ṣàlàyé àwọn èròjà' → ['Ṣ','à','l','ày','é','▁à','w','ọn','▁è','r','ò','jà']
At 2.4× the token cost, tone placement must be learned token by token. Repetition-loop degeneration is the known signature of this weakness, and it is exactly what we observed. Closing it took the 5,000-example fluency slice.
A dataset that looked like 5,000 examples was 10. An early Yorùbá dataset had 5,000 rows. Profiling it showed 10 unique answers repeated 500× each — only a counter in the input varied. Training on it would have produced a model that memorised ten paragraphs. We threw it out and rebuilt from real plate combinations.
Bidirectional translation data broke language routing. Our first run included both en→yo and yo→en pairs. The yo→en direction taught the model to answer Yorùbá questions in English, which we caught with matched-pair probes. The shipped model trains en→yo only, with equal coverage of both languages across question types.
Fine-tuning hard on one language risks losing the others. We measured arc_easy
before and after: 70.0% base → 68.3% fine-tuned (n=300). Inside sampling noise —
the Yorùbá work cost nothing in general reasoning.
Accomplishments that we're proud of
The first nutrition assistant that speaks a Nigerian mother's language and knows her food. Every tool she can currently download fails on one side or the other: nutrition apps that know food but only speak English, or translation tools that speak Yorùbá but think dinner is a Caesar salad. NutriMama is the first we are aware of that does both — it knows Àmàlà from Ẹ̀gúsí from Mọ́ínmọ́ín, and it answers about them in Yorùbá.
We closed a capability gap, and proved it. Base Gemma answered a Yorùbá nutrition question with filler about parenting, and collapsed into a repetition loop when English data sat in front of it. The fine-tuned model gives substantive guidance in Yorùbá and holds the language regardless of context.
It gives an answer she can act on, not a table she has to interpret. Told a plate has energy and protein but nothing protective, it says fi ewébẹ̀ tútù kún un — add fresh vegetables. A nutrient breakdown asks a mother to do the reasoning. This does the reasoning and names a food she already has.
It works where the need is. 3.2 GB, 2.6 GB peak RSS, 8.76 tok/s on a 7.9 GB Windows laptop from 2016 — with the network unplugged. A mother with no data left on her bundle, in a home where the network drops for hours, gets the same answers as anyone else. A community health worker in a clinic with no signal gets the same answers as anyone else.
We did it without breaking anything else. 68.3% vs 70.0% on arc_easy — within
sampling noise. The Yorùbá work cost nothing in general reasoning.
0.00% out-of-vocabulary across 278,624 Yorùbá tokens. Every word traceable to attested usage. Generated text in a low-resource language reads as fluent while being wrong, and it is invisible at scale — so we built a gate instead of hoping.
What we learned
Measure before you build. Ten minutes of probing base Gemma told us the problem was Yorùbá generation quality, not language routing — routing already worked. Had we assumed, we would have spent the project solving a problem that did not exist.
Count unique examples, not rows. The 5,000-row dataset that held 10 answers would have quietly wrecked the model.
In a low-resource language, verify at the token level. Bad Yorùbá at scale looks fluent and is invisible without a check.
Data composition beats paraphrase. 341 real plate combinations produced far better variety than any amount of rewording, because the underlying content genuinely differed.
Test the harness, not just the model. Our first accuracy run scored both base and fine-tuned models at ~31% — near random on a 4-choice task. The model was fine; we had omitted Gemma's BOS token. A sanity check ("what do plants need to make food?" → harness answered Concrete) caught it. With BOS: 70%.
What's next for Nutri-MaMa
- Add Other Nigerian languages - Hausa, Igbo and Pidgin, using the same verification method.
- Photo input in production. The model is trained on 1,074 labelled meal images across 41 dishes; the vision projector is built and working. A mother photographs the plate instead of naming it.
- Database grounding. In production Nutri MaMa grounds quantitative claims against a structured nutrition database — the offline model supplies the reasoning and the language, the database supplies the numbers.
- Native-speaker review at scale ahead of field deployment.
- First-1,000-days depth: complementary feeding schedules, Growth Tracking, Daily Nutritional Tips Reminder, growth-faltering warning signs.
Built With
- gemma
- llama.cpp
- natural-language-processing
- nutrition
- offline-first
- python
- pytorch
- q4-km
- quanticization
- transformers
- unsloth
- yoruba