The Possible, the Plausible, and the Desirable: Event-Based Modality Detection for Language Processing
- Introduction
- Main Features
- Requirements
- Setup
- Basic Usage
- Important Notes
- Training Your Own Model
- Evaluation
- Citations
Code for event-based modality detection, as described in the ACL paper "The Possible, the Plausible, and the Desirable: Event-Based Modality Detection for Language Processing". The code allows training, data processing, and includes configuration files for the experiments described in the paper.
python>=3.6
torch=1.5.1
spacy==2.1.9
allennlp==1.0.0
You can find the data for training your own model in the following repository: https://github.com/OnlpLab/Modality-Corpus .
To convert from the conll format to the format used for training use the following script: data_processing/convert_formats.py
To make predictions with a model that we trained on the data (since we are doing 5-fold CV, we chose the models with the best performance on dev here), do the following:
- Have a virtual environment with AllenNLP version 2.0.0.
- Clone this repo.
- Download the models:
- Be at the root of the Modality repo
- Run the following command: allennlp predict path_to_downloaded_model/model.tar.gz data_you_want_to_predict_on.txt --include-package my_library --use-dataset-reader --cuda-device 0 --output-file file_you_want_to_predict_to.jsonl
- The file for prediction should have a sentence per line, with the tokenized word separated by whitespace. (e.g.: He should go home . )
We used the code from AllenNLP (https://github.com/allenai/allennlp). If you want to train your own model you need to specify the train and dev files in the jsonnet configuration files in the following folder: Roberta/experiments. Afterwards you can run the model with the following command: allennlp train experiments/my_config.jsonnet --include-package my_library -s output_directory
To evaluate your predictions you first need to convert them to a different format using this script: Roberta/scripts/format.py Afterwards you can use the conll evaluation script: Roberta/scripts/conlleval_orig.py .
If you use code from repository or our models, please cite the Event-Based-Modality paper:
@InProceedings{eventbasedmodality,
author = {Pyatkin, Valentina and Sadde, Shoval and Rubinstein, Aynat and Portner, Paul and Tsarfaty, Reut},
title = {The Possible, the Plausible, and the Desirable: Event-Based Modality Detection for Language Processing},
year = {2021},
}