Code repo for paper "KERAP: A Knowledge-Enhanced Reasoning Approach for Accurate Zero-shot Diagnosis Prediction Using Multi-agent LLMs"
14
stars
4
commits
Python
primary language
Mar 25, 2025
updated
This is the code repository for paper: KERAP: A Knowledge-Enhanced Reasoning Approach for Accurate Zero-shot Diagnosis Prediction Using Multi-agent LLMs and EHR, which aims to enhance LLM's zero-shot diagnosis prediction task utilizing KG through multi-agent framework and multi-stage reasoning process.
Medical diagnosis prediction, which is the task of predicting a patient’s future health risks based on their historically observed medical data such as electronic health records (EHRs), plays a vital role in enabling accurate healthcare and early interventions.
KERAP consists of three key components: the linkage agent, the retrieval agent, and the prediction agent. The linkage agent maps the predicted disease to a biomedical KG, establishing connections with relevant entities. The retrieval agent then queries the KG to extract and summarize related knowledge, categorizing the results into positive (e.g.,“symptom X indicates condition Y”) and negative knowledge (e.g., “symptom X rules out condition Z”) for inclusion and exclusion criteria. Finally, the prediction agent AP R integrates patient records with the extracted structured knowledge, leveraging multi-stage reasoning to achieve zero-shot diagnosis prediction.
Overview of our proposed KERAP framework.
The linkage folder contains code for concept linking and candidate generation using both embedding-based methods and prompt-based models.
python linkage/matching.py
Options include:
--mode: choose between embedding or prompt for matching methods.--top_k: number of top candidates to return.The retrieval folder contains scripts for retrieving positive and negative samples using LLM prompting and other filtering strategies.
python retrieval/extraction_positive.py
python retrieval/extraction_negative.py
You may configure your prompting settings and parsing rules in prompts.py.
prediction/: Core module for data preprocessing, model inference, and evaluation.
README.md: Project documentation.
requirements.txt: Python package dependencies.
Prepare your dataset in the expected format (e.g., CSV or structured dictionary). See utils/raw_dataset.py for loading logic. Typically, the input includes patient records with features and associated diagnosis labels.
You can run the prediction pipeline by executing:
python prediction/main.py
Optional arguments (define these in main.py):
--model: specify the prediction model (e.g., GPT-4o-mini).The evaluation metrics such as precision, recall, and F1-score are printed after model inference. You can also modify utils/evaluation.py to include additional evaluation metrics (e.g., ROC-AUC).
requirements.txt.We use a large-scale public knowledge graph, iBKH (from https://github.com/wcm-wanglab/iBKH), as the primary KG dataset. As for the patient context information, we use patient-specific data from two EHR datasets: MIMIC-III (from https://physionet.org/content/mimiciii/1.4/) and PROMOTE (private dataset). Due to the sensitive nature of medical data and privacy considerations, there are restrictions on data sharing. To gain access to the two patient-specific datasets, appropriate training and credentials may be required (https://physionet.org/). For further assistance with data access or other related inquiries, please feel free to reach out to our author team.
We would like to thank the authors from PromptLink (https://github.com/constantjxyz/PromptLink), iBKH (https://github.com/wcm-wanglab/iBKH) for their open-source efforts.
4 commits
Python
100.0%
Code repo for paper "KERAP: A Knowledge-Enhanced Reasoning Approach for Accurate Zero-shot Diagnosis Prediction Using Multi-agent LLMs"
14
stars
4
commits
Python
primary language
Mar 25, 2025
updated
This is the code repository for paper: KERAP: A Knowledge-Enhanced Reasoning Approach for Accurate Zero-shot Diagnosis Prediction Using Multi-agent LLMs and EHR, which aims to enhance LLM's zero-shot diagnosis prediction task utilizing KG through multi-agent framework and multi-stage reasoning process.
Medical diagnosis prediction, which is the task of predicting a patient’s future health risks based on their historically observed medical data such as electronic health records (EHRs), plays a vital role in enabling accurate healthcare and early interventions.
KERAP consists of three key components: the linkage agent, the retrieval agent, and the prediction agent. The linkage agent maps the predicted disease to a biomedical KG, establishing connections with relevant entities. The retrieval agent then queries the KG to extract and summarize related knowledge, categorizing the results into positive (e.g.,“symptom X indicates condition Y”) and negative knowledge (e.g., “symptom X rules out condition Z”) for inclusion and exclusion criteria. Finally, the prediction agent AP R integrates patient records with the extracted structured knowledge, leveraging multi-stage reasoning to achieve zero-shot diagnosis prediction.
Overview of our proposed KERAP framework.
The linkage folder contains code for concept linking and candidate generation using both embedding-based methods and prompt-based models.
python linkage/matching.py
Options include:
--mode: choose between embedding or prompt for matching methods.--top_k: number of top candidates to return.The retrieval folder contains scripts for retrieving positive and negative samples using LLM prompting and other filtering strategies.
python retrieval/extraction_positive.py
python retrieval/extraction_negative.py
You may configure your prompting settings and parsing rules in prompts.py.
prediction/: Core module for data preprocessing, model inference, and evaluation.
README.md: Project documentation.
requirements.txt: Python package dependencies.
Prepare your dataset in the expected format (e.g., CSV or structured dictionary). See utils/raw_dataset.py for loading logic. Typically, the input includes patient records with features and associated diagnosis labels.
You can run the prediction pipeline by executing:
python prediction/main.py
Optional arguments (define these in main.py):
--model: specify the prediction model (e.g., GPT-4o-mini).The evaluation metrics such as precision, recall, and F1-score are printed after model inference. You can also modify utils/evaluation.py to include additional evaluation metrics (e.g., ROC-AUC).
requirements.txt.We use a large-scale public knowledge graph, iBKH (from https://github.com/wcm-wanglab/iBKH), as the primary KG dataset. As for the patient context information, we use patient-specific data from two EHR datasets: MIMIC-III (from https://physionet.org/content/mimiciii/1.4/) and PROMOTE (private dataset). Due to the sensitive nature of medical data and privacy considerations, there are restrictions on data sharing. To gain access to the two patient-specific datasets, appropriate training and credentials may be required (https://physionet.org/). For further assistance with data access or other related inquiries, please feel free to reach out to our author team.
We would like to thank the authors from PromptLink (https://github.com/constantjxyz/PromptLink), iBKH (https://github.com/wcm-wanglab/iBKH) for their open-source efforts.
4 commits
Python
100.0%