BM
Bashar ModallalSOFTWARE · AI · SYSTEMS
← All field notes

AI

Designing Arabic–English Retrieval That Handles Mixed Queries

A practical design for Arabic-English retrieval across mixed queries, combining language-aware lexical search, multilingual vectors, careful normalization, balanced ranking and bilingual evaluation.

Teal and amber document streams converge in a shared multilingual search index.

العربية؟ اقرأ النسخة العربية: تصميم استرجاع بالعربية والإنجليزية يدعم الاستعلامات المختلطة.

An Arabic-speaking analyst may ask, “ما سبب ارتفاع 429 في خدمة payments بعد deploy؟” The query contains Arabic grammar, an HTTP status, an English service name, and an engineering verb. The answer may be in an English runbook, an Arabic incident report, or two sources that describe different parts of the same event. A retrieval system that treats the query as one language, translates it once, and searches one index can miss evidence or obscure why it missed it.

Arabic-English retrieval is a system design problem spanning text normalization, lexical analysis, embeddings, query routing, ranking, access control, and evaluation. The goal is not to make every source look like English. It is to let users search naturally across the languages in which useful evidence exists, while keeping source text, permissions, and citations traceable.

Start with the corpus and the questions

Before choosing a multilingual embedding model, inventory the content and query patterns. Record document language, script, source system, version, section path, timestamp, and access policy. Sample the questions people really ask: fully Arabic, fully English, mixed Arabic and English, product names, code identifiers, Arabic dialect, and spelling variants. A mixed query is not necessarily a language-detection error; it can be the normal language of technical work.

A useful architecture begins with language-aware fields, not one generic text field. Store the original passage unchanged. Add normalized searchable representations for Arabic and English, plus typed metadata. In a bilingual record, separate fields such as body_ar and body_en can use different lexical analyzers. For a mixed-language source, detect language at sentence or span level, or preserve the original field while indexing additional language-specific views. Keep the original as the source of truth for quotations and citations.

This matters because language analysis is linguistic processing, not mere lowercasing. Microsoft documents Arabic analyzers such as ar.microsoft and ar.lucene, and recommends comparing analyzer behavior on representative content. Its analyzer guidance explains that analyzer choice affects both indexing and query processing. Elasticsearch likewise provides a dedicated Arabic analyzer and composable character, token, and stemmer filters. These are implementation options, not a universal ranking: inspect the tokens they produce for your corpus before selecting one.

Normalize carefully; preserve evidence

Arabic text has orthographic variation that can fragment exact lexical matches: optional diacritics, presentation forms, and common variants in alif or other characters. Unicode normalization can also make visually identical strings use different code-point sequences. A robust pipeline creates a normalized search copy while retaining the exact original text. Version the normalization rules, apply compatible rules at indexing and query time, and avoid transformations that erase distinctions important to a domain.

Do not normalize everything indiscriminately. A device serial, customer ID, endpoint path, or acronym may be case- or punctuation-sensitive. Technical identifiers often need a separate keyword field with exact-match behavior. Keep both original and normalized values, and record which transformation produced the latter. If a user searches for /v2/payments, stemming or stripping punctuation may make results less precise.

An analyzer is not a language detector. A collection-wide Arabic analyzer can improve Arabic morphology while mishandling embedded English product names or code. Conversely, an English analyzer can tokenize Latin-script identifiers usefully while offering little help for Arabic morphology. Use explicit language fields where possible. When documents contain both languages, sentence-level language labels or extracted spans make indexing decisions inspectable.

Normalization also has an evaluation boundary. A rule that removes diacritics may improve recall for unvocalized queries but can collapse forms that a specialist corpus needs to distinguish. A synonym map may help with organization-specific terminology but can introduce false matches when a short acronym has multiple meanings. Keep transformations reversible where possible, test each rule against positive and negative pairs, and retain the raw query in a privacy-appropriate trace. The best normalization pipeline is therefore not the most aggressive one; it is the one whose effect on retrieval can be explained and measured.

Retrieve through complementary lanes

No single retrieval method is reliably best for every mixed-language question. A practical design runs several bounded candidate generators in parallel:

flowchart TD
  Q["Mixed query"] --> N["Normalize and preserve spans"]
  N --> L["Arabic and English lexical lanes"]
  N --> V["Multilingual vector lane"]
  L --> F["Filter, fuse, and rerank"]
  V --> F
  F --> E["Evidence with source locations"]

The diagram shows two different signals joining before a shared evidence stage. Lexical lanes help with exact service names, error codes, product terminology, and language-specific word forms. The vector lane can match semantically related passages across languages even when wording differs. Fusion combines candidate ranks; a reranker can then judge a smaller set using original query and passage text.

A multilingual embedding model can place Arabic and English text in a shared vector space, but shared representation does not guarantee equal retrieval quality. The CLAIRE Arabic cross-lingual retrieval system describes an approach based on English-Arabic cross-lingual word embeddings, showing one way to retrieve across language boundaries without translating every document. More recent Arabic-English RAG research by Amiraz and colleagues reports that cross-language document-query pairs can expose retrieval weaknesses hidden by language imbalance, and studies balanced retrieval and query translation as remedies. Treat this as a design warning: test the language pairs in your own corpus, not only an aggregate score.

For lexical search, make the language field explicit. For semantic search, preserve the original query and optionally generate controlled variants: an Arabic-only view, an English technical-term view, and a translated query when the request requires it. Do not replace the user's query with a translation and discard the original. Translation can add a useful path, but can also choose the wrong sense, mistranslate a proper noun, or change a negation. Keep query expansion bounded and log which variants contributed candidate results.

Fuse ranks without pretending scores are comparable

BM25 scores, cosine similarities, and cross-encoder scores have different scales and distributions. Adding them directly with arbitrary weights may cause one lane to dominate because of score calibration rather than relevance. A rank-based fusion method such as reciprocal rank fusion is a useful baseline: each lane contributes according to candidate rank, without assuming that a score of 0.72 in one model means the same thing as 0.72 in another. If product requirements call for calibrated score fusion, fit and validate that calibration on held-out queries.

Balance language lanes deliberately. If an English corpus is much larger, a global top-k can fill with English documents before Arabic candidates are considered. One option is to retrieve a quota from each language lane, merge those candidates, and rerank together. Another is a language-aware prior or balanced candidate budget. These controls do not guarantee that Arabic is relevant; they prevent corpus size alone from deciding which language gets a chance to compete.

Apply authorization filters before any candidate reaches the user or generation model. Each lane must use the same tenant, user, and document ACL constraints. A late merge must not reintroduce a passage excluded by another lane. Carry document ID, version, language, source URL, section, and access metadata through fusion so that ranking never detaches evidence from its provenance.

Worked example 1: a mixed incident query

Suppose the user asks: “ما سبب ارتفاع 429 في payments بعد deploy؟” The request contains Arabic words plus an exact HTTP status and service identifier. First preserve the full original query. A lightweight span detector can identify Arabic text, the numeric error code, and the Latin service name; it should not force the whole sentence into one language label.

Next execute an Arabic lexical query against Arabic fields, an English lexical query expanded only with approved technical aliases, and a multilingual vector query against both languages. Search 429 and payments as exact or keyword terms as well as semantic text. If the index contains an Arabic incident report titled “ارتفاع أخطاء الدفع بعد النشر” and an English runbook that says “payment gateway rate limiting,” lexical paths can catch the error code and service name while the vector path can bridge “ارتفاع” and “rate limiting.”

Fuse candidate lists, apply the same ACL constraints, and rerank the combined set against the original mixed query. Return passages with language and source location. If the strongest evidence is an English runbook and an Arabic incident note, an answer can explain the relationship, cite each source in its original language, and say when they describe separate facts. It should not claim that one source proves the other. If the evidence conflicts on the deploy timestamp, show both dates and the document versions rather than silently choosing one.

