8000 fix(response): clean up chunk text by rachlllg · Pull Request #16 · freelawproject/inception · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(response): clean up chunk text #16

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

Merged
merged 1 commit into from
Mar 25, 2025
Merged

fix(response): clean up chunk text #16

merged 1 commit into from
Mar 25, 2025

Conversation

rachlllg
Copy link
Contributor

clean up chunk text in the response to remove prefix for easier downstream processing

Per discussion: freelawproject/courtlistener#5298 (comment)
We should clean up the chunk text in the response to remove the prefix for easier downstream processing and keeping the opinion text clean

clean up chunk text in the response to remove prefix for easier downstream processing
@rachlllg rachlllg requested a review from mlissner March 24, 2025 22:17
Comment on lines +167 to +169
clean_chunks = [
chunk.replace("search_document: ", "") for chunk in all_chunks
]
Copy link
Member

Choose a reason for hiding this comment

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

Hm, will this use a bunch more memory where a different solution could remove search_document further upstream so that a full copy (and manipulation) of the response won't be necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The line right above this is where we pass all_chunks to the model to generate the embeddings, so we cannot do this upstream, unless one the three options:

  1. We carry two copies of the chunks, one with the prefix, one without, and pass the one with prefix to the model and return the one without as the text
  2. We create the chunks without the prefix but before passing the chunks to the models, we add the prefix, which is equivalent to this but in reverse
  3. or, we simply do not use the prefix. The nomic_ai model is designed for query-context with prefix so this will impact the performance slightly

I don't think either of the first two options will be any better, this list comprehension will consume CPU memory, it will not impact GPU memory.

Copy link
Member

Choose a reason for hiding this comment

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

Cool. Got it. Let's stick with what you've got. Thanks.

@mlissner mlissner merged commit e6908c8 into main Mar 25, 2025
5 checks passed
@mlissner mlissner deleted the clean-up-chunk-text branch March 25, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0