Skip to content

Add reranking document post processor#5904

Open
KoreaNirsa wants to merge 1 commit intospring-projects:mainfrom
KoreaNirsa:feature/reranking-document-post-processor
Open

Add reranking document post processor#5904
KoreaNirsa wants to merge 1 commit intospring-projects:mainfrom
KoreaNirsa:feature/reranking-document-post-processor

Conversation

@KoreaNirsa
Copy link
Copy Markdown
Contributor

Closes #5903

Overview

This PR adds reusable document reranking support to the RAG module.

The new post-processor supports the common RAG pattern of retrieving a broader candidate set from a vector store, reranking those candidates with a more precise relevance strategy, and passing only the best-ranked documents to generation.

The implementation intentionally does not define the ranking strategy itself. Instead, applications provide a DocumentReranker, which can delegate to an external reranking model or service, use custom metadata-based scoring, apply rule-based ranking, or combine multiple relevance signals.

Changes

  • Adds DocumentReranker as a functional contract for reranking retrieved documents based on a Query
  • Adds RerankingDocumentPostProcessor to apply a DocumentReranker after retrieval
  • Adds optional topN support to keep only the highest-ranked reranked documents
  • Adds unit tests for reranking, topN truncation, validation, and empty input behavior
  • Updates the RAG documentation with an example using RetrievalAugmentationAdvisor

Signed-off-by: KoreaNirsa <islandtim@naver.com>
@KoreaNirsa KoreaNirsa force-pushed the feature/reranking-document-post-processor branch from 8358585 to 276655d Compare April 29, 2026 08:55
@cylin0201
Copy link
Copy Markdown

Hi @KoreaNirsa, nice work on the reranking post-processor!

Just a heads-up: PR #5887 (linked to issue #5776, filed on Apr 8) covers similar territory with a ScoringModel abstraction that follows Spring AI's Model<TReq, TRes> pattern, including a Jina AI provider implementation and auto-configuration.

Flagging this for the maintainers' awareness so both approaches can be evaluated together. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a document reranking post-processor for Modular RAG flows

2 participants