Hello,
I'm trying to follow the blog "GraphRAG Python Package: Accelerating GenAI With Knowledge Graphs" and the code from its repository. I don't want to use OpenAI stuff since I want to run everything locally, so I'm using the Ollama libraries.
The script runs smoothly until the moment of ingest the first PDF file. After a few seconds I get the following Validation Error:
pydantic_core._pydantic_core.ValidationError: 1 validation error for Neo4jNode
embedding_properties.embedding.0
Input should be a valid number [type=float_type, input_value=[-0.021932466, 0.01252911...0.03033293, 0.014525634], input_type=list]
For further information visit h ttps://errors.pydantic.dev/2.10/v/float_type
.venv\Lib\site-packages\neo4j_graphrag\llm\openai_llm.py", line 138, in ainvoke
response = await self.async_client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\bduran\Documents\Coding\KnowledgeGraphs\Neo4j\graphRAG.venv\Lib\site-packages\openai_utils_utils.py", line 279, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncCompletions.create() got an unexpected keyword argument 'response-format'
I'll appreciate any direction on how to implement a working graphRAG script, especially when using OllamaLLM and OllamaEmbeddings.
Thanks in advance,
Boris
Hi,Its stating that its expecting embedding in one format…but by using the OllamaEmbeddings the embeddings its giving in wrong format…probably like [ [0.123, 0.6482, 0.63748]]but its expection in this formar [ 0.123, 0.673729, 0.9274 ]if u need to use the model OllamaEmbeddings need to extract in proper format just use the below code
from neo4j_graphrag.embeddings.base import Embedder
base_embedder = OllamaEmbeddings(model=model_name, host=embedding_credential)
# Create a wrapper that inherits from the proper base class
class EmbedderWrapper(Embedder):
def __init__(self, base_embedder):
self.base_embedder = base_embedder
def embed_query(self, text: str, **kwargs) -> list[float]:
embedding = self.base_embedder.embed_query(text, **kwargs)
# Fix double-nested list
if isinstance(embedding, list) and len(embedding) > 0 and isinstance(embedding[0], list):
return embedding[0]
return embedding
embedder = EmbedderWrapper(base_embedder)
@Ari_Neo4j I can confirm that this issue has been fixed in neo4j-graphrag version 1.9.1. I tested it with Ollama embeddings and everything works as expected now