Azure-Samples / graphrag-accelerator

One-click deploy of a Knowledge Graph powered RAG (GraphRAG) in Azure
https://github.com/microsoft/graphrag
MIT License
1.56k stars 226 forks source link

[BUG] Embedding model not found in the log of indexing of 1-Quickstart.ipynb #89

Closed Elizabeth819 closed 1 month ago

Elizabeth819 commented 1 month ago

Describe the bug There is nowhere to setup embedding model endpoint in deploy.parameters.json. The log says: {"type": "error", "data": "Error Invoking LLM", "cause": "Error code: 404 - {'error': {'code': 'DeploymentNotFound', 'message': 'The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.'}}", "stack": "Traceback (most recent call last):\n File \"/usr/local/lib/python3.10/site-packages/graphrag/llm/base/base_llm.py\", line 53, in _invoke\n output = await self._execute_llm(input, kwargs)\n File \"/usr/local/lib/python3.10/site-packages/graphrag/llm/openai/openai_embeddings_llm.py\", line 36, in _execute_llm\n embedding = await self.client.embeddings.create(\n File \"/usr/local/lib/python3.10/site-packages/openai/resources/embeddings.py\", line 215, in create\n return await self._post(\n File \"/usr/local/lib/python3.10/site-packages/openai/_base_client.py\", line 1805, in post\n return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)\n File \"/usr/local/lib/python3.10/site-packages/openai/_base_client.py\", line 1503, in request\n return await self._request(\n File \"/usr/local/lib/python3.10/site-packages/openai/_base_client.py\", line 1599, in _request\n raise self._make_status_error_from_response(err.response) from None\nopenai.NotFoundError: Error code: 404 - {'error': {'code': 'DeploymentNotFound', 'message': 'The API deployment for this resource does not exist.**

To Reproduce Steps to reproduce the behavior: My deploy.parameters.json: only two parametes for embedding model/deployment name, but nowhere to set API endpoint like openai api base: { "GRAPHRAG_API_BASE": "https://xxxxxxxx.openai.azure.com/", "GRAPHRAG_API_VERSION": "2024-04-01-preview", "GRAPHRAG_EMBEDDING_DEPLOYMENT_NAME": "text-embedding-3-large", "GRAPHRAG_EMBEDDING_MODEL": "text-embedding-3-large", "GRAPHRAG_LLM_DEPLOYMENT_NAME": "gpt-4o", "GRAPHRAG_LLM_MODEL": "gpt-4o", "LOCATION": "eastus2", "RESOURCE_GROUP": "graphrag-rg3", "RESOURCE_BASE_NAME": "new3" }

Expected behavior Add an embedding model API BASE

Screenshots image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Elizabeth819 commented 1 month ago

I found the reason, the embedding model should be under the same endpoint as the gpt model in the paramerers.json file, and the current embedding model must be ada-002, not 3-large, which will cause another error, saying : here's a mismatch in vector dimensions. The vector field 'vector', with dimension of '1536', expects a length of '1536'. However, the provided vector has a length of '3072'

Elizabeth819 commented 1 month ago

Changed the embedding model to ada-002, and still got the error: "type": "error", "data": "Error executing verb \"text_embed\" in create_final_entities: (OperationNotAllowed) The request is invalid. Details: The maximum number of allowed model errors has been reached.\r\nactions : 0: There's a mismatch in vector dimensions. The vector field 'vector', with dimension of '1536', expects a length of '1536'. However, the provided vector has a length of '3072'. Please ensure that the vector length matches the expected length of the vector field. Read the following documentation for more details: https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-configure-compression-storage.

24601 commented 1 month ago

I think this accelerator/GraphRAG in general assumes an embedding vector length of 1536 (ada 002's max), and text-embedding-3-large is giving you back 3072 (it's max), and given this is a hard coded default max in the current implementation, you may need to ada002 or text-embedding-3-small as its default is 1536 as well, or modify/set the value of vector_size to 3072 at https://github.com/Azure-Samples/graphrag-accelerator/blob/106f1232010a06eeefd852104a0d5cb5dd0123da/backend/src/meta_agent/community/retrieve.py#L279

My guess (just a guess) is that changing it back is not effective b/c there is some saved/cached data that it's still attempting to use. IDK on that, just guessing.