Azure AI Search embeddings: max content length exceeded?

Barry Briggs 60 Reputation points
2024-12-18T23:26:41.02+00:00

Creating embeddings for an array of 100 JSON objects in order to create an index. Loop through the objects creating an embedding for the body field (six simple fields and one vector field) and get error "This model's maximum context length is 8192 tokens, however you requested 16893 tokens (16893 in your prompt; 0 for the completion). Please reduce your prompt; or completion length."

However:

Using the tiktoken library:

The current object has 1778 tokens

The running total of 32 objects is 38355

The text for the embedding (for the offending object) is 7487 characters

I have put delays in the code to no avail. If I simply get an embedding for the offending object (no loop) it works which suggests it has something to do with the accumulating load -- but not sure what it could be.

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,119 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,453 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.