feat: Add a CrossEncoderRerankerHook as a post-processing hook - #227
Draft
jamie-ons wants to merge 3 commits into
Draft
feat: Add a CrossEncoderRerankerHook as a post-processing hook#227jamie-ons wants to merge 3 commits into
jamie-ons wants to merge 3 commits into
Conversation
…rence with cross embedding hook
jamie-ons
marked this pull request as draft
August 27, 2026 12:32
…for improved performance
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.
✨ Summary
This PR adds a new post-processing hook to add a cross encoder reranker. It takes the top retrieved results and reranks them using a cross-encoder model that scores (query, document) pairs jointly, often providing more accurate results than bi-encoder similarity scores (what we currently use in
HuggingFaceVectoriser). This adds no extra dependencies and works similarly to theHuggingFaceVectoriser.I have also included a Demo Notebook to test it out.
The evaluation results with n_results=20 for the reranking and model_name=
cross-encoder/ms-marco-MiniLM-L-12-v2:📜 Changes Introduced
CrossEncoderRerankerHooktosrc/classifai/indexers/hooks/default_hooks/postprocessing.pympsas atorch.deviceto theHuggingFaceVectoriserand to the hook so huggingface models run faster when developing.✅ Checklist
terraform fmt&terraform validate)🔍 How to Test
DEMO/reranker_hook.ipynb