GithubHelp home page GithubHelp logo

clip's Introduction

This repository houses all code for reproducing the results of the paper:

CLIP: A Dataset for Extracting Action Items for Physicians from Hospital Discharge Notes
James Mullenbach, Yada Pruksachatkun, Sean Adler, Jennifer Seale, Jordan Swartz, Greg McKelvey, Hui Dai, Yi Yang and David Sontag
ACL 2021

Paper link

Pre-trained models

We've uploaded two models to huggingface hub for public use. One is a MIMIC-DNote-BERT+Context model, one is of type TTP-BERT+Context-250k (see paper for details).

https://huggingface.co/jamesmullenbach/CLIP_TTP_BERT_Context_250k https://huggingface.co/jamesmullenbach/CLIP_DNote_BERT_Context

The label-specific thresholds for these models are supplied in this repo, as clip_dnote_label_threshs.npy and clip_ttp_label_threshs.npy, loadable via np.load. test_load.py shows a full example of how to load these two models, feed them data, and extract predictions.

Setup

  1. (Optional, recommended) Create and activate a virtual environment
  2. pip install -r requirements.txt.

Data

Link

The data is hosted by PhysioNet, as it is based on MIMIC-III, which has access controls for privacy reasons and which is also hosted by PhysioNet. Interested users will have to complete a short training course and sign a DUA with PhysioNet to gain access.

Data processing

After downloading and unpacking the data, cd data and run python convert_json_to_csv.py to create sentence-level data that the training scripts can read.

[step to split into train/val/test]

Experiments

All training scripts are in sentclf/. Bash scripts to invoke these scripts in the manner they were run to produce the paper results are found in train_{modelname}.sh. With the exception of the bag of words model, these scripts all will run training for multiple seeds and report final results on the test set, which can then be used to compute the table entries from the paper.

Pre-training

First, sentence-tokenize each note in MIMIC's NOTEEVENTS.csv file. Then, run apply_bert_unlabeled.py with a fine-tuned vanilla BERT model (trained with sentclf/bert.py) and the tokenized unlabeled data as inputs. This creates a data file with three columns: document_id, sentence_index, max_label_score. One can then use this file, sorted by decreasing max_label_score, to create task-targeted pre-training datasets of a given size. For example, taking the top 250k sentences by max_label_score will give (approximately) the same dataset used to pre-train the TTP-BERT+Context (250k) model from the paper.

Once you have this task-targeted dataset, use sentclf/pretrain_tasks.py to pretrain a model on the dataset. Example invocation for 250k sentences:

python pretrain_tasks.py
--fname ../data/unlabeled_tokenized_sentences.csv
--model bert
--focus_fname ../data/ttp_doc_sents_250k.csv
--task mlm_switch
--max_epochs 100
--mlm_probability 0.15
--n_context_sentences 2
--switch_prob 0.25
--patience 5
--lr 5e-5
--batch_size 8
--seed 11
--print_every 100
--gradient_accumulation_steps 4
--eval_steps 3000

Finally, one can then replace the pointers to local_weights in the train_pretrained_{size}.sh scripts to point to the newly TTP pre-trained models and roughly reproduce paper results (there will likely be some non-determinism with the final results here).

clip's People

Contributors

jmullenbach-asapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clip's Issues

empty labels

Hello,
I noticed that a lot of sentences have empty labels in the csv files. Are you supposed to be used as context only?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.