Closed JanHorcicka closed 6 months ago
🤖
Hello,
Thank you for reaching out with your issue. The error you're encountering is likely due to the restrictions set by the Deep Infra's embedding inference service, not LangChain itself. The 'gpt-3.5-turbo' model might not be allowed for generating embeddings in the Deep Infra's service, even though it can be used for creating a Language Learning Model (LLM).
When you call the _embed
method in the DeepInfraEmbeddings
class, it sends a POST request to the Deep Infra's API endpoint with the specified model ID. If the model ID you're using is 'gpt-3.5-turbo' and it's not allowed for generating embeddings, the API will return a non-200 status code, which will raise a ValueError in the _embed
method. You can find this code in the libs/langchain/langchain/embeddings/deepinfra.py file.
To resolve this issue, you should check the list of allowed models for generating embeddings on the Deep Infra's service. If 'gpt-3.5-turbo' is not on the list, you will need to use a different model.
As for LangChain, it does have a specific list of models that are allowed for generating embeddings. This list includes various models like OpenAIEmbeddings, CacheBackedEmbeddings, ClarifaiEmbeddings, and many more. You can find this list in the __all__
variable in the libs/langchain/langchain/embeddings/init.py file.
I hope this helps! If you have any other questions or need further clarification, feel free to ask.
Best, Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
@JanHorcicka The problem is with lack of sufficient documentation and error handling in Langchain. Read this documentation from OpenAI on the models you can use for embeddings.
The limitation is from OpenAI. You cannot use gpt-3.5-turbo
for embeddings. You can either leave it blank which will default to text-embedding-ada-002
which is the best and recommended model. Or you can set it to one of the models from the docs.
Thank you all for answers. I would just like to point out that I didn't have this issue when using langchain==0.0.168
. This error started appearing after I updated to a higher version (I have langchain==0.0.232
). Which is weird. :)
I have the same issue also, have you found the solution for this? my version is 325
Thank you all for answers. I would just like to point out that I didn't have this issue when using
langchain==0.0.168
. This error started appearing after I updated to a higher version (I havelangchain==0.0.232
). Which is weird. :)
The reason you were not seeing it before is that it was hard coded in the earlier versions. Meaning it didn't matter whether you passed anything to it or not as it was not using the value you were giving it. In the newer versions this bug was fixed. So it will consider the argument you pass to it. Again, the problem is a limitation from OpenAI. The embedding models are different from the classification or generation models. You need to either pass the name of one of their embedding models or leave it blank. In which case it will default to the best embedding model.
Hi, @JanHorcicka,
I'm helping the LangChain team manage their backlog and am marking this issue as stale. It seems like you encountered a "PermissionError" when trying to generate embeddings using the 'gpt-3.5-turbo' model in LangChain. Dosu-bot provided a detailed explanation that the error is likely due to restrictions set by the Deep Infra's embedding inference service, and suggested checking the list of allowed models for generating embeddings. M-movahhedinia pointed out the lack of documentation and error handling in LangChain, and recommended referring to OpenAI's documentation for the recommended embedding models. You also mentioned that the error started appearing after updating to a higher version of LangChain, and m-movahhedinia explained that the issue was hard coded in earlier versions and has been fixed in newer versions. JJim180730 also reported encountering the same issue.
Could you please confirm if this issue is still relevant to the latest version of the LangChain repository? If it is, please let the LangChain team 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!
I have the same issue also, langchain==0.0.232
. Have you found the solution for this?
I have the same issue also,
langchain==0.0.232
. Have you found the solution for this?
I just don't specify the model name and it works.
embeddings = OpenAIEmbeddings()
@lauraparra28 @JanHorcicka
When you don't pass the model it will default to text-embedding-ada-002
. If it is all the same to you, I advise going with either one of the newer models. The text-embedding-3-small
has almost similar performance but is cheaper. The text-embedding-3-large
has better performance but is more expensive and in my experience very slightly slower.
In either case, you have to use one of the embedding models (one of the mentioned three) to avoid that issue. You can read more about the embedding models in the link I posted earlier.
Issue you'd like to raise.
I have an issue when trying to set 'gpt-3.5-turbo' as a model to create embeddings.
When using the 'gpt-3.5-turbo' to create LLM, everything works fine:
llm = OpenAI(model_name='gpt-3.5-turbo', temperature=0, openai_api_key=OPENAI_API_KEY, max_tokens=512)
Also creating embeddings without specifying a model works fine:
embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)
But when I try to use 'gpt-3.5-turbo' for embeddings, I get the following error:
embeddings = OpenAIEmbeddings(model='gpt-3.5-turbo', openai_api_key=OPENAI_API_KEY)
Error: openai.error.PermissionError: You are not allowed to generate embeddings from this model
This seems weird to me since I have just used the same model to create LLM. So I have access to it and should be able to use it. Unless creation of embeddings and LLM differs somehow.
Can somebody please advise?
Suggestion:
No response