Giter Site home page Giter Site logo

tasc's Introduction

TaSc

Repository for the paper "Improving Attention Interpretability with Task-specific Information in Text Classification", G.Chrysostomou and N.Aletras, to appear at ACL2021. Pre-print available at this link

Prerequisites

Install necessary packages by using the files conda_reqs.txt and pip_reqs.txt

conda create --name tasc --file  conda_reqs.txt
conda activate tasc
pip install -r pip_reqs.txt
python -m spacy download en

Downloading Task Data

You can run the jupyter notebooks found under tasks/task_name/*ipynb to generate a filtered, processed csv file and a pickle file used for trainining the models.

Training and Evaluating the models

You can train and save the models with train_eval_bc.py script with the following options:

  • dataset : {sst, twitter, mimicanemia, imdb, agnews}
  • encoder : {lstm, gru, mlp, cnn, bert}
  • data_dir : directory where task data is
  • model_dir : directory for saved models
  • experiments_dir : direcrory to save experiment results
  • mechanisms: selection of attention mechanism with options {tanh, dot}
  • operation : operation over tasc score generation with option {sum-over, max-pool, mean-pool}
  • lin : apply Lin-TaSc
  • feat : apply Feat-TaSc
  • conv : apply Conv-TaSc
  • speed_up : In case of low resource scenarios, you can use this option to speed up the fraction of token experiments by searching every 2% of the sequence instead of every token, with results being similar (almost identical) to those of the paper.

Example script (without TaSc):

python train_eval_bc.py -dataset sst 
			-encoder lstm 
			-mechanism dot 
			-data_dir data/ 
			-model_dir models/ 

Example script (with Lin-TaSc):


python train_eval_bc.py -dataset sst 
			-encoder lstm 
			-mechanism dot 
			-data_dir data/ 
			-model_dir models/ 
			-lin

Summarising results

Following the evaluation for multiple models / attention mechanisms , with and without TaSc, you can use produce_reports.py to create tables in latex and as csv for the full stack of results (as a comparison), a table for comparing with other explanation techniques, results across attention mechanism, encoder and dataset.

The script can be run with the following options:

  • datasets: list of datasets with permissible datasets listed above
  • encoders: list of encoders with permissible encoders listed above
  • experiments_dir: directory that contains saved results to use for summarising followed by /
  • mechanisms: selection of attention mechanism with options {Tanh, Dot}
  • tasc_ver : tasc version with options {lin, feat, conv}

To generate radar plots you can run python produce_graphs.py(produce_graphs.py).

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.