QAFD-RAG is a graph-based retrieval-augmented generation framework that uses query-aware flow diffusion to retrieve contextually relevant subgraphs from a knowledge graph with statistical retrieval guarantees.
Existing graph-based RAG methods rely on static retrieval—community detection (GraphRAG) or one-hop entity lookup (LightRAG)—that ignore query context and miss relevant multi-hop connections.
QAFD-RAG dynamically re-weights graph edges based on query relevance and propagates flow through the knowledge graph to discover multi-hop context, assembling a query-specific subgraph for the LLM.
How different retrieval strategies explore a knowledge graph



Comparison on Wikipedia pages (Apple fruit, Apple Inc., Amazon River, Amazon.com). Query: "Introduce Steve Jobs's products in Apple." GraphRAG retrieves entire communities, mixing relevant nodes with irrelevant ones. LightRAG focuses on 1-hop neighborhoods. QAFD-RAG reweights edges by query meaning, suppressing irrelevant neighborhoods.
A two-stage pipeline from raw documents to grounded LLM answers
Evaluated across diverse retrieval and generation tasks
Embeddings: openai-small · openai-large · jina-v3 · gritlm · nvidia-nv-embed-v2
LLMs: gpt-4o-mini · gpt-4o · gpt-5-nano · gpt-5-mini · gpt-5 · gpt-oss-120b
# 1. Install dependencies
pip install -r requirements.txt
# 2. Set your OpenAI API key
export OPENAI_API_KEY="sk-..."
# 3. Build a knowledge graph
./run.sh ultradomain --build --max-documents 100
# 4. Run a benchmark
./run.sh ultradomain --questions 10
from src import QAFD_RAG, QueryParam
rag = QAFD_RAG(
working_dir="./my_kg",
llm_model_name="gpt-4o-mini",
embedding_model_key="jina-v3",
)
# Index documents
rag.insert(["Document text 1...", "Document text 2..."])
# Query
answer = rag.query("What is X?", param=QueryParam(mode="hybrid"))
print(answer)
@inproceedings{zhou2026qafd,
title={Query-Aware Flow Diffusion for Graph-Based RAG with Retrieval Guarantees},
author={Zhuoping Zhou and Davoud Ataee Tarzanagh and Sima Didari and Wenjun Hu
and Baruch Gutow and Oxana Verkholyak and Masoud Faraki and Heng Hao
and Hankyu Moon and Seungjai Min},
booktitle={International Conference on Learning Representations (ICLR)},
year={2026}
}