# Atomic GraphRAG Pipelines

Memgraph provides a comprehensive suite of tools and algorithms that make
building GraphRAG systems both efficient and scalable. These tools, known as
"Atomic GraphRAG Pipelines," empower you (or an agent) to implement
sophisticated pipelines as atomic database queries.

Here’s how each feature plays a role in enhancing your Retrieval-Augmented
Generation workflows:

1. [Vector search](https://memgraph.com/docs/querying/vector-search): A pivotal first step for extracting
relevant information during pivot search. Vector search allows you to perform
semantic searches, matching context or meaning rather than exact terms.
2. [Deep-path traversals](https://memgraph.com/docs/advanced-algorithms/deep-path-traversal): Enables
rapid navigation through complex relationships in your graph, supporting
multi-hop queries and reasoning across interconnected data.
3. [Leiden community
detection](https://memgraph.com/docs/advanced-algorithms/available-algorithms/leiden_community_detection):
A faster, more accurate algorithm than Louvain, Leiden ensures well-connected
communities, making it ideal for relevance expansion in retrieval processes.
4. [Louvain](https://memgraph.com/docs/advanced-algorithms/available-algorithms/community_detection) and
[dynamic community
detection](https://memgraph.com/docs/advanced-algorithms/available-algorithms/community_detection_online):
Louvain is a foundational clustering algorithm for discovering communities,
while dynamic community detection adapts in real time, accommodating graph
updates without compromising cluster integrity.
5. [PageRank](https://memgraph.com/docs/advanced-algorithms/available-algorithms/pagerank) and [dynamic
PageRank](https://memgraph.com/docs/advanced-algorithms/available-algorithms/pagerank_online):
PageRank ranks nodes based on their influence or importance. Its dynamic
counterpart adjusts these rankings as new data is ingested, ensuring retrieval
results remain relevant.
6. [Text search](https://memgraph.com/docs/querying/text-search): Facilitates keyword-based searches,
allowing you to locate specific entities or relationships within your graph
quickly. This complements vector search for hybrid retrieval strategies.
7. [Geospatial search](https://memgraph.com/docs/fundamentals/data-types#point): Geospatial search
enables you to integrate and retrieve location-based insights, enhancing the
relevance and precision of responses.
8. [Run-time schema tracking under `SHOW SCHEMA INFO`
query](https://memgraph.com/docs/querying/schema#run-time-schema-tracking): Tracks schema changes as they
happen, enabling seamless updates and adaptations in your graph structure
without manual intervention. This is especially useful if you're including
schema into the LLM context.
9. [Real-time data ingestion](https://memgraph.com/docs/data-streams): Memgraph supports seamless
integration with streaming platforms like Kafka, Redpanda, and Pulsar, allowing
you to continuously grow and update your knowledge graph. Combine this
with [Memgraph MAGE](https://memgraph.com/docs/advanced-algorithms) or [custom
procedures](https://memgraph.com/docs/custom-query-modules) to dynamically query and analyze incoming
data.
10. Embedding procedures [`embeddings.text` and
`embeddings.node_sentence`](https://memgraph.com/docs/advanced-algorithms/available-algorithms/embeddings):
Offer the ability to compute embeddings during the preprocessing or retrieval
stages.
11. [`llm.complete`](https://memgraph.com/docs/advanced-algorithms/available-algorithms/llm) function:
Allows you to call any LLM under any given Cypher query.
12. [Server-side parameters](https://memgraph.com/docs/database-management/server-side-parameters): Could
be used for many different things, but in this context, the parameters help you
with managing configuration under any given query or pipeline.
13. [Server-side descriptions](https://memgraph.com/docs/database-management/server-side-descriptions):
Annotate labels, edge types and properties with human-readable descriptions
that are persisted in the database and surfaced through `SHOW SCHEMA INFO`.
This enriches the schema you hand to the LLM with domain knowledge that the
names alone don't convey (units, value ranges, how a label relates to upstream
systems), which improves the quality of generated Cypher and retrieval.

## Question and Pipeline Types

With these building blocks, you can design a tailored GraphRAG pipeline to
answer any type of question in the most effective way. There is a logical
progression in how these pipelines are applied: **Text2Cypher** is the most
precise and efficient option when a concrete value or node in the graph directly
contains the answer. If the answer isn’t encapsulated in a single node or
relationship, a form of **QFS** (Query-Focused Summarization) comes into play,
synthesizing information from across the entire dataset to construct an
appropriate response.

- **Analytical** - When the answer exists as a concrete value in your graph and
you need an exact, deterministic result, use
[Text2Cypher](https://memgraph.com/docs/ai-ecosystem/graph-rag/atomic-pipelines/text2cypher). The system
translates your natural language question into a Cypher query, so you never need
to learn the query language yourself. This works well for business metrics that
live as properties on nodes or relationships: *"What is the CAC for our
enterprise segment last quarter?"*, *"Which portfolio companies have an ROI above
30%?"*, or *"How many open invoices are tied to this customer?"*

- **Local** - To retrieve a focused, contextually-rich subgraph rather than a
single value, use [Local Graph Search](https://memgraph.com/docs/ai-ecosystem/graph-rag/atomic-pipelines/local-graph-search).
A vector search surfaces the most semantically relevant entry point, and then
graph traversal expands outward through relationships to gather surrounding
context. The classic example: searching for *"Ronaldo"* in a sports
recommendation graph should return Cristiano Ronaldo first, but the second
result should be Messi, not the Brazilian Ronaldo, because the graph encodes
co-occurrence and engagement patterns showing that users who interact with
Cristiano Ronaldo content are far more likely to engage with Messi content next.
The relationship matters more than the name.

- **Global** - For questions that cannot be answered by finding something
specific in the dataset, but instead require reasoning across the entire corpus
to surface what is absent, underrepresented, or emergent, apply [Query-focused
Summarization](https://memgraph.com/docs/ai-ecosystem/graph-rag/atomic-pipelines/query-focused-summarization).
QFS can also be used as the inverse of local search: instead of retrieving what
exists, it synthesizes what is missing or not well-covered. Example use cases:
  - **Legal**: Given millions of case files and a new incoming case, *"What are
  the recommended next steps and which precedents are most relevant to
  upsell?"*
  - **Finance**: Given a corpus of S-1 filings, *"What risks or topics does this
  sector consistently fail to address?"* or *"What does Nvidia's S-1 not cover
  compared to peers?"*
  - **Publishing**: *"I want to write a book, which important topics in this
  domain are not yet well covered in the existing literature?"*

![atomic_graphrag_pipelines](https://memgraph.com/docs/pages/ai-ecosystem/graph-rag/atomic-pipelines/atomic-graphrag-pipelines.png)
