What you will learn
- RAG quality depends on source and retrieval quality before generation.
- Chunking must preserve the meaning needed by the question.
- Evaluate retrieval and answer grounding separately.
01
Define the knowledge contract
List the approved sources, owners, freshness expectations, access rules, and questions the system should answer. Decide what it must do when evidence is missing or sources conflict.
RAG should narrow the answer to trusted evidence. It should not create false confidence when the knowledge base is incomplete.
02
Prepare sources carefully
Remove duplicate navigation and boilerplate, preserve titles and section hierarchy, record source identifiers and dates, and attach access-control metadata. Chunk by semantic unit rather than arbitrary character count whenever possible.
Tables, procedures, policies, and code need specialized parsing. Test whether the retrieved chunk retains the conditions and definitions necessary to interpret it.
03
Build the retrieval pipeline
Transform the user question into a useful search representation, apply permission filters, retrieve candidates, and rerank for relevance. Hybrid lexical and semantic search can help when exact product names and conceptual similarity both matter.
Return source metadata with each passage so the model can cite evidence and the user can inspect the original material.
04
Generate grounded answers
Instruct the model to answer only from supplied sources, cite material beside important claims, report conflict, and say when the answer is not supported. Validate citation identifiers and structured fields after generation.
05
Evaluate retrieval and generation
Measure whether the required source was retrieved, whether irrelevant passages were included, whether the answer is supported, and whether citations point to the correct evidence. A good answer with poor retrieval may fail on the next case.
Build test questions from real user needs, including unanswerable questions and permission-sensitive cases.
FAQ
Common questions
Does RAG eliminate hallucinations?
No. It provides evidence, but the model can still misinterpret or go beyond it. Use explicit grounding rules, citations, validation, and evaluation.
How often should documents be re-indexed?
Match indexing to the source’s change rate and business risk. Critical policies may need event-driven updates; stable reference material may use scheduled refreshes.
Turn the method into a reusable instruction.
Explore expert prompts