langchain: Azure OpenAI Embedding langchain.embeddings.openai.embed_with_retry won't provide any embeddings after retries.

I have the following code:

docsearch = Chroma.from_documents(texts, embeddings,persist_directory=persist_directory)

and get the following error:

Retrying langchain.embeddings.openai.embed_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised RateLimitError: Requests to the Embeddings_Create Operation under Azure OpenAI API version 2022-12-01 have exceeded call rate limit of your current OpenAI S0 pricing tier. Please retry after 3 seconds. Please contact Azure support service if you would like to further increase the default rate limit.

The length of my texts list is less than 100 and as far as I know azure has a 400 request/min limit. That means I should not receive any limitation error. Can someone explain me what is happening which results to this error?

After these retires by Langchain, it looks like embeddings are lost and not stored in the Chroma DB. Could someone please give me a hint what I’m doing wrong?

using langchain==0.0.125

Many thanks

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 2
  • Comments: 33

Most upvoted comments

Define following values in the code 👍:

openai.api_type = “azure” os.environ[“OPENAI_API_TYPE”] = “azure” os.environ[“OPENAI_API_KEY”] = “your api key” os.environ[“OPENAI_API_BASE”] = “put yours” os.environ[“OPENAI_API_VERSION”] = “2023-03-15-preview”

llm = AzureOpenAI( api_key=“your api key”, api_base=“put yours”, api_version=“2023-03-15-preview”, deployment_name=“name of the deployment”)

llm_embeddings = OpenAIEmbeddings(model=“text-embedding-ada-002”, chunk_size = 1)

this will definitely work with chroma,faisss db

Getting the same error using Azure OpenAI with openai.api_version = "2023-05-15"

Creating my embeddings:

from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(chunk_size=1, openai_api_version=openai.api_version, openai_api_key=openai.api_key, openai_api_type=openai.api_type,
 openai_api_base=openai.api_base, deployment="ChatGPTEmbeddings", model="text-embedding-ada-002")

Creating vector store index:

 index = VectorstoreIndexCreator(
    embedding = embeddings,
    vectorstore_cls=DocArrayInMemorySearch
).from_loaders([loader])

Receiving this error on loop, cell running for 1minute and 51 seconds. Retrying langchain.embeddings.openai.embed_with_retry.<locals>._embed_with_retry in 4.0 seconds as it raised RateLimitError: Requests to the Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. Operation under Azure OpenAI API version 2023-05-15 have exceeded call rate limit of your current OpenAI S0 pricing tier. Please retry after 1 second. Please go here: https://aka.ms/oai/quotaincrease if you would like to further increase the default rate limit..