This is a attention model for Irony Detection Subtask Task 3 held at SemEval 2018. The model is based on the allennlp library.
The code implements two different attention mechanisms for encoding the sentence representations.
-
Basic attention layer Paper. Best Performance of model 69.19% F1 score.
-
A Structured Self-attentive Sentence Embedding by Lin et.al. Paper.Best Performance of model 70.00% F1 score.
The model is composed of three basic components :-
- Reader - Responsible for reading the dataset in .txt files in the dataset folder.
- Model - The model module defines the neural net we want to use for the model. It is currently a sequence to sequence encoder whoose output is fed to a feed forward network for classification.
- Predictor - This part is required for running the demo and evaluate procedure.
The experiments directory contains the config files which contains the hyperparameters and the model configuration.
To train the model run:
allennlp train experiments/experiment_file.json -s directory_path_to_save_model --include-package irony_model
-
Introduces masking in the Structured Self-attentive Sentence Embedding which is present in
irony_model/modules/module.py
. The sentence encoder can be used with any allennlp model. -
Example of how to implement multitask learning. Loss function is taken as sum of losses of both the tasks.
-
Implements the macro F1 loss i.e. average of F1 of all the classes.
-
A seq2seq encoder module with forbenius norm based penalization.
For running the react based avisulizations of the attention. There are essentially two things that are needed for the setup
- The Flask server running (Run the following command)
python -m allennlp.service.server_simple --archive-path /tmp/irony_alternate1/model.tar.gz --predictor ironic-predictor --include-package irony_model
- Setting up the React Server for nodejs visualization(Ensure that node js and npm are installed on the system)
npm install
(Only once)npm start
- Allennlp==0.7.0
- React js
- Node-js
- npm
- Add New Models
- Update Documentation and Readme