完整流程需自备 Neo4j 并配置 NEO4J_URL/USERNAME/PASSWORD 三个环境变量;UMLS 词典需注册申请,MIMIC IV 与书籍受许可限制无法直接获取;Docker 演示依赖 OPENAI_API_KEY 与 NCBI_API_KEY,且用联网 PubMed 检索替代本地语料
Medical-Graph-RAG
ImprintLabMIT长期未更新面向循证医学信息检索的图谱 RAG 系统,把医学知识组织成图结构再结合大模型检索,让回答有据可查、可溯源。
A Graph RAG System for Evidenced-based Medical Information Retrieval [ACL 2025]
conda env create -f medgraphrag.yml
export OPENAI_API_KEY=your_OPENAI_API_KEY
python run.py -simple TrueREADME 未说明显存或 GPU 要求;Docker 演示需分配 10G 存储空间(--storage-opt size=10G)
面向医疗领域的 Graph RAG 系统,用图谱检索增强大模型,给出有证据支撑的医学问答
面向循证医学信息检索的图谱 RAG 系统,把医学知识组织成图结构再结合大模型检索,让回答有据可查、可溯源。
核心能力
- 构建三层医疗知识图谱:私有病历、文献书籍、UMLS 词典
- 用 trinity 参数开启层级图链接,需指定 gid 关联子图
- 支持基于 PubMed 的联网检索,绕开论文版权限制
- 提供 Neo4j 图数据库与 ChatGPT 的完整构建与推理流程
- 附带 Docker 演示镜像,可直接启动 Web 界面试用
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Medical-Graph-RAG
We build a Graph RAG System specifically for the medical domain.
Check our paper here: https://arxiv.org/abs/2408.04187
Demo
a docker demo is here: https://hub.docker.com/repository/docker/jundewu/medrag-post/general
Use it by: docker run -it --rm --storage-opt size=10G -p 7860:7860 \ -e OPENAI_API_KEY= your_key -e NCBI_API_KEY= your_key medrag-post
this demo used web-based searches on PubMed instead of locally storing medical papers and textbooks to detour the license wall.
Quick Start (Baseline: a simple Graph RAG pipeline on medical data)
-
conda env create -f medgraphrag.yml
-
export OPENAI_API_KEY = your OPENAI_API_KEY
-
python run.py -simple True (now using ./dataset_ex/report_0.txt as RAG doc, "What is the main symptom of the patient?" as the prompt, change the prompt in run.py as you like.)
Build from scratch (Complete Graph RAG flow in the paper)
About the dataset
Paper Datasets
Top-level Private data (user-provided): we used MIMIC IV dataset as the private data.
Medium-level Books and Papers: We used MedC-K as the medium-level data. The dataset sources from S2ORC. Only those papers with PubMed IDs are deemed as medical-related and used during pretraining. The book is listed in this repo as MedicalBook.xlsx, due to licenses, we cannot release raw content. For reproducing, pls buy and process the books.
Bottom-level Dictionary data: We used Unified Medical Language System (UMLS) as the bottom level data. To access it, you'll need to create an account and apply for usage. It is free and approval is typically fast.
In the code, we use the 'trinity' argument to enable the hierarchy graph linking function. If set to True, you must also provide a 'gid' (graph ID) to specify which graphs the top-level should link to. UMLS is largely structured as a graph, so minimal effort is required to construct it. However, MedC-K must be constructed as graph data. There are several methods you can use, such as the approach we used to process the top-level in this repo (open-source LLMs are recommended to keep costs down), or you can opt for non-learning-based graph construction algorithms (faster, cheaper, and generally noisier)
Example Datasets
Recognizing that accessing and processing all the data mentioned may be challenging, we are working to provide simpler example dataset to demonstrate functionality. Currently, we are using the mimic_ex here here as the Top-level data, which is the processed smaller dataset derived from MIMIC. For Medium-level and Bottom-level data, we are in the process of identifying suitable alternatives to simplify the implementation, welcome for any recommendations.
1. Prepare the environment, Neo4j and LLM
-
conda env create -f medgraphrag.yml
-
prepare neo4j and LLM (using ChatGPT here for an example), you need to export:
export OPENAI_API_KEY = your OPENAI_API_KEY
export NEO4J_URL= your NEO4J_URL
export NEO4J_USERNAME= your NEO4J_USERNAME
export NEO4J_PASSWORD= your NEO4J_PASSWORD
2. Construct the graph (use "mimic_ex" dataset as an example)
-
Download mimic_ex here, put that under your data path, like ./dataset/mimic_ex
-
python run.py -dataset mimic_ex -data_path ./dataset/mimic_ex(where you put the dataset) -grained_chunk -ingraphmerge -construct_graph
3. Model Inference
-
put your prompt to ./prompt.txt
-
python run.py -dataset mimic_ex -data_path ./dataset/mimic_ex(where you put the dataset) -inference
Acknowledgement
We are building on CAMEL, an awesome framework for construcing multi-agent pipeline.
Cite
@article{wu2024medical,
title={Medical Graph RAG: Towards Safe Medical Large Language Model via Graph Retrieval-Augmented Generation},
author={Wu, Junde and Zhu, Jiayuan and Qi, Yunli},
journal={arXiv preprint arXiv:2408.04187},
year={2024}
}