Deep Learning Community Question

How to handle multi-stage retrieval in LlamaIndex to reduce AI hallucinations?

Posted on 2025-01-08 • In Deep Learning • By Amanda Ross

I’ve built a basic RAG setup, but the answers are still slightly off. Is LlamaIndex the best framework for RAG applications that require re-ranking? I want to implement a two-stage process where I fetch 50 nodes and then re-rank the top 5. Can someone explain the step-by-step logic for this using the built-in Cohere or Sentence Transformer re-rankers?

3 Answers 11,278 Views

All answers to this question 3 Answers

Karen Mitchell Answered on 2025-01-10
Answered

To solve hallucinations, you definitely want to use the "Node Postprocessor" module. Step one is initializing your base retriever to pull a larger initial set, say similarity_top_k=20. Step two is adding a CohereRerank or a LLMRerank module to your query engine. This forces the system to look closer at the semantic relevance of the retrieved chunks before the final LLM synthesis. I implemented this for a legal discovery tool in late 2023, and we saw a dramatic drop in "hallucinated" clauses because the second-stage re-ranker was much better at understanding the nuance of the query than a simple vector search.

David Harrison Answered on 2025-01-15
Answered

Does adding a re-ranking step significantly increase the latency of the response? My users are very sensitive to waiting more than 2 seconds for an answer.

Jason Meyers Commented on 2025-01-17
Commented

David, it does add a bit of overhead, usually around 300-500ms. However, if accuracy is your priority, it’s a necessary trade-off. You can mitigate this by using a smaller, faster cross-encoder model for re-ranking locally instead of calling an external API. In many production cases, a slightly slower but correct answer is always better than a fast, incorrect one that loses user trust.

Christopher Bell Answered on 2025-01-19
Answered

I highly recommend checking out "Small-to-Big" retrieval. You search small chunks for better match accuracy but send larger parent chunks to the LLM for context.

Karen Mitchell Commented on 2025-01-20
Commented

I agree, Christopher. That specific feature in LlamaIndex is arguably one of its biggest advantages for maintaining context without cluttering the search.

Write a Comment

Your email address will not be published. Required fields are marked (*)

Join the LearnersEra Community

Ask questions, share knowledge and learn from professionals across technology, project management and certification topics.

Change Country and Nearest City

Select your country and nearest city to see courses available in your region.