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

Add chunk size parameter to EmbeddingsRequest #111

Open
sibbl opened this issue Jun 5, 2023 · 1 comment
Open

Add chunk size parameter to EmbeddingsRequest #111

sibbl opened this issue Jun 5, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sibbl
Copy link

sibbl commented Jun 5, 2023

Feature Request

Azure OpenAI only allows one single string to be part of an embeddings request. Other frameworks have a chunk_size or embed_batch_size parameter for this.

Describe the solution you'd like

I'd propose a int? ChunkSize = null parameter for the EmbeddingsRequest. If it's > 0, the there should be multiple requests being made with n lines per requests.

Describe alternatives you've considered

I did the chunking myself, but as other frameworks have this built-in, we might also want to add such a parameter here.

Additional context

Quote from MS docs about this limitation:

I am trying to use embeddings and received the error "InvalidRequestError: Too many inputs. The max number of inputs is 1." How do I fix this?
This error typically occurs when you try to send a batch of text to embed in a single API request as an array. Currently Azure OpenAI does not support batching with embedding requests. Embeddings API calls should consist of a single string input per request. The string can be up to 8191 tokens in length when using the text-embedding-ada-002 (Version 2) model.

@sibbl sibbl added the enhancement New feature or request label Jun 5, 2023
@StephenHodgson StephenHodgson added help wanted Extra attention is needed good first issue Good for newcomers labels Jun 5, 2023
@StephenHodgson StephenHodgson linked a pull request Jun 14, 2023 that will close this issue
This was unlinked from pull requests Jun 17, 2023
@sibbl
Copy link
Author

sibbl commented Sep 6, 2023

A quick update: Microsoft now allows up to 16 items in the array, not only a single one.

OpenAI currently allows a larger number of array inputs with text-embedding-ada-002. Azure OpenAI currently supports input arrays up to 16 for text-embedding-ada-002 Version 2. Both require the max input token limit per API request to remain under 8191 for this model.

https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/switching-endpoints#azure-openai-embeddings-multiple-input-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Development

No branches or pull requests

2 participants