Neo4j AI: GraphRAG, Knowledge Graphs & Generative AI

Hao Wu
Software Engineer
No items found.
|
September 2, 2026
Neo4j AI: GraphRAG, Knowledge Graphs & Generative AI

Neo4j gives AI applications a way to retrieve context by both meaning and relationship. Vector search can find content similar to a question, while a property graph can follow typed connections among the entities in that content. The combination matters when an answer depends on how several facts connect, not merely on finding a passage that resembles the prompt.

This guide explains how Neo4j fits into generative AI, retrieval-augmented generation (RAG), knowledge graphs, GraphRAG, vector search, and agentic systems. It also covers the architecture, use cases, benefits, and operational trade-offs involved in putting a graph on an AI application's retrieval path.

What is Neo4j AI?

Neo4j AI is a useful name for the set of Neo4j capabilities used to build machine learning and generative AI applications. It is not one feature or a separate database engine. The foundation is Neo4j's property graph database, where nodes represent entities, relationships connect them, and both can carry properties. Cypher queries retrieve paths and patterns from that model.

Several components add AI-specific functions. Neo4j database vector indexes support similarity search over embeddings. The Neo4j GraphRAG for Python package supplies retrievers, generation interfaces, and a knowledge graph construction pipeline. The Graph Data Science library provides graph algorithms, node embeddings, and machine learning pipelines. Aura Agent offers a managed path for creating agents over graphs in AuraDB, while Neo4j MCP exposes graph tools to compatible clients.

The common idea is connected context. An AI system can start with a natural-language question, identify relevant entities or documents, traverse the graph around them, and provide the resulting facts and paths to a model. Neo4j stores and queries the connected data; an external model still performs language generation unless an integrated service handles that orchestration.

How does Neo4j work with AI?

Neo4j usually participates in two stages of an AI workflow: preparing connected knowledge and retrieving it at inference time. Data may arrive from operational systems, files, APIs, or document collections. A pipeline maps structured records directly into nodes and relationships or extracts entities and relationships from unstructured text. Entity resolution then attempts to merge mentions that refer to the same real-world object.

At query time, an application turns the user's input into one or more retrieval operations. It might embed the question and run vector similarity search, generate a Cypher query from the question, perform keyword search, or combine these methods. A traversal can expand an initial match to related people, products, events, citations, or documents. The application formats that subgraph as context and sends it to a large language model (LLM), which produces the response.

Neo4j can also support predictive work outside generative AI. The Graph Data Science workflow loads a graph projection into an analytical in-memory representation, runs algorithms, and streams or writes results. Its node embeddings can become features for node classification, link prediction, or structural similarity search. This is graph machine learning rather than RAG, though both approaches can use embeddings.

Neo4j AI architecture

A production Neo4j AI architecture can be understood in five layers:

Source and ingestion. Structured data is exported or streamed from source systems, while documents are parsed and split into chunks. The pipeline assigns stable identifiers and retains provenance so an answer can be traced to its source.

Graph and semantic model. Neo4j stores the property graph. Labels, relationship types, properties, and constraints encode the domain model. Document-oriented graphs often retain Document and Chunk nodes alongside extracted entities so retrieval can move between source text and structured facts.

Indexes and analytics. Neo4j's range, text, full-text, and vector indexes provide different entry points. Graph Data Science may compute centrality, communities, similarity, or embeddings in a separate in-memory projection, then write selected results back to the database.

Retrieval and orchestration. Application code or the GraphRAG package selects a retriever, executes vector or Cypher searches, expands matches through the graph, and assembles context. The LLM, embedding model, reranker, and prompt layer commonly remain external services.

Serving and operations. An API, chat interface, or agent consumes the answer. Authentication, authorization, monitoring, evaluation, and feedback surround the retrieval path. Neo4j can run as a standalone database, in an Enterprise Edition cluster with primaries and read-scaling secondaries, or as the managed AuraDB service.

Figure: Neo4j combines semantic, lexical, and graph retrieval before generation, while evaluation and access control surround the serving path.

The important boundary is between storage, retrieval, and generation. Calling the whole stack Neo4j AI should not hide the separate model providers, data pipelines, and application controls that make the system work.

Neo4j for generative AI

