Skip to main content

How to build a RAG corpus with AI

Guide · about 8 min · refs checked 2026-11-19 (reference links and dates only)

RAG quality is mostly corpus quality, not model quality. Decide what to collect, how to chunk and how to test first.

How to
Define the question domain and refusal boundary: what must be answered, what must be “I don’t know”; only collect content that supports those. Denoise documents (headers, footers, ads, navigation), keep heading hierarchy and source URL; OCR scans first. Chunk by semantic structure, not fixed length; attach document title, section path and source link to each chunk. Generate searchable questions/summaries per chunk but keep the original text: retrieve with questions, answer with originals. Build a small eval set: real questions, gold answers, must-cite documents; rerun on every chunker or model change. Retire stale documents with version and deletion records; never let old and new policies be retrieved together.

Example and interpretation

A teaching scenario, not a measured or executed site test.

Take 20 product docs, strip headers/footers, chunk by section with title and URL, then test 10 real questions for hit rate and citation, recording which question types must be refused.

How to check your practice

Explain the example in your own words, inspect input constraints, then verify against the source. Revisit concepts if you cannot explain why; supply missing dates, fields or permissions; withdraw unsupported conclusions.

For this topic, start with concept confusion · See all six scenarios and their reasoning

Sources
  • LlamaIndex documentation ↗
  • OpenAI File Search ↗