What’s a Information Graph?
To know why one could use a Information Graph (KG) as an alternative of one other structured information illustration, it’s vital to acknowledge its deal with specific relationships between entities—equivalent to companies, folks, equipment, or prospects—and their related attributes or options. In contrast to embeddings or vector search, which prioritize similarity in high-dimensional areas, a Information Graph excels at representing the semantic connections and context between information factors. A primary unit of a data graph is a reality. Info might be represented as a triplet in both of the next methods:
Two easy KG examples are proven beneath. The left instance of a reality could possibly be

Now that you just perceive the importance of semantics in Information Graphs, let’s introduce you to the dataset we’ll use within the upcoming code examples: the BloodHound dataset. BloodHound is a specialised dataset designed for analyzing relationships and interactions inside Lively Listing environments. It’s broadly used for safety auditing, assault path evaluation, and gaining insights into potential vulnerabilities in community constructions.
Nodes within the BloodHound dataset characterize entities inside an Lively Listing surroundings. These usually embody:
- Customers: represents particular person consumer accounts within the area.
- Teams: represents safety or distribution teams that combination customers or different teams for permission assignments.
- Computer systems: represents particular person machines within the community (workstations or servers).
- Domains: represents the Lively Listing area that organizes and manages customers, computer systems, and teams.
- Organizational Models (OUs): represents containers used for structuring and managing objects like customers or teams.
- GPOs (Group Coverage Objects): represents insurance policies utilized to customers and computer systems inside the area.
An in depth description of node entities is accessible right here. Relationships within the graph outline interactions, memberships, and permissions between nodes; a full description of the sides is accessible right here.

When to decide on GraphRAG over Conventional RAG
The first benefit of GraphRAG over customary RAG lies in its capability to carry out precise matching throughout the retrieval step. That is made doable partly by explicitly preserving the semantics of pure language queries in downstream graph question language. Whereas dense retrieval methods based mostly on cosine similarity excel at capturing fuzzy semantics and retrieving associated info even when the question is not a precise match, there are instances the place precision is crucial. This makes GraphRAG significantly precious in domains the place ambiguity is unacceptable, equivalent to compliance, authorized, or extremely curated datasets.
That stated, the 2 approaches should not mutually unique and are sometimes mixed to leverage their respective strengths. Dense retrieval can solid a large internet for semantic relevance, whereas the data graph refines the outcomes with precise matches or reasoning over relationships.
When to decide on Conventional RAG over GraphRAG
Whereas GraphRAG has distinctive benefits, it additionally comes with challenges. A key hurdle is defining the issue accurately—not all information or use instances are well-suited for a Information Graph. If the duty entails extremely unstructured textual content or doesn’t require specific relationships, the added complexity will not be value it, resulting in inefficiencies and suboptimal outcomes.
One other problem is structuring and sustaining the Information Graph. Designing an efficient schema requires cautious planning to steadiness element and complexity. Poor schema design can impression efficiency and scalability, whereas ongoing upkeep calls for assets and experience.
Actual-time efficiency is one other limitation. Graph databases like Neo4j can wrestle with real-time queries on giant or often up to date datasets because of complicated traversals and multi-hop queries, making them slower than dense retrieval techniques. In such instances, a hybrid method—utilizing dense retrieval for pace and graph refinement for post-query evaluation—can present a extra sensible answer.
GraphDB and embeddings
Graph DBs like Neo4j typically additionally present vector search capabilities through HNSW indexes. The distinction right here is how they use this index with the intention to present higher outcomes in comparison with vector databases. If you carry out a question, Neo4j makes use of the HNSW index to determine the closest matching embeddings based mostly on measures like cosine similarity or Euclidean distance. This step is essential for locating a place to begin in your information that aligns semantically with the question, leveraging the implicit semantics given by the vector search.
What units graph databases aside is their capability to mix this preliminary vector-based retrieval with their highly effective traversal capabilities. After discovering the entry level utilizing the HNSW index, Neo4j leverages the specific semantics outlined by the relationships within the data graph. These relationships permit the database to traverse the graph and collect further context, uncovering significant connections between nodes. This mix of implicit semantics from embeddings and specific semantics from graph relationships permits graph databases to supply extra exact and contextually wealthy solutions than both method may obtain alone.
Finish-to-Finish GraphRAG in Databricks
GraphRAG is a superb instance of Compound AI techniques in motion, the place a number of AI parts work collectively to make retrieval smarter and extra context-aware. On this part, we’ll take a high-level take a look at how every part matches collectively.
GraphRAG Structure
Under is an structure diagram demonstrating how an analyst’s pure language questions can retrieve info from a Neo4j data graph.

The structure for GraphRAG-powered risk detection combines the strengths of Databricks and Neo4j:
- Safety Operations Middle (SOC) Analyst Interface: Analysts work together with the system by means of Databricks, initiating queries and receiving alert suggestions.
- Databricks Processing: Databricks handles information processing, LLM integration, and serves because the central hub for the answer.
- Neo4j Information Graph: Neo4j shops and manages the cybersecurity data graph, enabling complicated relationship queries.
Implementation Overview
For this weblog, we’re skipping the code particulars—try the GitHub repository for the complete implementation. Let’s stroll by means of the important thing steps to construct and deploy a GraphRAG agent.
- Construct a Information Graph from Delta Tables: Within the pocket book, we mentioned eventualities about structured information and unstructured information. The Neo4j Spark Connector gives a quite simple means of reworking information in Unity Catalog into graph entities (nodes/relationships).
- Deploy LLMs for Cypher Question and QA: GraphRAG requires LLMs for question technology and summarization. We demonstrated how one can deploy gpt-4o, llama-3.x, a fine-tuned text2cypher mannequin from HuggingFace and serve them utilizing a provisioned throughput endpoint.
- Create and Take a look at GraphRAG Chain: We demonstrated how one can use totally different LLM for Cypher and QA LLMs and prompts through GraphCypherQAChain. This permits us to additional tune with glass-box tracing outcomes utilizing MLflow Tracing.
- Deploy the Agent with Mosaic AI Agent Framework: Use Mosaic AI Agent Framework and MLflow to deploy the agent. Within the pocket book, the method contains logging the mannequin, registering it in Unity Catalog, deploying it to a serving endpoint, and launching a assessment app for chatting.

Conclusion
GraphRAG is a robust but extremely customizable method to constructing brokers that ship extra deterministic, contextually related AI outputs. Nonetheless, its design is case-specific, requiring considerate structure and problem-specific tuning. By integrating data graphs with Databricks’ scalable infrastructure and instruments, you may construct end-to-end Compound AI techniques that seamlessly mix structured and unstructured information to generate actionable insights with deeper contextual understanding.