Given a pair of sentences (premise, hypothesis), the decomposed graph entailment model (DGEM) predicts whether the premise can be used to infer the hypothesis.
Switch branches/tags
Clone or download
tusharkhot Merge pull request #7 from allenai/add_predictors
Improve README + Add model predictors
Latest commit 2e57f46 Mar 14, 2018


A repository of the the entailment models used for evaluation in the SciTail: A Textual Entailment Dataset from Science Question Answering paper accepted to AAAI'18. It contains three models built using the PyTorch-based deep-learning NLP library, AllenNLP.

  • Decomposable Attention (Baseline): A simple model that decomposes the problem into parallelizable attention computations (Parikh et al. 2016). We directly use the AllenNLP implementation (Gardner, et al., 2017) of the decomposable attention model here.

  • Ngram Overlap (Baseline): A simple word-overlap baseline that uses the proportion of unigrams, 1- skip bigrams, and 1-skip trigrams in the hypothesis that are also present in the premise as three features. We feed these features into a two-layer perceptron.

  • Decomposable Graph Entailment Model (Proposed): Our proposed decomposed graph entailment model that uses structure from the hypothesis to calculate entailment probabilities for each node and edge in the graph structure and aggregates them for the final entailment computation. Please refer to our paper for more details.

We use the SciTail dataset and pre-trained models by default (downloaded automatically by the scripts/ script). The models can be trained and evaluated on new datasets too as described below.

Setup Instruction

  1. Create the scitail environment using Anaconda
conda create -n scitail python=3.6
  1. Activate the environment
source activate scitail
  1. Install the requirements in the environment:
sh scripts/
  1. Install pytorch as per instructions on Commands as of Nov. 22, 2017:

Linux/Mac (no CUDA): conda install pytorch torchvision -c soumith

Linux (with CUDA): conda install pytorch torchvision cuda80 -c soumith

  1. Download the Glove embeddings into a Glove/ folder in the root directory as glove.<tokens>B.<dim>d.txt.gz files.

  2. Test installation

pytest -v

Download the data and models

Run the script to download the dataset and models used in the SciTail paper.

 sh scripts/

This will download and unzip the data to SciTailV1.1 folder (from here) and models to SciTailModelsV1 folder (from here).

Evaluate the SciTail models

To run the trained models on the test sets, run

  sh scripts/

Note that the models include the vocabulary used for training these models. So these pre-trained models will have poor performance on new test sets with a different vocabulary.

View predictions of the SciTail models

To view the model predictions, run

  sh scripts/

The predictions would be added to the predictions/ folder for each model. Each file has the original examples along with the model's probability, logit predictions, and entailment score using the keys: label_probs, label_logits and score respectively.

Train the SciTail models

To train the models on new datasets, run

  sh scripts/

with the appropriate train/validation sets specified in the training configuration files.

  • Decomposable Graph Entailment Model: training_config/dgem.json
  • Decomposable Attention Model: training_config/decompatt.json
  • NGram Overlap Model: training_config/simple_overlap.json

If you find these models helpful in your work, please cite:

     Author = {Tushar Khot and Ashish Sabharwal and Peter Clark},
     Booktitle = {AAAI},
     Title = {{SciTail}: A Textual Entailment Dataset from Science Question Answering},
     Year = {2018}