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(langchain): Rerank Documents Based on Recency Bias on Document Date in Metadata #6676

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

Conversation

Mraj23
Copy link
Contributor

@Mraj23 Mraj23 commented Sep 2, 2024

Fixes # (issue): langchain-ai/langchain#18729

This PR implements a retriever that performs reranking based on receny of a documents published date.

This retreiver differs from the TimeWeightedVectorStoreRetriever that performs retrieval based on the retrieved date of the document, not its published date

Copy link

vercel bot commented Sep 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Sep 9, 2024 1:45am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Sep 9, 2024 1:45am

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features labels Sep 2, 2024
@Mraj23 Mraj23 changed the title Rerank Documents Based on Recency Bias on Document Metadata Date Rerank Documents Based on Recency Bias on Document Date in Metadata Sep 2, 2024
Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Would it make more sense to add a different mode to the existing TimeWeightedVectorStoreRetriever?

@jacoblee93 jacoblee93 changed the title Rerank Documents Based on Recency Bias on Document Date in Metadata feat(langchain): Rerank Documents Based on Recency Bias on Document Date in Metadata Sep 4, 2024
): [Document, number][] {
if (documents.length === 0) return [];

if (!documents.every(([doc, _]) => doc.metadata.date instanceof Date)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would suggest storing this as an ISO string - not all (most?) vector stores will not deserialize dates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features 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