Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

brian-ogrady
Copy link
Contributor

@brian-ogrady brian-ogrady commented Jan 25, 2025

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 from VectorStore 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 the build_compressor abstract method to be implemented by the child class. This requires sourcing BaseDocumentCompressor from langchain_core.documents.compressors but otherwise is a fairly lightweight class and is even an improvement because the previous implementation of rerankers were inaccurately subclassed from LCVectorStoreComponent.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jan 25, 2025
@brian-ogrady
Copy link
Contributor Author

@brian-ogrady brian-ogrady changed the title Nvidia reranker fix fix: Nvidia reranker remove nonexistent method Jan 25, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 25, 2025
@brian-ogrady
Copy link
Contributor Author

Related PR

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jan 27, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Jan 27, 2025
Copy link

codspeed-hq bot commented Jan 27, 2025

CodSpeed Performance Report

Merging #5933 will not alter performance

Comparing brian-ogrady:nvidia-reranker-fix (736ac45) with main (2f9cd3e)

Summary

✅ 9 untouched benchmarks

@brian-ogrady brian-ogrady changed the title fix: Nvidia reranker remove nonexistent method feat: Restructure Rerankers and add VoyageAI Reranker Component Jan 27, 2025
@github-actions github-actions bot added enhancement New feature or request and removed bug Something isn't working enhancement New feature or request labels Jan 27, 2025
@github-actions github-actions bot removed the enhancement New feature or request label Jan 27, 2025
@github-actions github-actions bot added the enhancement New feature or request label Jan 27, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 27, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 28, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 28, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 28, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 30, 2025
@ogabrielluiz ogabrielluiz requested a review from erichare January 30, 2025 21:31
Copy link
Contributor

@ogabrielluiz ogabrielluiz left a 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

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 31, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 31, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants