Optimize the batching logic of the embeddings #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trying to fix the error "beyond max_tokens_per_request" as follows:
When utilizing the text-embedding-ada-002 model as the embedding model, the following issues were encountered during the initialization of the knowledge base:
This occurred because all three embedding models provided by OpenAI (Text-Embedding-3-small, Text-Embedding-3-large, and Text-Embedding-Ada-002) are subject to two types of limitations: an MAX INPUT limit of 8192 tokens and a max_tokens_per_request limit of 300,000 tokens. When embedding the knowledge base, the total number of tokens exceeded the latter limit, resulting in the aforementioned error.
This error was not observed during the previous development phase, likely due to the use of alternative embedding models.
The solution implemented involves estimating the total token consumption and processing the data in batches when the max_tokens_per_request limit is exceeded.
Although this issue may not arise when using other embedding models, the proposed solution does not interfere with the operation of other models. Therefore, no logical distinctions based on the embedding models were introduced.