GraphRAG With Python And Neo4j |
Written by Nikos Vaggalis | |||
Tuesday, 20 May 2025 | |||
Use this Neo4j GraphRAG library to build your own knowledge graph-based applications. But why GraphRAG, the concept, in the first place? GraphRAG is an advanced RAG technique which consumes structured and unstructured documents to create knowledge graphs which extract context on top of the vectors. It's that property that renders graph based RAG to provide highly relevant answers to the users' questions. As examined in our previous article,Ingres vs Postgres MVCC Explained With Neo4j's LLM Knowledge Graph Builder, the superiority of GraphRAG stems from that it also manages to capture the context/relationships between the vectors. That article went through a GraphRAG solution that was utilized with Neo4j as the underlying data store, while on the front end used the "LLM Knowledge Graph Builder" application which consumes, parses and provides a UI to the user to interrogate his documents. But that was the full package of a pre-made application. To utilize and customize a GraphRAG solution to your own needs, like building knowledge assistants, search APIs, chatbots, or report generators, you can leverage the underlying GraphRAG for Python library living under package neo4j-graphrag. So to perform a GraphRAG query using the neo4j-graphrag package, a few components are needed first:
The LLMs provided as dependencies when installing the package are :
For instance to install the packge with Mistral you use: pip install "neo4j-graphrag[mistralai]" Then instantiate the MistralAILLM class: from neo4j_graphrag.llm import MistralAILLM llm = MistralAILLM( The other thing you need is the Neo4J Python driver : URI = "neo4j://localhost:7687" Then a LLM for entity extraction, and an embedding model to create vectors on text chunks for similarity search,
And it's open source too and although it requires a Neo4j Graph Database backend, you can opt for the cloud offering of the fully managed AuraDB which comes with a free tier too or just use a dockerized Neo4J instance. More InformationRelated ArticlesIngres vs Postgres MVCC Explained With Neo4j's LLM Knowledge Graph Builder
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Monday, 02 June 2025 ) |