Find answers from the community

Updated 10 months ago

My question is : Is text-ebedding-3-

My question is : Is text-ebedding-3-large is working with llama_index and AzureOpenai ?
W
K
39 comments
How are you creating embedding object?
Can you share that?
print("Initialisation OpenAI...")

llm = AzureOpenAI(
model=_model.ChatModel.Model,
deployment_name=_model.ChatModel.Name,
api_key=_model.Key1,
azure_endpoint=_model.Server,
api_version=_model.ChatModel.ApiVersion,
)

embed_model = AzureOpenAIEmbedding(
model=_model.LearningModel.Model,
deployment_name=_model.LearningModel.Name,
api_key=_model.Key1,
azure_endpoint=_model.Server,
api_version=_model.LearningModel.ApiVersion,
)

Settings.llm = llm
Settings.embed_model = embed_model
Settings.context_window = _contextWindow
Settings.num_output = _numOutput



print("Initialisation MongoDB...")

mongodb_client = pymongo.MongoClient(_mongoURI)
store = MongoDBAtlasVectorSearch(mongodb_client, db_name=_index)

storage_context = StorageContext.from_defaults(vector_store=store)



print("Démarrage de l'importation...")

reader = SimpleDirectoryReader(_directory, recursive=True, encoding="latin-1", required_exts=[".pdf", ".docx", ".pptx", ".csv"])

for docs in reader.iter_data():
print("F > " + docs[0].metadata['file_name'])
VectorStoreIndex.from_documents(docs, storage_context=storage_context)



print("Terminée.")
Can you check if you are able to generate embeddings like this:
Plain Text
embeddings = embed_model.get_text_embedding(
    "It is raining cats and dogs here!"
)


If this doesnt work you might have to check whether this model is available in Azure yet or not
do i need to imùport something else than thes?:
from llama_index.llms.azure_openai import AzureOpenAI
from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding
from llama_index.vector_stores.mongodb import MongoDBAtlasVectorSearch
from llama_index.embeddings.openai import OpenAIEmbedding

btw the model "text-ebedding-3-large" is already deploy in azure
no i think the imports look fine, youc an remove the OpenAI embeddings
it stayed like that
i chage it like that to make iit work
Attachment
image.png
it returned me this error :
Initialisation OpenAI...
Traceback (most recent call last):
File "C:\Users\sxd-i\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\llama_index\core\embeddings\utils.py", line 59, in resolve_embed_model
validate_openai_api_key(embed_model.api_key)
File "C:\Users\sxd-i\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\llama_index\embeddings\openai\utils.py", line 104, in validate_openai_api_key
raise ValueError(MISSING_API_KEY_ERROR_MESSAGE)
ValueError: No API key found for OpenAI.
Please set either the OPENAI_API_KEY environment variable or openai.api_key prior to initialization.
API keys can be found or created at https://platform.openai.com/account/api-keys


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\Projets\IA Chat Local\Sources\LocalIndexation\app.py", line 57, in <module>
embeddings = Settings.embed_model.get_text_embedding(
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sxd-i\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\llama_index\core\settings.py", line 67, in embed_model
self._embed_model = resolve_embed_model("default")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sxd-i\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\llama_index\core\embeddings\utils.py", line 66, in resolve_embed_model
raise ValueError(
ValueError:
**
Could not load OpenAI embedding model. If you intended to use OpenAI, please check your OPENAI_API_KEY.
Original error:
No API key found for OpenAI.
Please set either the OPENAI_API_KEY environment variable or openai.api_key prior to initialization.
API keys can be found or created at https://platform.openai.com/account/api-keys

Consider using embed_model='local'.
Visit our documentation for more embedding options: https://docs.llamaindex.ai/en/stable/module_guides/models/embeddings.html#modules
**
Ah so your AzureEMbedding is not being used, it is defaulting to openAI
Also, Not sure if this can be the issue or not but your API version should be this api_version="2023-07-01-preview" or above
i show you how i change :
Attachment
image.png
i just didn't comment embeddings
You have to put this below Azure embed model line
embeddings = embed_model.get_text_embedding(
"It is raining cats and dogs here!"
)

Initialize the model first and then put this below
like this ? (sorry for aswerring you this late, i was eating )
Attachment
image.png
Yes, try now and see if this works, else can you show what is your API version
And No worries for the reply!
and for the API version, you mean the version of azure?
Attachment
image.png
wait, remove Settings from the method call, You havent set it yet and then call
and for the version , yes the value that you are providing with _model.LearningModel.ApiVersion
just do this:
Plain Text
embeddings = embed_model.get_text_embedding(
    "It is raining cats and dogs here!"
)
okay it seems to work
Awesome, I suppose that solves your issue as well right?
i'll wait the end of the indexation and i'll tell you if it works or not
okay it didn't work as i expect see the error :
Strange!, did you get a output when you ran this?
only output that i get
Please share this value once _model.LearningModel.ApiVersion
it's build like this :
Attachment
image.png
No I mean the value that is present in this _model.LearningModel.ApiVersion when you are creating the embed_model,
what i guet on azure :
Attachment
image.png
when running it's "1"
It should be the version that is being shown in your Screenshot
even with that it didn't work
i'll check by my side, i'll repost an announce if need other help
You can test on Azure Platform itself, They provide you with API object as well, copy all the values from there and use those values in your code
i check the api version taht were available on microsoft docs, i chose the 2023-05-15 version, it seems like the model text-embedding-3-large doesn't work with previews or with an other version than 2023-05-15
Add a reply
Sign up and join the conversation on Discord