Table of Contents
To handle documents that mix Arabic, French and English, treat language as something to manage at every stage: OCR with all three languages loaded, normalise Arabic spelling and digits before indexing, combine a cross-lingual embedding model with per-language keyword search, choose a language model that officially supports all three, and test each language combination separately.
Key takeaways
- Language mixing happens at three levels: across documents, inside one document, and inside one sentence. Each level breaks a different part of the pipeline.
- Keyword search does not cross languages. In the BGE-M3 paper's cross-lingual test, BM25 found an answer passage in the top 100 for 18.9% of Arabic questions against English text, against 71.5% for the multilingual embedding model (Chen et al., 2024).
- Arabic text needs normalisation of hamza forms, teh marbuta, alef maksura, diacritics and tatweel (Apache Lucene), and digits need converting to 0 to 9.
- Model cards differ: Llama 3.1 lists eight supported languages and Arabic is not one of them (Meta), while Llama 4 lists both Arabic and French (Meta).
- Language models sometimes answer in the wrong language, more often with complex prompts and high sampling temperatures (Marchisio et al., 2024). Test answer language explicitly.
Why do industrial documents in Algeria mix three languages?
Algeria's constitution makes Arabic the national and official language, and Tamazight also a national and official language (Constitution of 2020, Articles 3 and 4); check with counsel which language a given document must use. Industrial document libraries are usually more mixed than that. Equipment manuals often come from the manufacturer in English, internal procedures and reports are often written in French, and correspondence, forms and shift notes may be in Arabic. Our guide to RAG for maintenance manuals gives this as one of the main pitfalls of a basic setup.
The mixing happens at three levels, and each one needs a different fix.
| Level | Example | What breaks | What to do |
|---|---|---|---|
| Across documents | English OEM manual, French procedure, Arabic report on the same pump | An Arabic question does not find the French procedure | Cross-lingual embeddings plus keyword search per language |
| Inside a document | Arabic cover page and headings, French body, English data tables | OCR with one language loaded; one analyser for the whole file | OCR with all three languages; detect language per paragraph |
| Inside a sentence | A shift note such as "تم تغيير الـ joint d'étanchéité على المضخة P-201" | Tokenisation, stemming and display order of the Latin parts | Keep identifiers as exact tokens; isolate Latin runs when displaying |
How do you OCR pages that mix Arabic and Latin script?
Load all the languages you expect. Tesseract accepts several languages at once with -l followed by language codes joined by +, such as ara+fra+eng, and its documentation notes that both processing time and output can change with the order of the languages (Tesseract documentation). Try more than one order on a sample of your own pages.
Expect Arabic to be the weak point. The KITAB-Bench authors cite Arabic's cursive script and right-to-left flow as specific difficulties, and on their PDF-to-Markdown task the best model tested reached only 65% accuracy (Heakl et al., 2025). For mixed pages, the practical rules are:
- Keep a link from every extracted passage to its page image, so users can check the original.
- Check numbers, units and tags by hand on a sample, because these are the values technicians act on.
Why do numbers and equipment tags go wrong in Arabic text?
Two sets of digits. Unicode encodes Arabic-Indic digits (U+0660 to U+0669) and a second, extended set (U+06F0 to U+06F9) separately from the European digits 0 to 9, and notes that European digits are used even in many Arabic-speaking countries in North Africa (Unicode Standard, chapter 9). A corpus can therefore hold the same pressure value as "١٢" in one document and "12" in another. In the search index, convert all digits to 0 to 9. Elasticsearch's decimal_digit filter, for example, converts every Unicode decimal digit to 0 to 9 (Elastic documentation). Keep the original text for display and citation.
Decimal separators differ too: French writes 4,5 bar and English writes 4.5 bar. Normalise them in a separate numeric field if users search by value.
Display order. Arabic is displayed right to left, while tags such as P-201 and units such as kPa run left to right. The Unicode Bidirectional Algorithm decides the display order, and its specification acknowledges that implicit ordering is sometimes not enough to produce comprehensible text, which is why it defines directional formatting characters (Unicode UAX #9). In an Arabic interface, test answers that contain tags, ranges and units, and isolate Latin runs and numbers so that they are not displayed in the wrong order.
How should Arabic and French text be normalised before indexing?
Keyword search only matches what is spelled the same way. Arabic allows several spellings of the same word. The Arabic normaliser in Apache Lucene, the library underneath search engines such as Elasticsearch, maps hamza on alef to bare alef, teh marbuta to heh and alef maksura to yeh, and removes diacritics and the tatweel stretching character (Apache Lucene).
French has its own issues: elided articles such as l' and qu' attach to the next word. Elasticsearch's built-in analysers handle both. Its Arabic analyser chains lowercase, digit conversion, stop words, Arabic normalisation and a stemmer; its French analyser starts with an elision filter and uses a light stemmer (Elastic documentation).
To apply the right analyser, you need to know each passage's language:
- Detect language per paragraph or per chunk, not per file. fastText's language identification models recognise 176 languages, and the compressed version is about 917 kB (fastText). Note their Creative Commons Attribution-ShareAlike 3.0 licence.
- Index each chunk with the analyser for its main language, and index mixed chunks under both.
- Keep a separate exact-match field without stemming for part numbers, tags and fault codes.
- Apply exactly the same normalisation to the user's question at query time.
Should you translate the documents or search across languages?
| Approach | How it works | Strengths | Limits |
|---|---|---|---|
| Cross-lingual embeddings | One multilingual model places questions and passages from different languages in the same vector space | No translation step; originals stay the reference | Weak on exact strings; test on your own vocabulary |
| Query translation or glossary expansion | The question is translated or expanded with equivalent terms before keyword search | Keyword search then works across languages | A wrong translation of a technical term misses the document |
| Translation at indexing | Documents are machine-translated and the translations indexed beside the originals | One language for search and review | Cost and errors on technical terms; licence and confidentiality of the translation model |
Keyword search alone does not cross languages. In the cross-lingual MKQA test reported with BGE-M3, where questions in 25 languages must retrieve English passages, BM25 reached a recall at 100 of 18.9% for Arabic questions and 45.3% for French ones, while BGE-M3 combining its dense, sparse and multi-vector modes reached 71.5% and 76.6% (Chen et al., 2024).
If you translate, check the licence. Meta's NLLB-200 model card, for example, gives a non-commercial CC BY-NC 4.0 licence, describes it as a research model not released for production, and lists domain-specific texts and document translation as out of scope, with training inputs of no more than 512 tokens (NLLB-200 model card).
A sensible default is hybrid: multilingual embeddings for meaning, per-language keyword search for exact identifiers, and a small trilingual glossary of your own equipment and process terms (pompe, مضخة, pump) to expand questions.
Which language model can answer in all three languages?
Read the model card, not the marketing page. As checked in November 2026, Meta lists eight supported languages for Llama 3.1 (English, German, French, Italian, Portuguese, Hindi, Spanish and Thai), treats other languages as out of scope, and "strongly discourage[s]" using it to converse in them (Llama 3.1 model card). The Llama 4 card lists Arabic, French and English among twelve supported languages (Llama 4 Scout model card). Our post on choosing an open-weight LLM covers the other criteria.
Then check two things:
- Token cost per language. The same text can produce very different numbers of tokens depending on the language, up to 15 times in some cases (Petrov et al., 2023). Measure Arabic, French and English samples with the candidate's tokenizer before sizing hardware, as described in our GPU sizing guide.
- Answer language. Researchers call the failure to answer consistently in the user's language "language confusion". Their benchmark covers 15 languages, including Arabic and French; among the models tested in 2024, Llama Instruct and Mistral models showed high levels of it. Confusion grew with complex prompts and high sampling temperatures, and was partly reduced by few-shot prompting and multilingual fine-tuning (Marchisio et al., 2024). State the answer language in the instructions and keep the temperature low.
See also fine-tuning vs RAG and our post on Arabic industrial terminology.
How do you test a trilingual document assistant?
Build the test set as a grid of question language by document language, and score each cell.
- Collect real questions from technicians and engineers in Arabic, French and English, including mixed questions such as an Arabic sentence with a French part name.
- For each question, record the correct passage, its language, and the expected answer language.
- Include values written with both digit forms, tags with and without hyphens, and questions whose answer is not in the documents.
- Measure retrieval recall per cell of the grid (Arabic question to French document, French question to English document, and so on).
- Check that every answer is in the expected language and that quoted values match the source exactly.
- Have a fluent engineer review Arabic and French terminology on a sample of answers.
- Re-run the full grid after any change to OCR, normalisation, embeddings, model or prompt.
Our guide to evaluating an LLM on your own documents covers scoring methods in more detail.
What we have seen at KABAS AI
DALILE, our AI knowledge assistant, runs on the client's own servers and answers from documents, spreadsheets and databases with exact sources. Running on-premise has a direct consequence for multilingual documents: OCR, language detection, normalisation, embeddings and any translation must all run locally too. A confidential French procedure cannot be sent to a cloud translation API just to make it searchable in Arabic, and every local model in the chain, including the translator, needs a licence that allows your use.
ADFC (Sonatrach Group) and ENAD Shymeca, two clients that use our Virtual Lab, are exploring integration with DALILE to improve knowledge discovery, and in ADFC's case technical documentation (ADFC case study, ENAD Shymeca case study).
Our advice is to begin with a language inventory: which document families exist in which language, who writes new ones, and in which language people ask questions. That inventory decides the OCR settings, analysers, glossary and test grid. Our agentic AI service deploys DALILE and connects it to your document management systems and databases.
Sources
- Chen et al., M3-Embedding: Multi-Linguality, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillation (arXiv 2402.03216, 2024)
- Apache Lucene, ArabicNormalizer documentation
- Meta, Llama 3.1 8B Instruct model card (Hugging Face)
- Meta, Llama 4 Scout 17B-16E Instruct model card (Hugging Face)
- Marchisio et al., Understanding and Mitigating Language Confusion in LLMs (arXiv 2406.20052, 2024)
- Constitution of Algeria, 2020 (Constitute Project)
- Tesseract documentation, Command line usage
- Heakl et al., KITAB-Bench: A Comprehensive Multi-Domain Benchmark for Arabic OCR and Document Understanding (arXiv 2502.14949, 2025)
- The Unicode Standard, Version 18.0, Core Specification, chapter 9
- Elastic documentation, Decimal digit token filter
- Unicode Standard Annex #9, Unicode Bidirectional Algorithm
- Elastic documentation, Language analyzers
- fastText, Language identification
- Meta, NLLB-200 distilled 600M model card (Hugging Face)
- Petrov et al., Language Model Tokenizers Introduce Unfairness Between Languages (arXiv 2305.15425, 2023)
Frequently asked questions
Should we translate all our documents into one language before indexing them?
Usually not as a first step. A cross-lingual embedding model lets an Arabic question find a French or English passage without translating the corpus, and the original text stays the reference. Translation at indexing time can help for a small set of key documents, but it needs a model whose licence allows production use and a glossary for technical terms.
Can an assistant answer in Arabic from a French or English document?
Yes. Retrieval finds the passage in its original language and the language model writes the answer in the language of the question. Keep the cited passage in its original language next to the answer, so the reader can check values and terms against the source.
Why does search miss Arabic words that are clearly in the document?
The usual causes are spelling variants and OCR errors. The same word can be written with different hamza forms, with or without diacritics, or with a stretching character, so normalise Arabic text the same way at indexing and at query time. Then check a sample of the OCR output by hand.
How should Arabic-Indic and Western digits be handled?
Unicode encodes Arabic-Indic digits separately from 0 to 9, so the same value can be stored in two forms. Convert all digits to 0 to 9 in the search index so that queries match either form, and keep the original text for display and citations.
Which language should the assistant answer in?
In the language of the question unless the user asks otherwise, stated explicitly in the instructions given to the model. Language models sometimes switch language on their own, so check the answer language in your tests and quote source passages in their original language.
Does the assistant need to understand Algerian Darija?
It depends on your documents. Formal manuals and procedures are mostly written in Modern Standard Arabic, French or English, while informal notes and messages may contain Darija mixed with French. The model cards cited here list Arabic without naming dialects, so test candidate models on samples of your own notes.