Generative models are good at synthesizing language but do not contain a current, authoritative copy of an organization's private facts. Neo4j supplies external context in a form that preserves identity and relationships. A model can receive not only a document chunk about a service outage, for example, but also the affected service, its upstream dependencies, the teams that own them, and the incidents linked to the same component.

The graph can also make generation easier to inspect. A Cypher result can preserve the path connecting two entities, and the application can attach source documents to the nodes or claims along that path. This does not make an LLM's answer automatically correct. It gives evaluators concrete retrieval evidence to compare with the generated response.

Neo4j's Python package supports multiple model providers through provider-specific integrations behind a common interface rather than requiring a particular LLM. That separation lets teams change generation or embedding models while keeping the graph schema and retrieval logic stable. In practice, model portability still requires regression tests because providers differ in tool calling, structured output, context limits, and text-to-Cypher behavior.

Neo4j for retrieval-augmented generation (RAG)

RAG retrieves external information before asking a model to answer. A basic pipeline embeds the user's question, finds similar text chunks, inserts them into a prompt, and calls the LLM. Neo4j can implement this baseline because embeddings may be stored as node or relationship properties and queried through a vector index.

The graph becomes useful after the initial match. Neo4j's VectorCypherRetriever runs vector search and then executes a configurable Cypher retrieval query, which can traverse the graph to gather connected context around the matched node. A hybrid retriever combines vector and full-text retrieval, while Text2Cypher translates a natural-language question into a Cypher query. These are distinct strategies and can be routed by question type.

For example, semantic search could locate a chunk describing a supplier. A Cypher expansion could then return the parts that supplier provides, the products containing those parts, and open disruptions affecting the relevant facilities. The first step handles fuzzy language; the second follows explicit relationships. RAG quality depends on both: finding the right entry point and expanding only the context needed to answer.

Neo4j knowledge graphs for AI

A knowledge graph represents a domain as identifiable entities, typed relationships, and properties. In Neo4j, a compact supply-chain pattern might look like this:

MATCH path = (supplier:Supplier)-[:SUPPLIES]->(:Part)
             -[:USED_IN]->(product:Product)
WHERE supplier.name = $supplierName
RETURN product.name, path

This query asks a relationship question directly. The returned path records why each product is in the answer. A relational implementation can answer the same question with joins, but the graph model makes variable-length and multi-hop relationship patterns central to the query language.

Building a reliable knowledge graph is largely a data-modeling and data-quality task. Teams must define entity boundaries, relationship direction and meaning, identifiers, provenance, and update rules. Unstructured documents add extraction uncertainty: an LLM may miss a relation, assign the wrong type, or create duplicate entities. Neo4j's knowledge graph builder includes loaders, splitters, schema construction, entity and relation extraction, pruning, writing, and entity resolution, but its documentation marks the feature as experimental. Human review and domain-specific evaluation still belong in the pipeline.

Neo4j GraphRAG

GraphRAG is RAG that uses graph structure during retrieval. The term covers several designs. Some systems create an entity graph from documents and retrieve neighborhoods around matched entities. Others generate Cypher against an existing enterprise knowledge graph. A hybrid design may use vector or full-text search for candidate discovery, then graph traversal for context expansion.

Neo4j's GraphRAG package supports these patterns through specialized retrievers. VectorRetriever returns similar nodes and their scores. VectorCypherRetriever runs configurable Cypher after vector search, which can traverse the graph for more context. HybridRetriever searches vector and full-text indexes. Text2Cypher generates and executes Cypher from a question. ToolsRetriever lets an LLM select among configured tools. The package's GraphRAG generation layer formats retrieved context into a prompt and calls the LLM.

GraphRAG is most useful when graph expansion adds evidence that chunk similarity would miss. It can connect aliases to a canonical entity, follow dependencies across systems, or gather facts distributed among several documents. It can also retrieve irrelevant neighborhoods if the graph is noisy or the traversal is too broad. Good implementations constrain relationship types and hop counts, preserve source attribution, limit context size, and evaluate retrieval separately from generation.

Neo4j vector search for AI applications

Neo4j vector indexes provide approximate nearest-neighbor search over embeddings stored on nodes or relationships. Applications commonly embed document chunks, products, cases, or entities. They embed the incoming query with the same model, search the relevant index, and use the closest results as retrieval candidates. Neo4j's vector index documentation describes the current Cypher interface and index behavior.

Keeping embeddings and graph entities together reduces identifier reconciliation between a vector store and a graph database. It also allows a query to apply graph logic after similarity search. A matched Chunk can lead to its Document, extracted entities, and related records without an application-side join. External vector stores remain an option: the GraphRAG package includes retrievers that map results from supported external systems back to Neo4j nodes.

Vector similarity is a ranking signal, not proof that a result answers the question. Approximate search can miss neighbors, raw scores from different retrieval systems are not directly comparable, and an embedding can reflect topical resemblance without factual relevance. Production pipelines often add metadata filters, lexical retrieval, reranking, graph constraints, and an abstention threshold. Evaluation should measure whether the required evidence appears in the retrieved context, not just whether the generated answer sounds plausible.

Neo4j AI agents and agentic AI

An AI agent chooses and sequences actions rather than performing one fixed retrieval call. Neo4j can serve as a knowledge source, memory store, or tool endpoint in that loop. An agent might inspect the graph schema, generate a read query, examine the result, and issue a narrower follow-up query before composing an answer.

Neo4j MCP exposes schema inspection and Cypher tools to MCP-compatible clients. Its documented read-only mode removes the write tool, while the read tool rejects writes and administrative operations. This is a useful baseline because an agent that can retrieve context does not necessarily need permission to mutate the graph. Applications still need least-privilege database credentials, query limits, logging, and approval gates for consequential actions.

Aura Agent provides a managed, no-code or low-code route for building and testing GraphRAG agents over an AuraDB knowledge graph. It can expose an agent through an API or MCP endpoint, and its current database tools are read-only. For custom systems, the GraphRAG package's Text2Cypher and ToolsRetriever components provide lower-level building blocks. In either path, schema grounding reduces invalid queries but does not eliminate incorrect reasoning, over-broad retrieval, or prompt injection elsewhere in the application.

Neo4j AI use cases

Enterprise search and question answering. A graph connects passages to products, policies, owners, and source documents. Retrieval can combine language similarity with the relationships needed to answer cross-document questions.

Fraud and financial crime investigation. Accounts, devices, identities, transactions, merchants, and addresses form a network. Graph traversals and algorithms can surface shared infrastructure or suspicious communities, while a generative interface summarizes the supporting paths for an investigator.

Cybersecurity operations. Assets, identities, vulnerabilities, alerts, and services can be modeled as connected entities. An assistant can trace exposure paths or gather the context around an alert, provided the graph remains current and authorization is enforced at retrieval time.

Life sciences and research. Publications, compounds, genes, diseases, trials, and researchers have explicit relationships. GraphRAG can assemble evidence across these entity types and retain links back to the originating literature.

Recommendations and customer support. Products, users, cases, symptoms, fixes, and compatibility rules can support recommendation or troubleshooting flows. Graph structure supplies hard constraints and related items; vector search handles free-form descriptions.

Across these cases, the graph earns its place when relationships affect the answer. A document-only corpus with independent questions may be served adequately by simpler vector RAG.

Benefits of using Neo4j for AI

Connected retrieval. Cypher can follow typed, multi-hop paths after a semantic or lexical match. This helps answer questions whose evidence is distributed across entities and documents.

One retrieval surface for several signals. Neo4j can hold graph facts, text, metadata, and embeddings, with full-text, vector, and graph retrieval available from the same database. That can simplify identifier management and post-retrieval expansion.

Traceable context. Paths and source links give an application evidence it can display, cite, log, and evaluate. Traceability supports review, though it does not by itself prove that the generated interpretation is valid.

Graph analytics alongside retrieval. Community detection, centrality, similarity, pathfinding, and node embeddings can enrich the facts an AI application retrieves. Computed properties can become filters, ranking features, or additional context.

Flexible deployment and tooling. Teams can use self-managed Neo4j or AuraDB, query through official drivers and Cypher, assemble a custom Python retrieval pipeline, or use managed agent tooling. The breadth is useful when the team already operates Neo4j or the application's domain is naturally graph-shaped.

These benefits matter most when retrieval repeatedly crosses entity relationships and the graph can serve as shared context for search, analytics, and generation.

Challenges of using Neo4j for AI

The graph must be designed and maintained. A useful schema depends on domain decisions about identity, relationships, provenance, and access. Automated extraction accelerates construction but also creates duplicates, unsupported relations, and missed facts that require evaluation and cleanup.

Materializing a stored graph creates another lifecycle. When external records are copied into a Neo4j stored graph, the deployment needs an ingestion or synchronization path. Freshness objectives, deletion propagation, schema changes, failed jobs, and backfills become part of the system's operating contract. Neo4j Virtual Graph provides a public-preview alternative for supported Databricks and Snowflake lakehouses. It translates Cypher to SQL without moving or extracting the source data, although Neo4j advises against using sensitive or production data during the preview.

Retrieval adds several tuning surfaces. Chunking, embedding models, vector indexes, entity linking, Cypher generation, traversal breadth, reranking, and prompt construction can each fail independently. End-to-end answer scoring alone makes diagnosis difficult, so teams need retrieval-level test sets and telemetry.

Resource and governance requirements grow with the stack. Graph storage, analytical projections, embedding generation, LLM calls, and agent orchestration have separate capacity and security concerns. Text-to-Cypher and tool use need schema-aware authorization and query controls, especially if writes are enabled.

When authoritative data already lives in SQL databases, data warehouses, or data lakes and lakehouses, several architectures can query it as a graph without creating a separate graph copy. PuppyGraph defines a graph schema over those existing tables as an ontology layer and queries them in place on its default direct-query path, including direct reads of open table formats such as Apache Iceberg and Delta Lake. It validates generated queries against the ontology before execution and returns structured feedback when an agent refers to entities or relationships outside the schema. PuppyGraph speaks openCypher over the Bolt protocol and also supports Gremlin, so Neo4j drivers and applications that use compatible openCypher can be repointed without a graph-data export and import step.

Neo4j Virtual Graph also addresses the no-copy case for its supported lakehouse sources and retains access to Neo4j tooling such as Browser, Bloom, GDS, and Copilot. Its execution model differs from PuppyGraph's: Virtual Graph translates Cypher to SQL for the source engine, while PuppyGraph compiles graph queries into node and edge operators that run in its own distributed engine and sends the source only simple projection and filter SQL. Because the query is represented as graph operators end to end, PuppyGraph can optimize specifically for multi-hop traversals. A stored Neo4j graph remains the direct architecture when the graph database itself is authoritative. When tables remain authoritative, teams should compare source coverage, preview maturity, execution placement, and operating requirements.

Conclusion

Neo4j supports AI by putting connected data, graph traversal, vector search, and graph analytics on the same retrieval path. Its GraphRAG package covers knowledge graph construction and several retrieval patterns, while Neo4j MCP and Aura Agent expose graph-backed context to agentic applications. The architecture is strongest when an answer depends on relationships that flat chunk retrieval would leave implicit.

The work extends beyond selecting a retriever. Teams still need a sound domain model, reliable ingestion, entity resolution, source attribution, authorization, retrieval evaluation, and controls around generated queries. Those requirements determine whether a graph improves an AI system's evidence or merely adds another layer to operate.

Try the forever-free PuppyGraph Developer Edition and book a demo with the team to see how openCypher and Gremlin queries traverse warehouse and lakehouse tables, with no graph-specific ETL, while an enforced ontology grounds agent-generated queries in the domain model.

No items found.
Hao Wu
Software Engineer

Hao Wu is a Software Engineer with a strong foundation in computer science and algorithms. He earned his Bachelor’s degree in Computer Science from Fudan University and a Master’s degree from George Washington University, where he focused on graph databases.

Get started with PuppyGraph!

PuppyGraph empowers you to seamlessly query one or multiple data stores as a unified graph model.

Dev Edition

Free Download

Enterprise Edition

Developer

$0
/month
  • Forever free
  • Single node
  • Designed for proving your ideas
  • Available via Docker install

Enterprise

$
Based on the Memory and CPU of the server that runs PuppyGraph.
  • 30 day free trial with full features
  • Everything in Developer + Enterprise features
  • Designed for production
  • Available via AWS AMI & Docker install
* No payment required

Developer Edition

  • Forever free
  • Single noded
  • Designed for proving your ideas
  • Available via Docker install

Enterprise Edition

  • 30-day free trial with full features
  • Everything in developer edition & enterprise features
  • Designed for production
  • Available via AWS AMI & Docker install
* No payment required