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

langchain[minor],docs[minor]: Add MatryoshkaRetriever #4458

Merged
merged 24 commits into from
Feb 29, 2024

Conversation

bracesproul
Copy link
Collaborator

Copy link

vercel bot commented Feb 20, 2024

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

Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 28, 2024 10:22pm
langchainjs-docs ✅ Ready (Inspect) Visit Preview Feb 28, 2024 10:22pm

@bracesproul bracesproul marked this pull request as ready for review February 20, 2024 17:30
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder labels Feb 20, 2024
@jacoblee93
Copy link
Collaborator

Does this need to be in experimental?

@bracesproul
Copy link
Collaborator Author

Does this need to be in experimental?

No, can move --just seemed right at the time but ig it goes both ways.

@bracesproul bracesproul changed the title langchain[minor],docs[minor]: Add AdaptiveRetrieval to lc experimental community[minor],docs[minor]: Add AdaptiveRetrieval to lc experimental Feb 21, 2024
@@ -0,0 +1,128 @@
import { CallbackManagerForRetrieverRun } from "@langchain/core/callbacks/manager";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should live in langchain and not community since it's more of an algorithm?

constructor(fields: MatryoshkaRetrievalFields<Store>) {
super({
...fields,
vectorStore: fields.smallStore,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why override this name?

*
* The MatryoshkaRetrieval retriever performs two semantic searches. The first uses the smaller
* store which returns many results, but is less accurate. Then, using the documents returned
* from the smaller store, the larger store is used to perform a more accurate search over the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you go into a bit more detail as to how this works? What does "more accurate search" mean?

query,
this.largeK,
(doc: DocumentInterface) =>
smallResultIds.includes(doc.metadata[this.idKey]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This filter will not always be a function will it?

const smallResultIds = smallResults.map(
(result) => result.metadata[this.idKey]
);
const largeResults = await this.largeStore.similaritySearch(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait lmao this is just parent document isn't it?

@jacoblee93 jacoblee93 added the hold On hold label Feb 21, 2024
@bracesproul bracesproul marked this pull request as draft February 21, 2024 17:11
@bracesproul bracesproul changed the title community[minor],docs[minor]: Add AdaptiveRetrieval to lc experimental community[minor],docs[minor]: Add MatryoshkaRetrieval to lc experimental Feb 27, 2024
@bracesproul bracesproul changed the title community[minor],docs[minor]: Add MatryoshkaRetrieval to lc experimental langchain[minor],docs[minor]: Add MatryoshkaRetrieval Feb 27, 2024
@bracesproul bracesproul added lgtm PRs that are ready to be merged as-is and removed hold On hold labels Feb 27, 2024
@bracesproul bracesproul marked this pull request as ready for review February 27, 2024 23:18
@@ -3646,6 +3650,15 @@
"import": "./retrievers/vespa.js",
Copy link

Choose a reason for hiding this comment

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

Hey there! I noticed that this PR introduces a new dependency for "./retrievers/matryoshka_retrieval" in the package.json file, potentially impacting the project's dependencies. This comment is to flag the change for maintainers to review the type of dependency change (peer/dev/hard). Keep up the great work!

@bracesproul bracesproul changed the title langchain[minor],docs[minor]: Add MatryoshkaRetrieval langchain[minor],docs[minor]: Add MatryoshkaRetriever Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder lgtm PRs that are ready to be merged as-is 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