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

Missing Azure OpenAI support for "OpenAIEmbeddings" #1577

Closed
tunayokumus opened this issue Mar 10, 2023 · 8 comments
Closed

Missing Azure OpenAI support for "OpenAIEmbeddings" #1577

tunayokumus opened this issue Mar 10, 2023 · 8 comments

Comments

@tunayokumus
Copy link
Contributor

It's currently not possible to pass a custom deployment name as model/deployment names are hard-coded as "text-embedding-ada-002" in variables within the class definition.

In Azure OpenAI, the deployment names can be customized and that doesn't work with OpenAIEmbeddings class.

There is proper Azure support for LLM OpenAI, but it is missing for Embeddings.

@lakshyaag
Copy link
Contributor

Same issue as #1560

@JonAtDocuWare
Copy link

FYI I worked around this issue with naming my deployment name "text-embedding-ada-002" using the model of the same name. The next issue I ran into was hitting the rate limiter when using embeddings, as the default is 300(?) requests per minute. I had to add my own retrying functionality to the /embeddings/openai.py code, but I am using an older version (0.088?) and it looks like in more recent commits better retrying is being built in.

just in case it helps you, here is my embed_documents function, with modifications at the end (last else case):

import tenacity
from tenacity import retry
...

def embed_documents(
        self, texts: List[str], chunk_size: int = 1000
    ) -> List[List[float]]:
        """Call out to OpenAI's embedding endpoint for embedding search docs.

        Args:
            texts: The list of texts to embed.
            chunk_size: The maximum number of texts to send to OpenAI at once
                (max 1000).

        Returns:
            List of embeddings, one for each text.
        """
        # handle large batches of texts
        if self.embedding_ctx_length > 0:
            return self._get_len_safe_embeddings(
                texts, engine=self.document_model_name, chunk_size=chunk_size
            )
        else:
            @retry(wait=tenacity.wait_fixed(10), stop=tenacity.stop_after_attempt(60))
            def addText(text):
                embedding = self._embedding_func(text, engine=self.document_model_name)
                return embedding
            responses = []
            for text in texts:
                responses.append(addText(text))
                    
            return responses

@geg00
Copy link

geg00 commented Mar 22, 2023

The issue comes when you try to use GPT-3.5-turbo
Azure does not let you name the deployments with '.'

@JonAtDocuWare
Copy link

The issue comes when you try to use GPT-3.5-turbo Azure does not let you name the deployments with '.'

Can you create embeddings with GPT-3.5-turbo?

@geg00
Copy link

geg00 commented Mar 22, 2023

I'm using
embeddings = OpenAIEmbeddings(chunk_size=1) for embedings
By default OpenAIEmbeddings uses text-embedding-ada-002
Create a model deployment name
text-embedding-ada-002 with the model text-embedding-002

Aure will not work unless you have chunk_size=1

@JonAtDocuWare
Copy link

The issue comes when you try to use GPT-3.5-turbo Azure does not let you name the deployments with '.'

So this is not really an issue for OpenAIEmbeddings

@tunayokumus
Copy link
Contributor Author

Opened a PR to fix this issue by separating deployment name and model name:
#3076

@dosubot
Copy link

dosubot bot commented Sep 20, 2023

Hi, @tunayokumus! I'm Dosu, and I'm helping the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the issue is about the missing Azure OpenAI support for "OpenAIEmbeddings". The model and deployment names are hard-coded and cannot be customized. One user suggested a workaround by naming the deployment "text-embedding-ada-002" using the model of the same name. Another user mentioned hitting the rate limiter when using embeddings and added their own retrying functionality.

However, it seems that the original author has addressed the issue by opening a pull request to fix it.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution to the LangChain repository!

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 20, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 27, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants