Arabic is one of the most spoken languages on Earth, and one of the worst served by AI. The problem is not a lack of speakers or text. The problem is that "Arabic" is not one language in practice. A user in Riyadh, a user in Cairo, and a user in Karachi typing Urdu in Arabic script all write differently — and most models handle that reality poorly.
rihla-llm is my attempt to build a multilingual model pipeline for Arabic, Urdu, and English that respects how people actually write. This article shares the lessons that mattered most, because they generalize to anyone building AI for under-served languages.
Lesson 1: Script is not language
Urdu and Arabic share a script, so naive pipelines lump them together. That is a mistake. The same characters carry different vocabularies, different grammar, and different cultural context. A model trained on mixed data without language awareness produces answers that drift mid-sentence — Arabic words in Urdu grammar, or formal Modern Standard Arabic where the user wrote casual dialect.
In rihla-llm, language identification happens early and explicitly. Every training example is tagged, and the model learns to stay in the language the user chose. It sounds obvious. Almost nobody does it carefully.
Lesson 2: Dialect is the product
Most Arabic training data is Modern Standard Arabic — news, books, formal writing. But people do not chat in Modern Standard Arabic. They write Gulf dialect, Egyptian dialect, Levantine slang, and Roman Urdu mixed with English words. A model that only understands formal Arabic feels foreign to the very users it claims to serve.
The practical fix is unglamorous: collect and clean real conversational data, normalize the wild spelling variation of dialect text (the same word can be spelled five ways), and evaluate on dialect test sets, not just formal benchmarks. My rule became simple: if a native speaker would not write it that way in a WhatsApp message, the model should still understand it — and reply naturally.
Lesson 3: Tokenization quietly decides your budget
Tokenizers trained mostly on English split Arabic words into many small pieces. That means Arabic text costs more tokens, fills context windows faster, and gives the model less room to think. It is an invisible tax on every Arabic user.
When building rihla-llm, measuring tokens-per-word for Arabic and Urdu versus English was one of the first diagnostics. If your tokenizer needs three tokens for a common Arabic word, your effective context and your inference bill both suffer. Choosing a base model and vocabulary with decent Arabic coverage is not a detail — it is a budget decision that compounds with every request.
Lesson 4: Fine-tuning beats scale for domain work
I did not train a foundation model. I fine-tuned one, using QLoRA so the work fits on modest hardware, then applied preference tuning (DPO) to push outputs toward helpful, in-language, culturally appropriate responses. For a domain assistant — travel, local services, everyday questions in Arabic and Urdu — a well-tuned smaller model beats a giant general model that answers in stiff formal Arabic.
The pipeline matters more than the parameter count:
- Curate domain data in all three languages, with dialect coverage.
- Fine-tune with QLoRA for efficiency.
- Align with DPO using preference pairs that reward staying in-language and answering directly.
- Ground with retrieval (RAG) so factual answers come from documents, not memory.
Lesson 5: Evaluation must be native
Benchmarks translated from English do not tell you whether Arabic users will be satisfied. I evaluate with native-speaker-style test prompts: dialect questions, code-switched Urdu-English messages, and requests where the correct answer requires local context. A model can score well on translated benchmarks and still fail every one of these.
If you build for a language, test in that language, the way its speakers actually write. Everything else is theater.
Why this work matters
Hundreds of millions of people speak Arabic and Urdu. Their AI tools should understand them as they are — dialect, code-switching, script and all. rihla-llm is a small step, built with open techniques: QLoRA fine-tuning, DPO alignment, and retrieval grounding. The larger lesson is for every builder working in an under-served language: respect the language's real usage, measure honestly, and tune for your users instead of for a leaderboard.
Muhammad Faizan is an AI engineer and full-stack developer based in Saudi Arabia. He builds ML systems and developer tools including PocketBot and Gale Download Manager. More at faizzyhon.com.
Frequently asked questions
Why do many Arabic AI products feel wrong to native speakers?
They are trained and tested on formal Modern Standard Arabic, while real users write dialects, mix scripts, and code-switch with English. The product then fails on exactly the text people produce.
What is rihla-llm?
A multilingual pipeline for Arabic, Urdu and English domain text, built with QLoRA fine-tuning, DPO preference tuning and retrieval, designed around dialect and script realities.
Why does tokenization matter so much for Arabic?
Arabic morphology packs a lot into each word, and generic tokenizers split it inefficiently. That inflates sequence length and cost, and can quietly degrade quality.
Related reading
- rihla-llm: A Multilingual Arabic, Urdu and English LLM Pipeline
- Arabic and Urdu Text Laser Engraving Design Guide
Written by Muhammad Faizan
AI engineer and full-stack developer based in Saudi Arabia. B.S. in Artificial Intelligence (2024), former ML engineer at Systems Limited, and builder of production systems for hotels, clinics and the open-source Gale download manager.