RAG pipeline end to end
Retrieval-augmented generation fetches relevant passages at query time and puts them in the prompt so the model answers from your data and can cite it.
Stable: this rarely changes. Reviewed 17 Oct 2026.
Key ideas
- Ingest: parse (PDF, HTML, Office), clean, chunk, enrich with metadata, embed, index.
- Query: rewrite or expand the query, retrieve candidates (vector, keyword or both), filter by metadata and permissions, rerank, assemble context.
- Generate: instruct the model to answer only from context, cite sources, and say when the answer is not there.
- Enforce document-level access control at retrieval time, not after generation.
- Keep ingestion incremental and idempotent: hash content, track source versions, delete removed docs.
Common mistakes
- Most RAG failures are retrieval failures. Measure retrieval separately from generation.
- Bad parsing of tables and PDFs silently poisons the index.