Case study · Production AI

A RAG that answers farmers
in their own dialect.

SheGrows is a WhatsApp assistant for women farmers in Egypt, built by 1morething for FAO. Farmers ask in Egyptian Arabic, by text or by voice note, and the knowledge base is written in formal Arabic. I owned the part that makes those two meet, the dialect retrieval layer, and the loop that turns expert answers into new knowledge.

Client
FAO · Egypt
My role
AI Engineer · dialect retrieval and feedback loop, in a team of 4
Stack
RAG · pgvector · Arabic full-text search · GPT-4o · Azure
Status
In production since July 2026

01The problem

RAG looks like magic in English demos. Drop in PDFs, retrieve, prompt the model, done. This one had to answer questions like "how do I water my courgette in summer" (typed as ازاى اروى الكوسة فى الصيف؟) against documentation written in formal Arabic. The same word arrives with different alif shapes, with or without diacritics, with stray right-to-left marks from a phone keyboard. Dialect sits on top of all of that.

Most embedding models, even multilingual ones, can't tell that the dialect question and the formal documentation mean the same thing. Dialect questions kept missing documents that plainly answered them.

02The constraint that shaped everything

In agriculture, a wrong pesticide dose can kill a crop, or worse. The system could not be allowed to guess confidently. That single constraint drove the confidence architecture: anything uncertain goes to a human agronomist instead of the model.

"The 'I don't know, let me get someone' path isn't a fallback. It's a feature."

03The pipeline

Steps 1, 2, 3, 5 and 6 are mine. Step 4 was a teammate's, and it is here because the rest does not make sense without it.

1
Normalize the query, never the docs
Strip diacritics, tatweel and right-to-left marks; unify alif variants. Ta-marbuta stays, because it carries meaning in technical Arabic. The knowledge base is left untouched so the exact words farmers search for survive.
2
Rewrite dialect into formal Arabic, with frozen nouns
A few-shot GPT-4o call converts Egyptian colloquial into formal Arabic and is told not to touch crop names, pesticide names, doses, dates or units. Rewrites are cached. Retrieval always runs on both the original and the rewrite, and the results are merged.
3
Hybrid retrieval with the Arabic tokenizer
pgvector for meaning, Postgres full-text search for keywords, merged by keeping each passage's best score. Postgres full-text search defaults to a configuration that does not understand Arabic; switching it to the Arabic one was a one-line change.
4
Thresholds tuned for Arabic
English-tuned 0.7 cosine thresholds rejected most correct Arabic matches, whose real scores sat between 0.20 and 0.45. A teammate's 20-query benchmark across Arabic, French and English set an empirical floor and ceiling.
5
Three outcomes, and the same answer every time
High confidence: answer. Medium: answer with a disclaimer. Low: escalate to a human agronomist. I also made routing deterministic, so the same message always takes the same path, and added a block that escalates before the LLM is even called when retrieval is weak.
6
Expert answers feed the knowledge base
Resolved escalations are embedded back into the knowledge base, kept in the farmer's own language and register. More than 1,200 expert answers have gone back in so far; new ones now pass an admin approval step first.

04The outcome

In production since July 2026. By late September it had answered more than 15,000 questions from over 100 farmers, about a third of whom ask by voice. Roughly four in five questions are answered without a human. These usage figures come from the production database. Answer accuracy has not yet been graded against an expert-labelled set, so it is not claimed here.

15K+
Farmer questions answered since the July 2026 launch
~4 in 5
Answered without a human; the rest go to an agronomist instead of a guess
1,200+
Expert answers fed back into the knowledge base through the loop I built
3 paths
Answer, answer with a disclaimer, or a human expert. No confident guessing on crop-critical advice

Want the engineering detail: the normalization rules, the rewriter prompt design, the threshold numbers? It's all in the long-form write-up: Arabic Broke My RAG. Here's What Saved It.

Have a messy, non-English, real-world RAG problem? Let's talk ↗