Atomic GraphRAG
Atomic GraphRAG runs a whole GraphRAG retrieval as one Cypher query. Memgraph finds the entities a question is about, expands to the context around them, ranks the results and assembles the prompt in one database operation, so an application or agent sends one query instead of coordinating several services.
Building blocks
A retrieval query combines these Memgraph features:
- Vector search: Finds nodes by semantic similarity. It’s usually the first step of a retrieval, called pivot search.
- Text search: Finds nodes by the words in their properties. Combine it with vector search for hybrid retrieval.
- Geospatial search: Finds nodes by location,
with the
Pointtype and point indexes. - Deep path traversals: Follow relationships across many hops, for multi-hop questions.
- Leiden community detection: Groups closely connected nodes into communities, for relevance expansion and query-focused summarization.
- Louvain and dynamic community detection: Group nodes into communities. The dynamic version updates the communities as the graph changes.
- PageRank and dynamic PageRank: Rank nodes by influence. The dynamic version updates the ranks as new data arrives.
SHOW SCHEMA INFO: Returns the current schema of the graph, which you can include in the LLM prompt.- Server-side descriptions:
Describe labels, edge types and properties in the database.
SHOW SCHEMA INFOreturns the descriptions, so the LLM gets the units, value ranges and meaning that names alone don’t convey. embeddings.textandembeddings.node_sentenceprocedures: Compute embeddings inside Memgraph, while loading data or at query time.llm.completefunction: Calls an LLM from a Cypher query, for example to summarize the retrieved context.- Server-side parameters: Store configuration, such as thresholds or model names, in the database and use it in any query.
- Data streams: Keep the knowledge graph up to date from Kafka, Redpanda or Pulsar.
Choose a pipeline
Choose the pipeline by where the answer is. Start with the most precise one that can answer the question:
- Analytical: The answer is a value in the graph, and you need an exact result. Use Text2Cypher, which turns the question into a Cypher query. It suits metrics stored as properties: “Which portfolio companies have an ROI above 30%?” or “How many open invoices are tied to this customer?”
- Local: The answer is a subgraph around one entity. Use Local graph search: vector search finds the entity, and graph traversal expands to the context around it. In a sports recommendation graph, a search for “Ronaldo” returns Cristiano Ronaldo first and Messi second, not the Brazilian Ronaldo, because the relationships show that users who engage with one engage with the other.
- Global: The answer needs reasoning across the whole dataset, including what is missing or underrepresented. Use Query-focused summarization, which summarizes communities of the graph and combines the summaries. For example, given a corpus of S-1 filings: “Which risks does this sector consistently fail to address?”
To see how the three pipelines fit together, see the diagram on GraphRAG.