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

embedDocuments() batch support and possibly large document splitting #390

Open
krodyrobi opened this issue Dec 19, 2024 · 2 comments
Open
Labels
feature request New feature or request

Comments

@krodyrobi
Copy link

krodyrobi commented Dec 19, 2024

Describe the Problem

OpenAi apis limit the number of elements embedded at a time and the size of each element, to work around this the js sdk and python sdk provide the following:

  • batching if number of documents are above 2048 (promise.all on the batch api calls)
  • split large (>~8000 tokens) documents in sections and then join the retrieved embeddings in a normalized fashion (here the js sdk does not do it but python one does)

Propose a Solution

Base implementation of sdk chat model on @langchain/oneai models.
For the per document split I believe this needs a custom implementation above the core sdk, didn't see it in js langchain.

Describe Alternatives

Create a wrapper over existing model.

Affected Development Phase

Development

Impact

Inconvenience

Timeline

No response

Additional Context

No response

@krodyrobi krodyrobi added the feature request New feature or request label Dec 19, 2024
@krodyrobi krodyrobi changed the title embedDocuments model does not split documents in batches nor does it split large documents and joins the embeddings embedDocuments() batche support and possibly large document splitting Dec 19, 2024
@krodyrobi krodyrobi changed the title embedDocuments() batche support and possibly large document splitting embedDocuments() batch support and possibly large document splitting Dec 20, 2024
@ZhongpinWang
Copy link
Contributor

Hi @krodyrobi ,

Thanks for raising this feature request. Have you checked langchain textsplitters, langchain vector store, and sample code? We currently do not handle sending batch requests or join embeddings. Will this satisfy your needs since you are using langchain?

@krodyrobi
Copy link
Author

krodyrobi commented Dec 20, 2024

Out of all the feature requests this in my opinion can be treated just as nice to have.

For the split of a single document, realistically no document should be that big to begin with as you've pointed out splitters exist, added here just for feature parity with python gen ai sdk and langchain.

For batching multiple documents however langchain-js/openai does this as a convenience. I realize we should stay clear from using something like this as if during the batch 1 request fails we lose quota for the whole promise.all set. Again this is here to provide parity with existing pre-conditions in js and python sdks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants