Reranking RAG Results with Gemini Decision 1 and LangChain4j
In Retrieval Augmented Generation pipelines, vector similarity tends to favor chunks with vocabulary similar to the search query. So using a reranking model to reorder the search results according to how well a particular chunk answers a question helps filtering & returning relevant extracts to the LLM. This is generally done with cross-encoder reranking models.
But in this article, I want to show you that you can use decision models, like gemini-decision-1, to handle the reranking phase, thanks to their yes/no answer probabilities,
and weโll be using the LangChain4jโs recent decision model integration I contributed to in version 1.24.
You can pair GoogleGenAiDecisionModel from the langchain4j-google-genai module with DecisionScoringModel and ReRankingContentAggregator from langchain4j-core without writing any custom glue code.
