RAG with Thai Documents: Common Problems and How to Fix Them
Thai has no spaces between words, so RAG fails in ways English doesn't. Common problems from word segmentation and chunking to transliterated terms, with fixes.
Your team followed an English RAG tutorial step by step, and it answers well on English documents. But once you load a Thai handbook, search starts missing things and answers land on the wrong topic. This isn't because the team did something wrong. It's because of the nature of the Thai language itself, which most tools were not originally designed for.
Why Thai is hard for RAG
The paper PyThaiNLP: Thai Natural Language Processing in Python (2023) explains that Thai, in its common written form, runs on without spaces or marks between words or between sentences. Word and sentence boundaries are therefore unclear, and grammar alone often cannot resolve the ambiguity. Systems designed around languages with spaces between words stumble at the very first step.
Problem 1: Word segmentation
Keyword search such as BM25 needs to know what a "word" is. If the system can't segment Thai, a query like "how many days of maternity leave" may be treated as one block of text and fail to find the document that uses a more formal phrase for leave to give birth.
Fixes
- Use a Thai word segmenter, such as PyThaiNLP, which offers several algorithms with NewMM, focused on speed, as the default. Use the same method when building the index and when searching.
- Add company-specific terms to the dictionary, such as product names, department names and internal abbreviations.
- Use hybrid search so semantic search can help when segmentation goes wrong.
Problem 2: Chunks cut mid-sentence
Many text splitters use full stops or line breaks as cut points, but Thai does not use full stops to end sentences, and it uses spaces both to end sentences and to separate phrases. Chunks are therefore easily cut in the middle of an idea.
Fixes
- Chunk by document structure, such as headings, clauses and paragraphs, rather than character count alone.
- Use overlap between chunks and put the heading at the front of every chunk.
Problem 3: Transliterations and mixed languages
Thai company documents often mix several spellings of "email" in Thai script with the English word "email", or use "OT" alongside the Thai term for overtime pay. Employees ask one way while documents say it another.
Fixes
- Choose a multilingual embedding model, such as BGE-M3, which BAAI says supports more than 100 languages.
- Build a company glossary of synonyms and use it to expand queries before searching.
Problem 4: Garbled text from PDFs
With some Thai PDFs, extracted text can have vowels and tone marks in the wrong positions or odd characters, depending on the font and how the file was created. Scanned files must first go through OCR that can read Thai.
Fixes
- Always spot-check extracted text by eye before adding it to the library.
- If it is badly garbled, use the source file (Word or Google Docs) instead, or OCR trained on Thai.
- Convert Thai numerals to Arabic numerals, and standardise on either Buddhist Era or Common Era years.
An example from a Thai organisation
A private hospital built RAG so nurses could search internal guidelines. In the first round, a nurse typed the everyday Thai phrase for "patient is allergic to a drug, how do I report it?", but the system found nothing, because the documents used the formal term for "adverse drug reaction" and the abbreviation "ADR". The team added a glossary mapping ward language to formal terms, added a Thai word segmenter to keyword search, and chunked documents by heading instead of character count. Search results improved without changing the language model at all.
Watch out for
- Don't trust English benchmark scores. A model that excels in English may do poorly in Thai.
- Every word segmenter makes mistakes, especially with proper names and new words. Test with your own documents.
- Your test questions must be written the way Thai employees really ask, including casual language, abbreviations and misspellings.
Most tools weren't designed for Thai, so we have to design for Thai ourselves.
How to get started
- Collect at least 30 real Thai questions from employees, including casual phrasing and transliterated terms.
- Check the quality of text extracted from PDFs before doing anything else.
- Choose multilingual embedding models and compare them using that question set.
- Add a Thai word segmenter and a company glossary to keyword search.
- Re-measure after every change, and add missed questions to the test set.
If many of your documents are scans, read Document AI: extracting data from PDFs and scanned documents next. And to learn which AI models handle Thai well, read Claude AI and the Thai language on Plants.work.