Why an AI Chatbot gives wrong answers from PDF files: the OCR, Data Cleansing and Chunking to do first
Inspektion engineering team · Published 4 December 2026 · Last updated 4 December 2026
Scanned PDFs are images AI cannot read, and Thai OCR leaves misplaced vowel marks and broken tables. Without cleansing and careful splitting, AI finds the wrong text and answers wrongly.
IllustrationSummary
- A PDF from a scanner is an image of the paper page. It must go through OCR before the system can search for words or let AI read the content.
- Raw Thai OCR output often has misplaced vowel or tone marks, tables broken into separate lines, and header text repeated on every page. This makes the system retrieve the wrong text or find nothing.
- A RAG system answers from the text it retrieves. If the source text is wrong or cut off in the middle of a table, the answer is wrong too, no matter how capable the language model is.
- OCR alone is enough for printed documents that you only need to search. If they contain tables, forms or handwriting, or you want AI to answer questions, add data cleansing with human review.
Short answer
An AI Chatbot gives wrong answers because the data it receives is wrong at the source. A scanned PDF is an image with no text. Unchecked Thai OCR has wrong characters and broken tables. And splitting data by length separates tables from their headings. Fix 3 stages before loading anything: OCR, cleansing and structuring, then splitting the data while keeping its context.
A scanned PDF is an image, not text
A PDF from a scanner stores an image of the paper page. If you try to select text or search for a word and nothing is found, the file has no text layer. An AI system that receives this kind of file must first convert the image into text itself. It usually does this with generic OCR that is not tuned for Thai, and nobody checks the result.
OCR quality depends on scan quality. Skewed, dark, shadowed or low-resolution images cause more reading errors [1]. Old documents in the cabinets of agencies and factories often have these problems, such as yellowed paper, faded ink, or photocopies of photocopies.
Common problems in Thai OCR and their effect on AI answers
Problems from raw OCR and the service level that fixes them
| Problem | Effect on AI | Fixed at level |
|---|---|---|
| Vowels and tone marks misplaced or out of order | Misspelled words do not match search terms, so the system cannot find the right document | L2 (AI corrects words + human review) |
| Tables broken into lines of text | Numbers lose their column headings, so AI matches values to the wrong headings | L2 (tables rebuilt as Markdown, CSV or JSON) |
| Headers, footers and page numbers repeated on every page | Repeated text takes up space in search results and pushes out the parts with real content | L2 (repeated text removed, paragraphs arranged) |
| Stamps over text and handwriting | Unreadable, or read as different characters | L2 hard level (every page checked and corrected again) |
| Scanned images with no text layer | Words cannot be searched at all | L1 (scanning and OCR, or OCR only) |
Our raw OCR output for printed Thai documents is about 95–98 percent accurate. That sounds high, but 1 page has a lot of characters. The remaining errors are spread across proper names, numbers and tables, which are the parts users ask about most.
Wrong data in, wrong answers out: how a RAG system works
Most enterprise AI Chatbots use RAG (Retrieval-Augmented Generation). The system first searches the document store for relevant text, then has a language model write the answer from that text [2]. So the model can only answer as well as the text it retrieves. If the source text is misspelled, the system cannot find it. If a table is broken, the model gets numbers without column headings and guesses their meaning.
Sending a long text for the model to read all at once does not solve the problem. Research has found that language models use information in the middle of a long text less well than information at the beginning or end [3]. Selecting correct text that matches the question is therefore more important than sending the whole document.
Chunking by length loses context
Before loading into a Vector Database, the system must split documents into small pieces (Chunks). If it cuts every fixed number of characters, a table may be split in half, headings get separated from content, and pages that give the equipment code get separated from the inspection results. A survey of RAG research states that the way data is split and indexed directly affects retrieval quality [4].
- Keep each table in a single Chunk, or attach the column headings to every part
- Attach the heading, document name, page number and labels, such as document type or equipment code, to every Chunk
- Split by document structure, such as headings, clauses or one report each, instead of by length alone
- Test with real questions before going live to see whether the system finds the right documents (Retrieval Evaluation)
Feeding scanned PDFs straight into AI
- The file is an image, so the system runs its own OCR with no human check
- Misplaced vowel marks and misspelled words that cannot be found
- Broken tables, numbers without column headings
- Headers repeated on every page crowd the search results
- Data cut into pieces by length, tables split in half
OCR, cleansing and splitting the data first
- A text layer, with low-confidence pages flagged
- AI corrects words and humans review
- Tables rebuilt as Markdown, CSV or JSON
- Repeated text removed, labels added by document type
- Split by document structure, retrieval tested
Summary: The quality of AI answers depends on the quality of the data you put in
Where L1, L2 and L3 fix the problem
Paper-to-Knowledge service levels (prices exclude VAT)
| Level | What it fixes | Delivered as | Starting price |
|---|---|---|---|
| L1 Scanning and OCR | Turns images into text, spot-checks about 10 pages in every 100 pages, and flags low-confidence pages | Markdown, Text or Searchable PDF | 5 THB per page (minimum 500 THB), or 3 THB per page if you already have PDFs |
| L2 Cleansing and structuring | Fixes misplaced vowel marks, removes headers and footers, rebuilds tables, adds labels, with human review | Markdown, CSV or JSON | Add 8 / 15 / 30 THB per page (easy / medium / hard) |
| L3 Knowledge base for AI | Designs how data is split, creates Embeddings, loads data into a Vector Database and tests retrieval | Ready-to-use database and a test report | One-time setup 20,000–50,000 THB, plus 3 THB per page for data import |
Prices drop with volume. See the full rate table for all volume ranges on the service page.
After L2, which includes human review, we guarantee accuracy of 99 percent or higher, with every table cell complete. The medium level, for tables and standard forms, checks every page. The easy level, for plain text, spot-checks 20–30 pages in every 100 pages. See the details and calculate a price on the Paper-to-Knowledge service page.
When OCR alone is enough, and when you need data cleansing
OCR alone (L1) is enough when
- The documents are printed text with no important tables
- You want to search for files or words in the documents, then open and read the originals yourself
- You can accept that some words may be misspelled, and that some pages are flagged by the system for checking
Add L2 when
- The documents have tables, forms, numbers or codes that must be correct in every cell
- There is handwriting, stamps over text, or old paper with faded ink
- You will analyze the data, load it into other systems, or have AI answer questions from the documents
Checklist before loading documents into an AI Chatbot
- Try searching for a word in the file. If nothing is found, the file is still an image and needs OCR first
- Open the OCR output of several random pages from each document group. Check vowels, tone marks, numbers and proper names
- Check that tables are still in table form and that every cell value matches its column heading
- Remove repeated headers, footers and page numbers
- Label documents, for example by type, year, agency or equipment code
- Split data by document structure, and do not cut tables in the middle
- Prepare real user questions with correct answers to test retrieval before going live
- Check that confidential documents are not accidentally sent for processing on a public Cloud
Read next
An example from a real project
In a maintenance history search system for a refinery, we organized about 2,000 PDF reports by equipment code before loading them into the Q&A system. This lets each answer cite the source report, which engineers can open and check. Read the details in the AI maintenance history search case, and see the Q&A system that uses this data at Enterprise KM Chatbot.
Frequently Asked Questions
Why does an AI Chatbot give wrong answers from Thai PDFs?
The main cause is usually the source data. A scanned PDF is an image that needs OCR first. Unchecked Thai OCR output has misplaced vowel marks, broken tables and repeated text. So the system retrieves the wrong text or finds nothing, and the language model then writes its answer from that text.
What is the difference between OCR and Data Cleansing?
OCR turns an image of a page into text. Data Cleansing corrects that text, removes repeated text, rebuilds tables and adds labels. Our L2 service combines AI with human review, and we guarantee accuracy of 99 percent or higher after review.
What is Chunking, and why does it matter for a RAG system?
Chunking is splitting documents into small pieces before loading them into a Vector Database. If the split cuts through a table or separates headings from content, the system retrieves data without its context. Split by document structure, attach headings and labels to every piece, then test with real questions.
Which documents need only OCR?
Printed text documents with no important tables, where you only need to search for files and then open and read the originals yourself. L1 starts at 5 THB per page, or 3 THB per page if you already have scanned PDFs. If there are tables, forms or handwriting, or you want AI to answer questions, add L2.
References
- [1]
Improving the quality of the output — Tesseract OCR documentation
- [2]
Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks — arXiv (Lewis et al., 2020)
- [3]
Lost in the Middle: How Language Models Use Long Contexts — arXiv (Liu et al., 2023)
- [4]
Retrieval-Augmented Generation for Large Language Models: A Survey — arXiv (Gao et al., 2023)







