https://github.com/bowang-lab/mediqa-chat-2023

A repository for organizing our submission to the MEDIQA-Chat Tasks @ ACL-ClinicalNLP 2023

https://github.com/bowang-lab/mediqa-chat-2023

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.4%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

A repository for organizing our submission to the MEDIQA-Chat Tasks @ ACL-ClinicalNLP 2023

Basic Info
  • Host: GitHub
  • Owner: bowang-lab
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 1.58 MB
Statistics
  • Stars: 21
  • Watchers: 7
  • Forks: 7
  • Open Issues: 3
  • Releases: 0
Created over 3 years ago · Last pushed about 3 years ago
Metadata Files
Readme License

README.md

ci License: MIT

MEDIQA-Chat-2023-WangLab

This repository contains our submission (and the resulting short paper) to the MEDIQA-Chat Shared Task @ ACL-ClinicalNLP 2023

Table of contents

Installation

Requires python>=3.8. First, create and activate a virtual environment, then install the requirements:

bash pip install -r requirements.txt

Note: For setup on a cluster managed by the Alliance, please see ./scripts/slurm/setup_on_arc.sh.

Usage

Fine-tuning a model on the shared task data

Models can be fine-tuned on the shared task data using the run_summarization.py script, which is adapted from the HuggingFace run_summarization.py script. To see all available options, run:

bash python ./scripts/run_summarization.py --help

Arguments can be modified in the config files or passed as command-line arguments. Valid arguments are anything from the HuggingFace TrainingArguments, Seq2SeqTrainingArguments or arguments specified in the script itself. At a minimum, you must provide a path to the dataset partitions with train_file, validation_file and, optionally, test_file.

Training

To train the model, run one of the following:

```bash

Task A (train)

python ./scripts/runsummarization.py "./conf/base.yml" "./conf/taskA.yml" \ outputdir="./output/taskA" ```

```bash

Task B (train)

python ./scripts/runsummarization.py "./conf/base.yml" "./conf/taskB.yml" \ outputdir="./output/taskB" ```

Note: base.yml contains good default arguments that should be used for all experiments. taskA.yml/taskB.yml contain arguments specific to Task A/B. Arguments passed via the command line arguments will override those in the config files.

Validation

To evaluate a trained model on the validation set, run one of the following:

```bash

Task A

python ./scripts/runsummarization.py "./conf/base.yml" "./conf/taskA.yml" \ outputdir="./output/taskA/finetune" \ modelnameorpath="./path/to/model/checkpoint" \ dotrain=False \ doeval=True ```

```bash

Task B

python ./scripts/runsummarization.py "./conf/base.yml" "./conf/taskB.yml" \ outputdir="./output/taskB/finetune" \ modelnameorpath="./path/to/model/checkpoint" \ dotrain=False \ doeval=True ```

Testing

To make predictions with a trained model on the test set, see the Submission.


By default, the model will be evaluated by ROUGE, BERTScore and BLEURT. You can change the underlying models for BERTScore and BLEURT by modifying the bertscore_model_type and bleurt_checkpoint arguments. We choose reasonable defaults here, which balance model size and evaluation time with automatic metric performance. For more information on possible models and metric performance, see here for BERTScore and here for BLEURT.

Results will be automatically logged to any integrations that are installed and supported by the HuggingFace trainer. If do_predict=True, a file which contains the model's predictions formatted for submission to the challenge task will be saved to output_dir / "taskX_wanglab_runY.csv". X corresponds to the script argument task and Y to the script argument run.

We also provide a SLURM submission script for ARC clusters, which can be found at ./scripts/slurm/run_summarization.sh.

Generate notes with LangChain

To generate notes with a large language model (LLM, via LangChain), use the run_langchain.py script. To see all available options, run:

bash python ./scripts/run_langchain.py --help

To reproduce our best results for Task B, run the following:

```bash

Task B

OPENAIAPIKEY="..." python scripts/runlangchain.py \ "./MEDIQA-Chat-TestSets-March-15-2023/TaskB/taskBtestset4participantsinputConversations.csv" \ "./output/taskB/incontext_learning" \ --train-fp "./MEDIQA-Chat-Training-ValidationSets-Feb-10-2023/TaskB/TaskB-TrainingSet.csv" \ --task "B" \ --run "1" ```

You will need to provide your own OPENAI_API_KEY.

Note: Due to the non-deterministic nature of OpenAI's models and API, results may vary slightly from our reported results.

Pre-trained models, outputs and results

All model outputs and results (as well as data from the human evaluation) reported in our paper are available in the data/paper directory.

Submitting to the shared task

To submit a run to the shared task we used the following commands:

```bash ./scripts/submission/install.sh ./scripts/submission/activate.sh

Then, choose one of the decode scripts, e.g.

./scripts/submission/decodetaskArun1.sh ```

The submission scripts also demonstrate how to make predictions on the test set using a trained model.

Citing

If you use our model in your work, please consider citing our paper:

@inproceedings{giorgi-etal-2023-wanglab, title = {{W}ang{L}ab at {MEDIQA}-Chat 2023: Clinical Note Generation from Doctor-Patient Conversations using Large Language Models}, author = {Giorgi, John and Toma, Augustin and Xie, Ronald and Chen, Sondra and An, Kevin and Zheng, Grace and Wang, Bo}, year = 2023, month = jul, booktitle = {Proceedings of the 5th Clinical Natural Language Processing Workshop}, publisher = {Association for Computational Linguistics}, address = {Toronto, Canada}, pages = {323--334}, url = {https://aclanthology.org/2023.clinicalnlp-1.36}, abstract = {This paper describes our submission to the MEDIQA-Chat 2023 shared task for automatic clinical note generation from doctor-patient conversations. We report results for two approaches: the first fine-tunes a pre-trained language model (PLM) on the shared task data, and the second uses few-shot in-context learning (ICL) with a large language model (LLM). Both achieve high performance as measured by automatic metrics (e.g. ROUGE, BERTScore) and ranked second and first, respectively, of all submissions to the shared task. Expert human scrutiny indicates that notes generated via the ICL-based approach with GPT-4 are preferred about as often as human-written notes, making it a promising path toward automated note generation from doctor-patient conversations.} }

Owner

  • Name: WangLab @ U of T
  • Login: bowang-lab
  • Kind: organization
  • Location: 190 Elizabeth St, Toronto, ON M5G 2C4 Canada

BoWang's Lab at University of Toronto

GitHub Events

Total
  • Issues event: 1
  • Watch event: 2
Last Year
  • Issues event: 1
  • Watch event: 2

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 209
  • Total Committers: 2
  • Avg Commits per committer: 104.5
  • Development Distribution Score (DDS): 0.01
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
johngiorgi j****i@g****m 207
Augustin Toma a****a@g****m 2

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 10
  • Total pull requests: 18
  • Average time to close issues: 3 days
  • Average time to close pull requests: about 3 hours
  • Total issue authors: 3
  • Total pull request authors: 2
  • Average comments per issue: 0.3
  • Average comments per pull request: 0.17
  • Merged pull requests: 18
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • JohnGiorgi (8)
  • keyuchen21 (1)
  • ahuang11 (1)
Pull Request Authors
  • JohnGiorgi (16)
  • augustintoma (2)
Top Labels
Issue Labels
Pull Request Labels