Skip to content
English

Switch theme

// 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

  1. Spot-check chunks: the text should be clean and each chunk should make sense on its own
  2. Chunk by document structure (headings, paragraphs) with modest overlap
  3. Use hybrid retrieval: keyword (BM25) plus vectors, then a reranker (e.g. BGE reranker)
  4. Prepare 30–50 questions with reference answers and evaluate retrieval and answers with a tool such as Ragas after every change
  5. 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.

Data updated: Problems & errors