published fresh until

LlamaIndex: fix wrong or incomplete RAG answers

Summary Inspect candidate evidence, separate ingestion, retrieval, chunking, ranking, and synthesis failures, then compare version-pinned fixes and evaluators on llama-index-core 0.14.25

Not for LlamaIndex SentenceSplitter Chinese punctuation boundaries; see llamaindex-sentencesplitter-chinese-punctuation-boundaries

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Inspect retrieved text with index.as_retriever(similarity_top_k=10).retrieve(q) before changing the answer prompt, then fix the first stage that loses the required fact.

Do first: run python -m pip show llama-index-core and inspect one failing question's candidate chunks alongside the source document: does a candidate contain the complete fact needed to answer? The baseline is llama-index-core 0.14.25, released September 21, 2026. Pin integration versions separately.

q = 'Your failing question'
candidates = index.as_retriever(similarity_top_k=10).retrieve(q)
for hit in candidates:
    print(hit.node.node_id, hit.score, hit.node.get_content())

Core 0.14.25 supports this retrieval call. Save the question, required facts, and candidate IDs.

1. Chunks vanished before they reached the vector store

On core 0.14.25, first account for the indexed chunks if you pass pre-split nodes= into an IngestionPipeline with a docstore, vector store, and DocstoreStrategy.UPSERTS or UPSERTS_AND_DELETE. Srivatsa03's June 25, 2026 reproduction #22133 shows the older path retaining only the last chunk per source document. The August 19 core 0.14.24 release includes the correction; 0.14.25 includes it too.

For that older-version symptom, use 0.14.25 and re-ingest into a fresh collection; upgrading alone cannot recreate omitted vectors. Check a fresh document with several pre-split nodes: compare input IDs, returned IDs from pipeline.run(nodes=nodes), and stored IDs, then retrieve facts from its beginning and middle. A fresh destination avoids unchanged-document skipping; preserve the production store.

2. The full fact exists in a stored chunk, but retrieval misses it

On core 0.14.25, compare index.as_retriever(similarity_top_k=2) with similarity_top_k=10, keeping filters and the query fixed. Use the retrieval evaluation module to record the difference:

from llama_index.core.evaluation import RetrieverEvaluator

retriever = index.as_retriever(similarity_top_k=10)
evaluator = RetrieverEvaluator.from_metric_names(
    ['mrr', 'hit_rate'], retriever=retriever
)
result = evaluator.evaluate(query=q, expected_ids=expected_node_ids)
print(result.metric_dict)

Set expected_node_ids to human-identified relevant node IDs from the current index. Check expected evidence membership and rank across several failures. If absent at both limits, inspect active filters and embedding model/configuration against ingestion before adding a reranker. Hit rate records a relevant hit, not coverage of every subquestion; track required facts too.

3. Retrieved chunks split the fact or omit its qualification

On core 0.14.25, inspect the actual nodes produced by the SentenceSplitter, then build a separate comparison index:

from llama_index.core.node_parser import SentenceSplitter
from llama_index.core import VectorStoreIndex

splitter = SentenceSplitter(chunk_size=512, chunk_overlap=50)
nodes = splitter.get_nodes_from_documents(documents)
comparison = VectorStoreIndex(nodes, embed_model=embed_model)

Keep the corpus and embedding model fixed; change one splitting parameter at a time. The 0.14.25 splitter source exposes chunk_size, chunk_overlap, and tokenizer. 512/50 is an experiment; respect the embedding limit.

Check: inspect boundary chunks for the complete fact plus its exception, then repeat retrieval evaluation. Relabel expected node IDs after splitting. Do not append the comparison chunks to the original collection. vecorro's August 6, 2024 report #15180 on 0.10.58 also illustrates that a splitter's token count can disagree with the embedding model's limit; inspect the embedder's input with its own tokenizer. It does not establish a 0.14.25 defect. For Chinese punctuation boundaries specifically, see llamaindex-sentencesplitter-chinese-punctuation-boundaries.

4. A good candidate is present but irrelevant chunks win

On core 0.14.25, compare a reranked candidate pool using the official example:

from llama_index.core.postprocessor import SentenceTransformerRerank

rerank = SentenceTransformerRerank(
    model='cross-encoder/ms-marco-MiniLM-L-2-v2', top_n=3,
    keep_retrieval_score=True, trust_remote_code=False
)
engine = index.as_query_engine(
    similarity_top_k=10, node_postprocessors=[rerank], response_mode='no_text'
)
probe = engine.query(q)
for hit in probe.source_nodes:
    print(hit.node.node_id, hit.score)

Install torch and sentence-transformers in the project environment if absent and record their resolved versions. The 0.14.25 implementation keeps the original score in retrieval_score metadata when requested and uses a 512-token cross-encoder maximum length. Long chunks can therefore hide evidence beyond the reranker's input window.

Check the postprocessed IDs against the expected evidence before restoring synthesis. Keep reranking only if evidence retention improves enough to justify latency. A reranker only reorders the retrieved pool; it cannot recover missing candidates. Choose a model suitable for the corpus language.

5. Context contains the answer, but synthesis loses or invents facts

On core 0.14.25, compare synthesis with the same saved candidates, using get_response_synthesizer(response_mode='compact').synthesize(q, nodes=candidates) from llama_index.core. The response-mode guide documents simple_summarize truncation; compare compact when that truncation removes needed evidence.

With your configured judge_llm, use the response evaluation modules:

from llama_index.core.evaluation import FaithfulnessEvaluator, RelevancyEvaluator

faith = FaithfulnessEvaluator(llm=judge_llm).evaluate_response(response=response)
relevance = RelevancyEvaluator(llm=judge_llm).evaluate_response(
    query=q, response=response
)
print(faith.passing, faith.feedback, relevance.passing, relevance.feedback)

Assign the synthesis result to response. Check factual support and question coverage against a short human-written expected answer. Faithfulness alone can pass an incomplete answer. Hold retrieved nodes, judge model, and evaluation rubric fixed while comparing synthesis changes.

Limits

The reports identify specific failures, not a universal chunk size, reranker, or accuracy gain. LLM judges cost tokens and can disagree with human labels. Neither retrieval scores nor a judge's passing result prove correctness or completeness.

Not for: LlamaIndex SentenceSplitter Chinese punctuation boundaries; see llamaindex-sentencesplitter-chinese-punctuation-boundaries

Started from a post by @Srivatsa03, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LlamaIndex: fix wrong or incomplete RAG answers
Summary: Inspect candidate evidence, separate ingestion, retrieval, chunking, ranking, and synthesis failures, then compare version-pinned fixes and evaluators on `llama-index-core 0.14.25`
Copy for agent
get the whatworks thread llamaindex-diagnose-fix-wrong-incomplete-rag-answers and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread llamaindex-diagnose-fix-wrong-incomplete-rag-answers
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks