Diff of /README.md [000000] .. [6cf5c7]

Switch to unified view

a b/README.md
1
<div align="center">
2
<h1> ⚕️EHRAgent🤖 </h1>
3
</div>
4
5
The official repository for the code of the paper ["EHRAgent: Code Empowers Large Language Models for Complex Tabular Reasoning on Electronic Health Records"](https://arxiv.org/abs/2401.07128). EHRAgent is an LLM agent empowered with a code interface, to autonomously generate and execute code for complex clinical tasks within electronic health records (EHRs). The project page is available at [this link](https://wshi83.github.io/EHR-Agent-page/).
6
7
### Features
8
9
- EHRAgent is an LLM agent augmented with tools and medical knowledge, to solve complex tabular reasoning derived from EHRs;
10
- Planning with a code interface, EHRAgent enables the LLM agent to formulate a clinical problem-solving process as an executable code plan of action sequences, along with a code executor;
11
- We introduce interactive coding between the LLM agent and code executor, iteratively refining plan generation and optimizing code execution by examining environment feedback in depth.
12
13
### Data Preparation
14
15
We use the [EHRSQL](https://github.com/glee4810/EHRSQL) benchmark for evaluation. The original dataset is for text-to-SQL tasks, and we have made adaptations to our evaluation. We release our clean and pre-processed version of [EHRSQL-EHRAgent](https://drive.google.com/file/d/1EE_g3kroKJW_2Op6T2PiZbDSrIQRMtps/view?usp=sharing) data. Please download the data and record the path of the data.
16
17
### Credentials Preparation
18
Our experiments are based on OpenAI API services. Please record your API keys and other credentials in the ``./ehragent/config.py``. 
19
20
### Setup
21
22
See ``requirements.txt``. Packages with versions specified in ``requirements.txt`` are used to test the code. Other versions that are not fully tested may also work. We also kindly suggest the users to run this code with Python version: ``python>=3.9``. Install required libraries with the following command:
23
24
```bash
25
pip3 install -r requirements.txt
26
```
27
28
### Instructions
29
30
The outputting results will be saved under the directory ``./logs/``. Use the following command to run our code:
31
```bash
32
python main.py --llm YOUR_LLM_NAME --dataset mimic_iii --data_path YOUR_DATA_PATH --logs_path YOUR_LOGS_PATH --num_questions -1 --seed 0
33
```
34
35
We also support debugging mode to focus on a single question:
36
```bash
37
python main.py --llm YOUR_LLM_NAME --dataset mimic_iii --data_path YOUR_DATA_PATH --logs_path YOUR_LOGS_PATH --debug --debug_id QUESTION_ID_TO_DEBUG
38
```
39
40
For **eICU** dataset, just change the option of dataset to ``--dataset eicu``.
41
42
### Citation
43
If you find this repository useful, please consider citing:
44
```bibtex
45
@inproceedings{shi-etal-2024-ehragent,
46
    title = "{EHRA}gent: Code Empowers Large Language Models for Few-shot Complex Tabular Reasoning on Electronic Health Records",
47
    author = "Shi, Wenqi  and
48
      Xu, Ran  and
49
      Zhuang, Yuchen  and
50
      Yu, Yue  and
51
      Zhang, Jieyu  and
52
      Wu, Hang  and
53
      Zhu, Yuanda  and
54
      Ho, Joyce C.  and
55
      Yang, Carl  and
56
      Wang, May Dongmei",
57
    editor = "Al-Onaizan, Yaser  and
58
      Bansal, Mohit  and
59
      Chen, Yun-Nung",
60
    booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
61
    month = nov,
62
    year = "2024",
63
    address = "Miami, Florida, USA",
64
    publisher = "Association for Computational Linguistics",
65
    url = "https://aclanthology.org/2024.emnlp-main.1245",
66
    doi = "10.18653/v1/2024.emnlp-main.1245",
67
    pages = "22315--22339",
68
    abstract = "Clinicians often rely on data engineers to retrieve complex patient information from electronic health record (EHR) systems, a process that is both inefficient and time-consuming. We propose EHRAgent, a large language model (LLM) agent empowered with accumulative domain knowledge and robust coding capability. EHRAgent enables autonomous code generation and execution to facilitate clinicians in directly interacting with EHRs using natural language. Specifically, we formulate a multi-tabular reasoning task based on EHRs as a tool-use planning process, efficiently decomposing a complex task into a sequence of manageable actions with external toolsets. We first inject relevant medical information to enable EHRAgent to effectively reason about the given query, identifying and extracting the required records from the appropriate tables. By integrating interactive coding and execution feedback, EHRAgent then effectively learns from error messages and iteratively improves its originally generated code. Experiments on three real-world EHR datasets show that EHRAgent outperforms the strongest baseline by up to 29.6{\%} in success rate, verifying its strong capacity to tackle complex clinical tasks with minimal demonstrations.",
69
}
70
```