RAG Retrieval Troubleshooting: Why Only 2-3 Chunks Are Returned From a Large Knowledge Base

    This article explains why a RAG pipeline retrieves only two or three chunks even when a knowledge base holds dozens or hundreds of documents. It clarifies that the model never reads the knowledge base directly, then walks through six common root causes—chunk size and chunk count, embedding model and index mismatch, an overly strict similarity threshold, the combined squeeze of Top-K and context budget, overly narrow metadata filters, and incomplete index builds or failed writes. A four-step observable retrieval flow and a recommended troubleshooting order help turn vague "inaccurate results" into comparable metrics, followed by engineering practices such as observability, externalized parameters, an evaluation set, hybrid retrieval, and elastic cloud resources.

    1. Symptom and Problem Scope

    When building a local knowledge Q&A system by calling a cloud LLM API through an AI coding tool or a desktop client, one of the most frequent complaints is this: the knowledge base clearly holds dozens or even hundreds of imported documents, yet after every question the model only “sees” two or three fragments, and the coverage of the answer is obviously insufficient. Many people’s first reaction is that the model is not capable enough or that the API has a bug. But from how retrieval-augmented generation (RAG) actually works, the vast majority of cases are not model problems at all—the retrieval chain has already compressed the candidate set down to a tiny size at the recall stage.

    One conceptual boundary needs to be clear first: the LLM does not read the knowledge base directly. The real flow is that documents are first split into chunks, the chunks are vectorized and written into a vector store; when a question comes in, it is vectorized the same way, a similarity search is run against the vector store, a number of chunks are retrieved, and those chunks are stitched into the prompt and handed to the model. So “only two or three documents were read” actually means “only two or three chunks were recalled,” and the problem almost certainly lies in chunking, embedding, retrieval parameters, or filter conditions.

    2. Six Common Root Causes

    2.1 Chunk Size and Chunk Count

    If the chunk length is set too large (for example, over a thousand tokens per chunk), a long document may be split into only two or three pieces, so recalling two chunks amounts to covering the “entirety” of two documents—which naturally looks like “only two or three.” Conversely, chunks that are too small break up semantics and lower the relevance of what gets recalled. A good starting point is 300–800 tokens for a comparison experiment, keeping 10%–20% overlap so answers are not cut off at boundaries.

    2.2 Embedding Model and Index Mismatch

    Document ingestion and querying must use the same embedding model, the same dimensionality, and the same normalization scheme. If the model or the dimension is changed midway, similarity computation becomes distorted and the ranking degrades, which shows up as “always hitting the same two or three.” Embedding models also differ greatly in semantic granularity, and mixing a long-text model with a short-text model will significantly hurt recall quality.

    2.3 An Overly Strict Similarity Threshold

    Many implementations ship with a minimum similarity threshold by default. When that threshold is too high, it blocks a large number of relevant chunks and leaves only two or three “absolutely safe” results. The threshold should be exposed as a tunable parameter: set it to 0 first and observe the recall count, then raise it gradually to find the balance point between precision and coverage.

    2.4 The Double Squeeze of Top-K and Context Budget

    Top-K determines how many candidates are pulled back, while the context window determines how many chunks can actually fit into the prompt. If Top-K is set to 3, or if the system prompt and conversation history consume the whole budget, the remaining space only holds two or three chunks. The two need to be tuned together, and compressing conversation history should take priority over compressing knowledge chunks.

    2.5 Overly Narrow Metadata Filters

    Filters by document type, time, tag, or permission can shrink the candidate pool first if too many conditions are stacked, leaving nothing to retrieve from. It is better to verify filters and similarity search separately, and first confirm the total candidate count after filtering.

    2.6 Index Not Fully Built or Writes Failed

    After a bulk import, the index may still be building in the background, some documents may have failed vectorization, or the collection may point at the wrong store—all of which lead to “documents exist in the store but cannot be retrieved.” This is an engineering-state problem that needs logging services and monitoring alerts to confirm write and index status.

    3. A Systematic Troubleshooting Flow

    1. # Illustration: break retrieval into four observable steps
    2. chunks = split(docs, size=500, overlap=80) # 1. Check the total chunk count
    3. vectors = embed(chunks, model=EMBED_MODEL) # 2. Confirm model and dimension consistency
    4. candidates = index.search( # 3. Turn the threshold off first
    5. query_vector=embed(query, model=EMBED_MODEL),
    6. top_k=20, threshold=0.0,
    7. filters=None
    8. )
    9. final = [c for c in candidates if c.score >= 0.35][:8] # 4. Then tighten threshold and K

    The recommended order is: total chunk count → vector dimension and model consistency → candidate count after filtering → recall with the threshold off → gradually tune Top-K and the threshold → finally check how the context budget is allocated. Record the recall count and hit rate at every step, and only then does a vague “feels inaccurate” turn into data you can compare.

    4. Engineering Recommendations

    • Observability first: instrument the retrieval chain to output candidate count, score distribution, and the number of chunks finally injected, and pair it with logging and monitoring alerts to locate anomalies.
    • Externalize parameters: chunk length, overlap, Top-K, threshold, and filter conditions should all be external configuration items that can be switched per scenario.
    • Evaluation-set driven: prepare 30–50 real questions with their reference answer chunks, and use recall and hit rate for regression so you are not tuning by feel.
    • Hybrid retrieval as a fallback: vector search is insensitive to proper nouns and identifier-like content, so layering keyword search and fusing the rankings can improve long-tail recall.
    • Elastic cloud resources: rebuilding an index in bulk is a high-load operation, so container platforms and message queues can be used to run it asynchronously and smooth out spikes, with object storage holding the original documents and index snapshots.

    5. Conclusion

    “Only two or three documents were read” is almost never the model’s fault, but an engineering detail in retrieval parameters and data preparation. Quantify and verify the five stages—chunking, embedding, filtering, Top-K, and context budget—one by one, and the hit rate usually improves markedly. If a managed option is needed, the general retrieval and vector capabilities offered by cloud vendors such as Baidu AI Cloud can serve as a reference for implementation, but the tuning methodology itself is platform-agnostic.