GithubHelp home page GithubHelp logo

dfki-nlp / ade_templates Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 0.0 373 KB

This project contains templates and evaluation of models with these templates for the task of Adverse Drug Effect (ADE) detection.

Python 19.97% Jupyter Notebook 80.03%

ade_templates's Introduction

Evaluating the Robustness of Adverse Drug Event Classification Models Using Templates

examples.png

This project evaluates Adverse Drug Effect (ADE) classification models with test cases generated from templates (see examples above). All templates for ADE classification can found in templates_all.csv (and templates_base.csv for base templates only).

Preparation

Create an environment and install relevant libraries.

$ pip install -r requirements.txt

Install checklist separately with pip install checklist.

Model Fine-tuning

Set up the config file for fine-tuning by adapting the arguments in model/setup_finetuner_config.py and running the file. (Or directly adapt the arguments in model/brb.ini or model/xlm.ini instead.)

Fine-tune BioRedditBERT by running

$ python finetune.py --configfile brb.ini

Fine-tune XLMRoBERTa by running

$ python finetune.py --configfile xlm.ini

Extracting Entities

Entities to fill the CheckList templates are extracted from the PsyTAR corpus. Save the PsyTAR corpus as checklist_work/data/PsyTAR_dataset.xlsx. Follow the instructions in checklist_work/entity_extraction/extract_entities.ipynb to extract your own entities from PsyTAR or a different corpus.

Running Tests

In folder checklist_work/:

Run checklist_tests.py for your Huggingface sequence classification model. A customized test suite (checklist_customized.py) is run, which uses part of the original CheckList code.

Run all tests:

$ python checklist_tests.py \
    -- model YOUR_MODEL_PATH \
    --temporal_order \
    --positive_sentiment \
    --beneficial_effect \
    --true_beneficial_effect_gold_label 0 \
    --negation

The Positive Sentiment test will use a ADE fill-ins from a list of less severe ADEs. Deactivate this behavior if needed:

$ python checklist_tests.py \
    --positive_sentiment \
    --mild_ade_source None

Inspect default values for sampling of templates and entities as well as other arguments:

$ python checklist_tests.py -h

Cite

 @misc{macphail2024evaluatingrobustnessadversedrug,
      title={Evaluating the Robustness of Adverse Drug Event Classification Models Using Templates}, 
      author={Dorothea MacPhail and David Harbecke and Lisa Raithel and Sebastian Möller},
      year={2024},
      eprint={2407.02432},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2407.02432} 
}

ade_templates's People

Contributors

harbecke avatar dtmacp avatar

Stargazers

 avatar

Watchers

Philippe avatar  avatar Lisa Raithel avatar  avatar

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.