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

core: add new clean up strategy "scoped_full" to indexing #28505

Merged
merged 8 commits into from
Dec 13, 2024

Conversation

KeiichiHirobe
Copy link
Contributor

@KeiichiHirobe KeiichiHirobe commented Dec 4, 2024

Note that this PR is now Draft, so I didn't add change to aindex function and didn't add test codes for my change.
After we have an agreement on the direction, I will add commits.

batch_size is very difficult to decide because setting a large number like >10000 will impact VectorDB and RecordManager, while setting a small number will delete records unnecessarily, leading to redundant work, as the IMPORTANT section says.
On the other hand, we can't use full because the loader returns just a subset of the dataset in our use case.

I guess many people are in the same situation as us.

So, as one of the possible solutions for it, I would like to introduce a new argument, scoped_full_cleanup.
This argument will be valid only when claneup is Full. If True, Full cleanup deletes all documents that haven't been updated AND that are associated with source ids that were seen during indexing. Default is False.

This change keeps backward compatibility.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 4, 2024
Copy link

vercel bot commented Dec 4, 2024

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

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 8:35pm

@dosubot dosubot bot added the Ɑ: core Related to langchain-core label Dec 4, 2024
Copy link
Collaborator

@eyurtsev eyurtsev left a comment

Choose a reason for hiding this comment

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

This looks very reasonable!

If you'd like to merge:

  1. Could you introduce this as a new cleanup mode?
  2. Add unit-tests

libs/core/langchain_core/indexing/api.py Show resolved Hide resolved
@@ -259,6 +256,11 @@ def index(
specify a custom vector_field:
upsert_kwargs={"vector_field": "embedding"}
.. versionadded:: 0.3.10
scoped_full_cleanup: This argument will be valid only when `claneup` is Full.
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about we turn this into another clean up mode so we don't introduce another parameter that only works conditionally?

This looks like cleanup == 'full_scoped' or something like that.

And we'd document:

  1. In the important section -- that full_scoped is a solution to problem w/ batches being a best effort
  2. This solution keeps track of the source ids in memory (probably fine for most use cases in terms of memory consumption) -- would require parallelizing for 10M+ docs anyway

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Dec 13, 2024
@KeiichiHirobe KeiichiHirobe changed the title [draft] core: add scoped_full_cleanup arg to index core: add scoped_full_cleanup arg to index Dec 13, 2024
@KeiichiHirobe KeiichiHirobe changed the title core: add scoped_full_cleanup arg to index core: add new clean up strategy "scoped_full" to indexing Dec 13, 2024
@KeiichiHirobe
Copy link
Contributor Author

@eyurtsev Thank you for your review. I've just pushed 1 commit: 32c3f03

@eyurtsev
Copy link
Collaborator

Pushed a minor doc-string update

@eyurtsev eyurtsev enabled auto-merge (squash) December 13, 2024 20:24
@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Dec 13, 2024
@eyurtsev
Copy link
Collaborator

@KeiichiHirobe thank you looks great!

@eyurtsev eyurtsev merged commit 258b3be into langchain-ai:master Dec 13, 2024
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: core Related to langchain-core lgtm PR looks good. Use to confirm that a PR is ready for merging. size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants