[FEATURE] Add reranker fallback chains to statement reranking#406
Draft
marora90 wants to merge 1 commit into
Draft
[FEATURE] Add reranker fallback chains to statement reranking#406marora90 wants to merge 1 commit into
marora90 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds ordered fallback chains for final statement reranking while keeping entity reranking unchanged.
Users can continue to configure a single reranker:
or provide an ordered chain:
If an earlier statement reranker raises and the fallback policy permits recovery, the next strategy is attempted.
Changes
Support none as either:
Validate list-based reranker chains.
Improve fallback logging:
Clarify the statement/entity reranking distinction in the public documentation.
Make the throttling-policy example robust to exceptions whose response attribute is not a dictionary.
Problem
Model-based rerankers can fail because of transient provider errors such as throttling.
Previously, callers had to either accept that failure or implement fallback outside the retrieval pipeline.
This change allows callers to prefer a model-based reranker while retaining a local fallback.
Fallback remains stateless and is evaluated per query. A reranker that failed for one query will be attempted again for the next query.
Related issue: #403
Decisions to review
A few behaviors are intentional but worth confirming during review:
1. Reranker chains only apply to statements
rerankerandreranker_fallback_policycontrol final statement reranking. Entity reranking remains independent andalways uses TF-IDF, even when statement reranking is disabled with
Noneornone.2. Fallback allows any exception by default
Without a custom policy, any failure from a non-final reranker advances to the next strategy. This includes transient
errors such as throttling, but also configuration, credential, dependency, or implementation errors.
A custom policy can restrict which failures allow fallback. Exceptions from the final reranker—and exceptions raised by
the policy itself—always propagate.
3. Falling back to
nonestill requires policy approvalFor
['bedrock', 'none'], the Bedrock failure must be approved by the fallback policy beforenoneis reached. Ifdenied, the original exception propagates.
Once reached,
noneperforms no scoring and cannot fail.4. Empty score maps do not trigger fallback
An empty score map is treated as a completed scorer response. It is logged at
ERROR, no fallback is attempted, and allstatements are dropped.
This preserves existing behavior, but is worth confirming because it may be surprising in a chain.
5. Existing validation behavior is preserved
ProcessorArgsremains permissive, with validation performed byRerankStatements. Lists validate reranker names andthe placement of
none; legacy single-string values retain their existing, less-strict behavior for compatibility.6. Fallback state is not remembered
Fallback is evaluated independently for every query. A failed provider is retried on the next query rather than being
temporarily disabled, so persistent failures may add latency until the underlying issue is resolved.
Testing
pytest)Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.