HiRAG layers knowledge so RAG can see forest and trees
HiRAG organizes text into a layered knowledge structure so retrieval can zoom in on details, out to themes, or across the bridges that connect them.

What it does
HiRAG is a retrieval-augmented generation system that indexes text into a hierarchical knowledge structure instead of flat chunks or a single-layer graph. At query time it retrieves local facts, global summaries, or “bridge” connections between the two, then feeds the results to an LLM. The code exposes modes such as hi, hi_local, hi_global, and hi_bridge so you can bias toward granularity, breadth, or the glue between them.
The interesting bit Most GraphRAG variants treat the graph as one flat tapestry; HiRAG explicitly separates micro-level entities from macro-level communities and the relations that link them. On the UltraDomain benchmark the authors report winning nearly every head-to-head comparison against GraphRAG, LightRAG, NaiveRAG, FastGraphRAG, and KAG—often by wide margins—using LLM-as-judge metrics for comprehensiveness, empowerment, and diversity.
Key highlights
- Hierarchical retrieval modes: query local knowledge, global themes, bridge edges, or a combined
himix. - Benchmark sweep: outscores GraphRAG, LightRAG, NaiveRAG, FastGraphRAG, and KAG across legal, CS, agriculture, and mixed-domain datasets in the provided evaluation tables.
- Pluggable LLM backends: works with OpenAI, DeepSeek, and ChatGLM APIs via config files and example scripts.
- Academic backing: accepted to EMNLP 2025 Findings; evaluation uses the public UltraDomain dataset.
- Successor noted: the authors flag re-indexing cost as a pain point and point to their newer DeepRefine project for test-time refinement.
Caveats
- The evaluation margins against some baselines (notably FastGraphRAG and KAG) are extremely lopsided—often 95–100 % win rates—which suggests the benchmark or judge may favor HiRAG’s specific output style; treat the tables as project-reported, not independent verification.
- The quick-start parameter is spelled
enable_hierachical_mode(missing the second r), so check your kwargs. - Generation and evaluation both require calling external LLM APIs; there is no fully offline path shown in the README.
Verdict Worth a look if you are building RAG over heterogeneous domains and suspect a flat graph is losing either fine details or big-picture context. Skip it if you need a fully offline pipeline or if your current chunk-and-embed setup already feels good enough.
Frequently asked
- What is hhy-huang/HiRAG?
- HiRAG organizes text into a layered knowledge structure so retrieval can zoom in on details, out to themes, or across the bridges that connect them.
- Is HiRAG open source?
- Yes — hhy-huang/HiRAG is open source, released under the MIT license.
- What language is HiRAG written in?
- hhy-huang/HiRAG is primarily written in Python.
- How popular is HiRAG?
- hhy-huang/HiRAG has 555 stars on GitHub.
- Where can I find HiRAG?
- hhy-huang/HiRAG is on GitHub at https://github.com/hhy-huang/HiRAG.