// How-to · Build RAG and process documents
RAG retrieves the wrong passages: how to debug
First find which stage fails: parsing, chunking, retrieval or generation. Measure with a fixed question set, then improve one stage at a time.
verified 2026-10-102 official sources
Scenario: Build RAG and process documents →
Symptoms
- The answer is in the documents but the model says it cannot find it
- Retrieved chunks are unrelated to the question
Common causes
- Poor parsing has already garbled the text
- Chunks are too small or too large, cutting the answer apart
- Vector-only search recalls names and IDs poorly
- No reranking, so the best chunks are not at the top
How to fix
- Spot-check chunks: the text should be clean and each chunk should make sense on its own
- Chunk by document structure (headings, paragraphs) with modest overlap
- Use hybrid retrieval: keyword (BM25) plus vectors, then a reranker (e.g. BGE reranker)
- Prepare 30–50 questions with reference answers and evaluate retrieval and answers with a tool such as Ragas after every change
- The vector store is rarely the main issue; if you already run Postgres start with pgvector, move to a dedicated store at scale
Official references
Compiled from official documentation and public discussions on 2026-10-10; not yet reproduced in our own environment. Follow the official docs if they differ.