-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[DRAFT] Chunker .add API #2261
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
base: 05-29-anton_chunker
Are you sure you want to change the base?
[DRAFT] Chunker .add API #2261
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite. This stack of pull requests is managed by Graphite. Learn more about stacking. |
if chunker is not None: | ||
chunks, chunk_ids = chunk_and_assign_ids(documents, ids, chunker) | ||
# Flatten chunk_ids and chunks, and assign them as the new values | ||
ids = [id for chunk_id in chunk_ids for id in chunk_id] |
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.
Basically we expand the list of IDs by chunk ID. We should probably pass these out to the user (we currently do not pass IDs out) so they can keep track of the new IDs. I can do that here, on in a separate PR.
embeddings = self._embed(input=documents) | ||
elif images is not None: | ||
if chunker is not None: | ||
# Image chunking is not supported yet | ||
raise NotImplementedError("Image chunking is not supported yet.") | ||
embeddings = self._embed(input=images) | ||
else: | ||
if uris is None: |
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.
`update` should be fairly straightforward since it's a delete and an add under the hood. We only need to do the same trick with IDs, delete the old ID and insert new ones.
See this comment inline on Graphite.
I think my primary feedback is that:
I think that we should either
|
d2b2d7f
to
719c37c
Compare
19197fd
to
14d8b1e
Compare
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
719c37c
to
773385a
Compare
14d8b1e
to
aee51bf
Compare
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
d673865
to
205c06c
Compare
aee51bf
to
bdd2cca
Compare
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
205c06c
to
514cf4d
Compare
bdd2cca
to
e9dbd2d
Compare
Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas |
Description of changes
This PR adds Chunkers to the
.add
method onCollection
.It allows users to pass a chunker in whenever the
.add
. The chunker splits documents into chunks according to supplied parameters.This is implemented in a way that Chunkers can read off properties of collections - we want to do that so that Chunkers can be aware of embedding functions. (next PR)
Thinking about this a little more, we probably want
max_tokens
to already be a part of the Chunk interface, but I can implement that when I make these smarter in the next PR in this stack.There is a notebook for you to try this out! Install chroma from the repo with
pip install -e .
Then check out https://app.graphite.dev/github/pr/chroma-core/chroma/2261/DRAFT-Chunker-add-API#file-chunker_example.ipynb
Test plan
TBC
Documentation Changes
TBC
TODO