DEV Community

Multigrid
Multigrid

Posted on • Originally published at multigrid.ai

Getting AI Output in Egyptian Arabic Instead of Formal Arabic

Asking for “Arabic” reliably gives you Modern Standard Arabic, which no one speaks at home. Getting Egyptian colloquial requires naming the dialect and constraining a handful of grammatical features, because a vocabulary swap alone produces MSA grammar wearing Egyptian words.

Why generic Arabic gives you MSA

Arabic is diglossic. Modern Standard Arabic is the written register used for news, government, publishing and formal correspondence across the entire Arabic-speaking world; the regional varieties are the spoken languages, and until recently they were written down mainly in dialogue, subtitles, song lyrics and informal messaging.

That distribution is exactly what a model learns from. Written Arabic on the web is overwhelmingly MSA, so MSA is the high-probability continuation of any Arabic context, and it is additionally what an instruction-tuned model associates with the register of “answering a question”. The pull is toward MSA twice over: once from the corpus and once from the task framing. An unqualified request for Arabic therefore lands on MSA not by accident but by the same mechanism that makes an unqualified request for Chinese land on the mainland standard.

Egyptian is the best-represented dialect in that thin colloquial slice — Egyptian cinema and television have been the region’s dominant media for a century, and the subtitles and scripts follow. That makes Egyptian the dialect most likely to work at all, and it is worth knowing that the same procedure applied to a Gulf or Maghrebi variety will produce noticeably weaker results.

The markers that actually differ

These are the features to specify, because they are the ones that decide whether a speaker reads the output as Egyptian or as MSA with local words dropped in.

  • Negation is a circumfix. Egyptian wraps the verb: ما…ش, as in ماكتبش (ma-katab-sh, “he did not write”). MSA uses a preceding particle — لم, ما, لا — and nothing after the verb. This is the single most diagnostic feature, and a response with no ش suffixes anywhere is not Egyptian.
  • The present tense takes a بـ prefix. Egyptian بيكتب (biyiktib, “he writes / is writing”) against MSA يكتب (yaktubu). MSA has no such prefix at all.
  • The future is هـ, not سـ. Egyptian هيكتب (hayiktib) against MSA سيكتب (sayaktubu).
  • Interrogatives are different words entirely. إيه for “what” against MSA ماذا; فين for “where” against أين; إزاي for “how” against كيف; ليه for “why” against لماذا; إمتى for “when” against متى. Egyptian also places them at the end of the clause where MSA fronts them.
  • Case endings are absent. MSA marks nominative, accusative and genitive with iʿrāb suffixes. Egyptian has none. Any tanwīn in the output is an MSA leak.
  • Core vocabulary differs. عايز for “I want” against أريد; دلوقتي for “now” against الآن; كده for “like this” against هكذا; عربية for “car” against سيارة; كويس for “good” against جيد.

The order matters. If you supply only the vocabulary column, a model will produce MSA sentences containing عايز and دلوقتي, which reads to a speaker as a foreigner’s Arabic rather than as Egyptian. The morphology is what carries the dialect.

There is no standard spelling to hold you to

MSA has a codified orthography with centuries of institutional backing. Egyptian Arabic, as a written language, does not. The same word is spelled several ways by different writers, and the variation is systematic enough to name:

  • Final ي versus ى. Egyptian writing frequently uses the dotted ي where MSA would use alif maqṣūra ى, and just as frequently does not. Both appear in the training data for the same words.
  • Final ة versus ه. Tāʾ marbūṭa is often written as a plain hāʾ in informal Egyptian text, reflecting how it is pronounced.
  • Hamza carriers. The seat of the hamza (أ, إ, ؤ, ئ, or bare ء) is regularly omitted or simplified in informal writing, so إيه appears as ايه and المهندس as المهندس or الـمهندس.
  • Words with no settled spelling at all. دلوقتي is also written دلوقت and دلوئتي; عايز as عاوز. These are not errors, they are competing conventions.

Three consequences for anything you build on top. Exact-match search and deduplication over Egyptian text will fail on spelling variants unless you normalise first, which is the general problem covered in Unicode normalisation plus an Arabic-specific folding step for hamza seats and final letters. Output will be internally inconsistent across a long document, because the model is sampling from a distribution that genuinely contains both spellings, and no instruction fixes that cleanly — pick a convention and apply it in a post-pass instead. And any automatic quality check that compares generated text against a reference will underreport quality, because it will count spelling variation as error.

The spelling variability also compounds the token cost. Arabic already carries a fertility penalty at two bytes per character in UTF-8, and dialect spellings that are rarer than their MSA equivalents win fewer tokenizer merges — so the same sentence in Egyptian generally costs more tokens than in MSA. The scale of that is set by the mechanism in the token cost of Arabic.

Writing the prompt

Name the dialect in Arabic as well as English, state the markers as positive requirements, and forbid the MSA features explicitly. A negative-only instruction (“do not use MSA”) performs poorly because it does not tell the model what to do instead.

system:
Write in Egyptian Colloquial Arabic (اللهجة المصرية العامية / Masri),
the spoken variety of Cairo. Not Modern Standard Arabic.

Required:
- negate verbs with the circumfix ما...ش  (e.g. ماروحتش, not لم أذهب)
- prefix present-tense verbs with بـ       (e.g. بيروح, not يذهب)
- prefix future verbs with هـ              (e.g. هيروح, not سيذهب)
- use إيه / فين / إزاي / ليه / إمتى for question words
- use عايز, دلوقتي, كده, كويس

Forbidden:
- case endings (iʿrāb) and tanwīn
- سوف or the سـ future prefix
- لم / لن / ما as standalone negation particles
- ماذا / أين / كيف / لماذا / متى

Keep every sentence in the dialect, including headings and list items.
Enter fullscreen mode Exit fullscreen mode

The last line is not filler. Structured output is where dialect instructions break down first — a model that holds the dialect in prose will often revert to MSA in a bulleted list or a heading, because those constructions are almost exclusively MSA in the training data.

The procedure

  1. Put the dialect instruction in the system prompt, not the user turn. It has to apply to every turn, and a conversation that renegotiates it each message will drift.
  2. Add two or three short exchanges as few-shot examples, written in Egyptian. Examples in the target variety do more than any amount of description, because they put the actual token statistics you want into the context — the argument in few-shot examples in the target language. If you cannot write them, source them from a native speaker; a wrong example is worse than none.
  3. Cap output length and chunk long documents. Dialect adherence decays with distance from the instruction. Several 300-word calls hold the register better than one 2,000-word call.
  4. Re-anchor at the end of the user turn. Repeating “اكتب بالمصري” immediately before the model generates puts the constraint at the position with the most local influence on the first tokens.
  5. Screen the output mechanically using the checks below, then have a speaker review anything that is going in front of users.

Verifying output you cannot read

Three regex-level checks catch most MSA leakage without reading Arabic. Count occurrences of the negation suffix ش at word end and of the بـ present prefix; near-zero in a long response means the morphology reverted. Search for tanwīn marks and for the MSA question words listed above; any hit is a leak. And search for سوف and the standalone سـ future, which is the most common single regression.

None of this substitutes for a speaker, and Egyptian itself has registers — the Cairene of a television script is not the Egyptian of a formal customer-service message. If your product speaks to several Arabic-speaking markets, the harder problem is that a single dialect choice will read as foreign to most of them, which is the subject of regional Arabic dialect confusion. MSA remains the correct choice for anything formal and pan-regional; the dialect is for the places where MSA sounds like a newsreader.

Related

Top comments (0)