Model or dataset
iMoonLab/Hyper-RAG avatar
iMoonLab/Hyper-RAG

Hyper-RAG: hypergraph retrieval for medical question answering

"Hyper-RAG: Combating LLM Hallucinations using Hypergraph-Driven Retrieval-Augmented Generation" by Yifan Feng, Hao Hu, Shihui Ying, Xingliang Hou, Shiquan Liu, Mingyuan Yang, Junchang Li, Shaoyi Du, Nanning Zheng, Han Hu, and Yue Gao.

320 stars53 forksPythonApache-2.0

At a glance

What is it?
Hyper-RAG replaces pairwise knowledge graphs with hypergraphs so that retrieval can return multi-entity facts. The repository ships a demo, a stepwise pipeline and a Docker path, but the README leaves configuration and evaluation partly to the paper.
Who is it for?
Adopt Hyper-RAG if your questions hinge on facts that span three or more entities and you can supply an OpenAI-compatible LLM and embedding endpoint, since the whole pipeline is configured through LLM_BASE_URL, LLM_API_KEY, EMB_BASE_URL, EMB_API_KEY and EMB_DIM in my_config.py. Do not adopt it if you need a self-contained local model stack or a documented, reproducible benchmark harness, because the README points evaluation at the paper and the dataset at external drives.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 81 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The hallucination problem Hyper-RAG targets, and the domain it assumes

General RAG splits a corpus into chunks, embeds them, and returns the nearest chunks to a question. That works when the answer sits inside one chunk. It fails when the answer is a relation spread across several sentences: a drug, a dosage, a patient subgroup, and an interaction that only matters together. Chunk retrieval returns one fragment and the model fills the rest from parametric memory, which is where hallucination enters.

The README frames the target domain narrowly. The abstract describes medical integration as cautious because "generated content deviates from factual accuracy, potentially leading to adverse outcomes," and the reported experiments run on a NeurologyCorp dataset with six LLMs. The project is therefore aimed at teams building question answering over dense, entity-rich technical corpora: clinical notes, pharmacology references, regulatory filings, engineering standards. If your corpus is conversational support tickets, the hypergraph construction cost is probably not repaid.

Note the naming inconsistency in the repository itself. The abstract says NeurologyCrop in one place and NeurologyCorp elsewhere, and the feature list repeats the NeurologyCorp spelling. That is a small thing, but it is the kind of detail that tells you the README was assembled from paper text rather than written for someone following it line by line.

Hypergraph modeling: what changes compared with a pairwise knowledge graph

The mechanism the project is built on is a shift in the unit of knowledge. A conventional graph stores edges between two nodes. The README's own framing is that hypergraphs model "the beyond-pairwise relationship among entities, which is more powerful than the pairwise relationship in traditional graph modeling," and that this avoids "the information loss caused by the pairwise relationship."

Concretely, a hyperedge can join three or more entities at once. A clinical statement that links a condition, a medication, a dosage range and a contraindication becomes one retrievable unit instead of three separate binary edges that must be reassembled at query time. The extraction illustration in the repository distinguishes low-order correlations (blue arrows) from high-order correlations (red arrows), with the original entity and correlation descriptions kept in separate boxes. So the pipeline appears to do two things: extract entities, then extract the relations among them at more than one arity.

Retrieval sits on top of that structure through Hypergraph-DB, a separate project from the same lab that the README calls the "native hypergraph database" and credits with "supporting rapid retrieval of higher-order associations." That dependency matters for anyone evaluating the project, because the retrieval performance characteristics live in a different repository with its own release cycle. The README does not describe the query algorithm: how a question is mapped onto hyperedges, whether traversal is bounded by hop count, or how candidate hyperedges are ranked before being placed in the prompt. That is a real gap for a system whose whole claim rests on retrieval quality.

Getting it running: clone, config, demo

Installation is a clone plus a requirements install. The README gives exactly three commands: git clone https://github.com/iMoonLab/Hyper-RAG.git, cd Hyper-RAG, and pip install -r requirements.txt. There is no packaging step, no pyproject.toml mentioned, and no version pinning advice beyond the requirements file itself.

Configuration is a file copy, not environment variables. You copy config_temp.py to my_config.py in the repository root and fill in two endpoint pairs. The LLM side takes LLM_BASE_URL, LLM_API_KEY and LLM_MODEL, with gpt-4o-mini as the example value. The embedding side takes EMB_BASE_URL, EMB_API_KEY, EMB_MODEL and EMB_DIM, with text-embedding-3-small and 1536 as the example values. Because both sides are base URLs rather than provider-specific clients, any OpenAI-compatible endpoint should slot in, which is the most useful design decision visible in the README.

The fastest path to a first result is python examples/hyperrag_demo.py, described as a toy example. The longer path is stepwise: python reproduce/Step_0.py preprocesses data that you place in the repository root, and the README then describes building "the knowledge hypergraphs, and entity and relation vector database" in a following step. The README text is truncated mid-sentence at that point, so the exact commands for the hypergraph construction and the later evaluation steps are not recoverable from the material available. Treat the stepwise route as something you will reconstruct from the reproduce/ directory rather than follow from the documentation.

Data supply, Docker, and the parts the README hands off

The dataset is not in the repository. The README points to a Google Drive folder and a Baidu Cloud link, and instructs you to put the dataset in the root directory before running Step_0.py. Two consequences follow. First, the reported numbers depend on a corpus you fetch from a file-sharing service, which is a weaker reproducibility story than a checksummed download or a scripted fetch. Second, the preprocessing contract is undocumented in the README: what file formats Step_0.py accepts, how documents are chunked, and whether entity extraction is itself an LLM call are all unstated. If entity and relation extraction runs through the configured LLM endpoint, ingestion cost scales with corpus size and you should budget for that before pointing it at a large corpus.

A Docker deployment section is listed in the README's own table of contents, and the section body is not present in the material provided. So the existence of a container path is confirmed, the contents are not. The same applies to the Evaluation section: it is in the table of contents, and the README's visible text does not describe how to reproduce the reported comparisons. The paper at the Nature Communications DOI is where the methodology and results live.

One more thing worth flagging for a medical-adjacent project: the README does not describe any access control, audit logging, or PHI handling guidance. If you are considering this for real clinical text, that is a gap you fill yourself, not one the project addresses.

Where the design costs you: ingestion, dependencies, and the wrong corpus

The central trade-off is that hypergraph construction is expensive and largely irreversible. Every entity and every correlation must be extracted before retrieval can happen, and the README's own extraction illustration shows that both entity descriptions and correlation descriptions are preserved. That is more LLM calls and more storage than chunk-and-embed. If your corpus changes daily, you are re-extracting rather than re-indexing a chunk, and the README says nothing about incremental updates.

Hyper-RAG is also the wrong tool when the answer genuinely lives in one passage. A policy document where each clause is self-contained does not benefit from beyond-pairwise modeling, and you pay the extraction cost for nothing. Retrieval over hyperedges can also pull in a wider context window than chunk retrieval, since a hyperedge carries several entity descriptions at once. The README does not discuss how many hyperedges are placed in the prompt or how that is bounded, so prompt-size control is something you will discover empirically.

Finally, the project is coupled to a sibling repository. Hypergraph-DB is a hard dependency for the retrieval layer, and its maturity, storage format and migration path are outside Hyper-RAG's control. For a v1.0 release from March 2026, that is a reasonable architecture, but it means an upgrade to one project can force a rebuild of the other.

Graph RAG and Light RAG: the actual difference in approach

The README compares against Graph RAG and Light RAG, reporting that Hyper-RAG outperforms them by 6.3% and 6.0% respectively on the NeurologyCorp dataset, with a 12.3% average improvement over direct LLM use across six models. The paper reports a 35.5% improvement over Light RAG across nine datasets under a selection-based assessment, and states that Hyper-RAG-Lite reaches twice the retrieval speed of Light RAG with a 3.3% performance gain.

The methodological difference is not a tuning detail. Graph RAG and comparable systems build a graph whose edges connect two nodes, then use community detection or traversal to assemble context. Hyper-RAG keeps multi-entity relations as first-class objects, so a query can match a fact that was never decomposed. The README's claim that existing methods decline as query complexity rises, while Hyper-RAG stays stable, follows directly from that: a question requiring four entities to be related at once has no single edge to match in a pairwise graph.

That said, the numbers come from the paper and the README's figures, not from anything a reader can rerun from the repository alone. The evaluation section is listed but not documented in the visible README, and one of the reported comparisons uses a selection-based assessment, which is a different measurement protocol from the accuracy figures. If you need to justify adoption internally, plan to reproduce at least the demo on your own corpus rather than citing the headline percentages.

Licence, maintenance and what an upgrade actually costs

Hyper-RAG is Apache-2.0, which permits commercial use, modification and redistribution provided you keep the licence and notice files and state significant changes. It includes a patent grant, which matters more than usual here because the project accompanies a published paper and a lab-built database. Apache-2.0 does not grant trademark rights, so the Hyper-RAG and Hypergraph-DB names are not yours to use in a product name. This is a description of the licence text, not legal advice; get your own review if you are shipping it inside a regulated product.

The maintenance picture is thin but not alarming. The repository is not archived, the last push is 2026-06-27, and there is a single tagged release, v1.0 from 2026-03-09. That is one release in roughly three and a half months of activity, which is consistent with a research codebase that was packaged for release rather than a library with a deprecation policy. There is no changelog in the material, so an upgrade from v1.0 to whatever follows has no documented migration path.

The practical upgrade cost sits in two places. If the hypergraph storage format changes with Hypergraph-DB, you rebuild the knowledge base, which means re-running extraction and re-paying the LLM cost. If the config surface changes, my_config.py is a local file you maintain by hand, so you diff it against config_temp.py on every pull. Neither is fatal, but both mean the cost of tracking upstream is measured in re-ingestion, not in a pip install.

Editorial conclusion

Adopt Hyper-RAG if your questions hinge on facts that span three or more entities and you can supply an OpenAI-compatible LLM and embedding endpoint, since the whole pipeline is configured through LLM_BASE_URL, LLM_API_KEY, EMB_BASE_URL, EMB_API_KEY and EMB_DIM in my_config.py. Do not adopt it if you need a self-contained local model stack or a documented, reproducible benchmark harness, because the README points evaluation at the paper and the dataset at external drives. Before committing, run python examples/hyperrag_demo.py against your own corpus and confirm that Step_0.py ingests your file formats, since the preprocessing contract is the part most likely to break first.

Official sources

  1. iMoonLab/Hyper-RAG on GitHub
  2. License: Apache-2.0
  3. Project website
  4. README
  5. Releases
Community notes

Community notes