A TalkToModel (Slack et al., 2022) adaptation to NLP use cases (question answering, hate speech detection, dialogue act classification).
The name is a word-play on Interrobang, a ligature of question mark and exclamation mark, and the interrogation of Language models.
Our tool offers a dialogue-based exploration of NLP interpretability methods (feature attribution, counterfactuals and perturbations, free-text rationalization) and dataset analyses (similar examples, keywords, label distribution).
Our accompanying paper is accepted at EMNLP 2023 Findings.
We consider 7 categories of operations.
- About: Capabilities of our system.
- Metadata: Information in terms of data, model, labels.
- Prediction: Various operations related to gold labels and model predictions.
- Understanding: Keyword-based analysis and retrieval of similar instances.
- Explanation: Feature attribution methods (local-, class-, global-level) and free-text rationalization.
- Perturbation: Methods to change some parts of an instance, e.g. such that the label of the instance would change.
- Custom input: We not only allow instances from the dataset but also instances given by users. (More details see below)
They are defined in actions and prompts.
We provide a dataset view with which users can explore instances contained in the pre-defined dataset (in screenshot, BoolQ dataset is used). Users can search instances that include the entered string.
- Question Answering (BoolQ)
- Hate Speech Detection (OLID)
- Dialogue Act Classification (DailyDialog)
conda create -n interrolang python=3.9
conda activate interrolang
python -m venv venv
source venv/venv/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
# Download omw-1.4
python -m nltk.downloader omw-1.4
# Punkt
python -m nltk.downloader punkt
# Install spacy
pip install -U pip setuptools wheel
pip install -U spacy
python -m spacy download en_core_web_sm
Install polyjuice-nlp and its dependencies due to some issues from polyjuice:
cd utils
bash dependency.sh
In our tool, we currently use the following Transformer models:
- DistilBERT fine-tuned on BoolQ: https://huggingface.co/andi611/distilbert-base-uncased-qa-boolq (HF)
- MultiBERT fine-tuned on OLID: https://huggingface.co/sinhala-nlp/mbert-olid-en (HF)
- BERT fine-tuned on DailyDialog: Due to anonymization not shown any links
Put them under ./data
and name the folders boolq_model
and olid_model
respectively.
Put the file 5e_5e-06lr
under ./explained_models/da_classifier/saved_model
In ./configs
, there are all gin config files for all three datasets with different parsing models. You can choose one of them and set its path in ./global_config.gin
:
GlobalArgs.config = "./configs/boolq_adapter.gin"
You can launch the Flask web app via
python flask_app.py
If you want to run with Docker, you can build the docker app
sudo docker build -t interrolang .
And then run the image
sudo docker run -d -p 4000:4000 interrolang
After the project is set up, we provide an optional user guide using Selenium to demonstrate how to use our system if you have a Chrome Browser available.
- Feature importance on token level
- Feature importance on sentence level
- Prediction
- Similarity
- Rationalization
1. Enter your custom input in the text area and then click send button. Be aware: you have to choose "Custom input" in the selection box.
3. Then you should enter prompts for operations mentioned above. Operations that support custom input are highlighted with yellow border.
4. In the end, click the send button and you will get the result. (In this example, we show the result of feature importance on token level on given custom input)
Include operation works similar to custom input
- Enter a single token in the text area and choose "Include"" in the selection box. Then click the send button.
- After clicking the button, you could see your entered token in the interface.
- Then you could enter a prompt (refer here)
- Supported operations:
- countdata
- label
- mistake
- predict
- score
- show
- Supported operations:
@inproceedings{feldhus-etal-2023-interrolang,
title = "{I}nterro{L}ang: Exploring {NLP} Models and Datasets through Dialogue-based Explanations",
author = {Feldhus, Nils and Wang, Qianli and Anikina, Tatiana and Chopra, Sahil and Oguz, Cennet and M{\"o}ller, Sebastian},
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2023",
month = dec,
year = "2023",
address = "Singapore, Singapore",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/2310.05592",
}