Worked example 2: a policy question with an identifier

Imagine an employee asks: “هل أحتاج موافقة إضافية لتغيير S3 lifecycle rule؟” A naïve translator may produce an awkward rendering of “lifecycle rule,” while a pure Arabic analyzer may not recognize the AWS term. Build an alias map for approved domain phrases, linking the exact phrase S3 lifecycle rule to the Arabic policy vocabulary used internally. Search the canonical identifier in a keyword field, the Arabic words in an Arabic field, and a vector representation across both.

Assume the Arabic policy page says that a retention change requires owner approval, while the English cloud runbook describes where to edit the rule. The retrieval system should return both because one answers the permission question and the other identifies the operational surface. The answer should distinguish policy authority from implementation instructions. If the policy page is older than the approved version, version metadata and freshness rules should demote or exclude it; translation quality cannot repair stale evidence.

The same approach works for code and product names. For “كيف أجد خطأ PAY-204 في service-api؟”, keep PAY-204 and service-api in exact-match fields, search the Arabic words lexically, and use a multilingual vector lane for paraphrases such as “تعذر إتمام الدفع”. A result may connect the error catalog to an Arabic support guide, but the system must keep the exact error record attached to its ID and version.

Make language and script quality measurable

Build a reviewed evaluation set whose query and evidence languages are labelled independently. Include four combinations—Arabic query/Arabic evidence, Arabic/English, English/Arabic, and English/English—plus mixed-script questions. Add diacritized and undiacritized forms, common spelling variants, numbers in Arabic-Indic and Latin forms when present, transliterated names, code identifiers, and questions containing negation. Use realistic examples from authorized corpora, remove personal data, and have bilingual reviewers check relevance judgments.

Measure recall at the retrieval cutoff, mean reciprocal rank, and nDCG for each language pair. Also measure the cross-language gap: compare retrieval quality when query and evidence languages differ with matched-language cases. Inspect results by topic and source, not only one overall average. Then examine actual retrieved passages and citations. A system can retrieve the right general topic but omit the sentence needed to support an answer.

Separate retriever failures from generation failures. If relevant evidence was never retrieved, rewriting the answer prompt will not fix the retrieval stage. If the passage is present but the answer ignores an Arabic qualifier or English exception, inspect context assembly and generation. Preserve a trace containing query variants, lane, candidate ranks, fusion result, selected passage IDs, language labels, versions, ACL decisions, and citation locations. Store only the user data needed for diagnosis and apply retention controls.

Evaluation should include negative and adversarial cases as well as known positives. Include near-duplicate documents in both languages, outdated translations, a relevant-looking passage with the wrong product version, and exact identifiers that should not match a similar one. Ask reviewers to mark not only relevance, but also whether a passage is sufficient evidence for the expected answer. This catches systems that retrieve a generally related page yet miss a crucial exception.

A production checklist

Start with the original corpus and a bilingual query sample. Keep original text immutable; create versioned normalized copies. Use Arabic-aware lexical analysis for Arabic fields, English analysis for English fields, and keyword treatment for identifiers. Add multilingual vectors as a separate candidate path. Consider query translation as one controlled lane rather than a replacement. Retrieve balanced candidates, fuse them with a method that does not assume raw scores are comparable, and rerank against the original query. Apply authorization consistently before results leave the retrieval service.

Finally evaluate every query-document language pairing and representative mixed queries. Watch for answerable Arabic documents lost behind a larger English index, English identifiers broken by linguistic processing, and translations that change meaning. Keep source language visible and preserve citations to the original passage. The system succeeds when it retrieves the right evidence across languages and explains where that evidence came from—not when all text has been converted to one language.

References

YOUR TAKE

What did you think?

Choose one reaction for this article.

Was this useful?

A cookie helps limit repeat responses. Your feedback is private.

Share this noteLinkedIn ↗X ↗Email ↗

Keep exploring.