Home / RAG / Preparing documents
RAG guide

Preparing documents

If a fact is mangled when a document is converted, no model can find it later. Document preparation is unglamorous and decides most of a RAG system's quality.

Hardest contentTables and scans
KeepHeadings and dates
RemoveOld versions
SyncDaily or on change

What makes documents hard

ContentProblemWhat we do
Tables in PDFsRows and columns get scrambled into a stream of numbersLayout-aware parsing that keeps tables as tables
Scanned formsNo text at all until OCR runsOCR with quality checks; flag pages that cannot be read reliably
SlidesMeaning is in layout and imagesExtract text per slide and keep the slide title with it
Many versionsOld and new policies contradict each otherKeep only current versions searchable, or mark versions clearly
Long documentsA passage loses its contextKeep section headings with each passage

Splitting into passages

  • Split by structure, not by character count. Sections and paragraphs make better passages than fixed-size blocks.
  • Keep passages a sensible size. Typically a few hundred words: big enough to carry meaning, small enough to be precise.
  • Carry metadata. Document title, section, date, owner and permissions travel with every passage.

Keeping it current

  • Sync changed documents daily or as they change, and remove deleted ones from the index the same day.
  • Give every source an owner who is told when their documents produce wrong answers.
  • Often the fastest way to improve answers is to fix the documents themselves.

Want answers from your own documents?

Tell us where the documents live, who should be able to ask, and ten questions people ask today. We will come back with a plain view of what it takes to answer them well, and safely.