-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Restructure Rerankers so both NVIDIA and Cohere work properly #5933
Merged
ogabrielluiz
merged 16 commits into
langflow-ai:main
from
brian-ogrady:nvidia-reranker-fix
Feb 5, 2025
Merged
feat: Restructure Rerankers so both NVIDIA and Cohere work properly #5933
ogabrielluiz
merged 16 commits into
langflow-ai:main
from
brian-ogrady:nvidia-reranker-fix
Feb 5, 2025
Conversation
This file contains 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
…g Voyage AI reranker.
5a66c86
to
2fe3d13
Compare
CodSpeed Performance ReportMerging #5933 will not alter performanceComparing Summary
|
d939f0e
to
99cfd4b
Compare
ogabrielluiz
approved these changes
Jan 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @brian-ogrady
I added a DataFrame output. LGTM
erichare
approved these changes
Feb 4, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
lgtm
This PR has been approved by a maintainer
size:L
This PR changes 100-499 lines, ignoring generated files.
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.
Motivation
This PR initially began as a small error that went unnoticed in the prior PR for the NVIDIA reranker component that only surfaces when using the default API url. Upon dropping the component into a flow it generates an error. This is due to a method name change
build_model
->build_reranker
. This PR resolves the issue detailed here and expands its scope to ensure the Cohere reranker component also functions properly and is no longer marked as legacy, detailed in this issue here.Further Context
The Cohere & NVIDIA rerankers were marked as legacy because we wanted to deprecate retrievers and both components had relied on the
ContextualCompressionRetriever
abstraction from LangChain. This particular abstraction is redundant in LangFlow because simply performs similarity search on a vector store and then reranks the resulting documents using the provided reranker (referred to as a compressor in LC documentation). Because we have the search results coming directly fromVectorStore
components we can instead pass the results directly into the reranker without this abstracted class.New Features
This PR adds a new component called the
LCCompressorComponent
(standing for LangChain Compressor Component) which is a base class for reranker components. Common attributes of the rerankers are abstracted away into this class, leaving thebuild_compressor
abstract method to be implemented by the child class. This requires sourcingBaseDocumentCompressor
fromlangchain_core.documents.compressors
but otherwise is a fairly lightweight class and is even an improvement because the previous implementation of rerankers were inaccurately subclassed fromLCVectorStoreComponent
.