This repo provides the model, code & data of our paper: XMD: An End-to-End Framework for Interactive Explanation-Based Debugging of NLP Models. [PDF]
NLP models are susceptible to learning spurious biases (i.e., bugs) that work on some datasets but do not properly reflect the underlying task. Explanation-based model debugging aims to resolve spurious biases by showing human users explanations of model behavior, asking users to give feedback on the behavior, then using the feedback to update the model. While existing model debugging methods have shown promise, their prototype-level implementations provide limited practical utility.
Project website: https://inklab.usc.edu/xmd
- This project is intended to be deployed on modern linux environments.
- Install Python 3, verify install status by using
python3 --version
to check. python may be installed under different aliases, use the appropriate one on your system.
Setup Environment
-
Create a virtual environment using:
- anaconda:
conda create -n xmd python=3.8
- virtualenv:
python3 -m pip install virtualenv
python3 -m venv xmd
- anaconda:
-
Activate your environment:
- anaconda:
conda activate hilt-demo
- virtualenv:
source hilt-demo/bin/activate
- anaconda:
-
Install prerequisites:
pip install -r requirements.txt
- Note that requirements.txt may contain package version not compatible with your installation. Please adjust accordingly.
Setup Backend
-
Setup PostgreSQL
- Follow postgres's instruction to install postgres 12 on your local system
- Make sure postgres is started and enabled by
sudo systemctl start postgresql-12
andsudo systemctl enable postgresql-12
- Verify postgres status by running
sudo systemctl status postgresql-12
- Create a postgrees user by running
sudo -u postgres createuser hilt-user
- Modify
/var/lib/pgsql/12/data/pg_hba.conf
so that the identification method use md5. See here in detail You can use any text editor you want. I would recommendmicro
ornano
. As a backup,vi
should be installed by default on any modern linux systems. - Open
annotation_backend/create_empty_db.sql
, you will need to execute these sql commands as the postgres user. This can be done by:cat annotation_backend/create_empty_db.sql
to print the command to the current console.sudo -u postgres psql
to switch to postgres user and enter the postgres environment. If prompt for password, enter one you configured during the setup process. Try 123.- Copy and paste commands in
annotation_backend/create_empty_db.sql
into the command window to execute these sql commands to initialize and configure the database. - Exit postgres environment by typing
\q
-
Setup Django
- Use
python3 annotation_backend/manage.py migrate
to setup postgres database for access - Use
python annotation_backend/manage.py createsuperuser
to setup django super user for website login
- Use
-
Start the backend by using
python annotation_backend/manage.py runserver 0.0.0.0:8000
Note 8000 here is hard coded in, you need to move other services that may be running on 8000 before hand. -
After verifying that the backend can be access via a web browser and can be accessed normally, it is recommended to use systemd or tmux to start a headless instance to allow server to serve after logout of current instance.
-
It is recommended to use
chmod
andchown
to set appropriate permissions for the database and source code files. Note that postgresql db need to be accessed as the postgres user.
(Old) Follow Django annotation backend installation instructions here
Directory overview
annotation_backend/
- Django applicationfrontend/
- Vue.js frontend project directorymodel_api/
- Model API
If you find our work helpful, please cite the following:
@article{lee2022xmd,
title={XMD: An End-to-End Framework for Interactive Explanation-Based Debugging of NLP Models},
author={Lee, Dong-Ho and Kadakia, Akshen and Joshi, Brihi and Chan, Aaron and Liu, Ziyi and Narahari, Kiran and Shibuya, Takashi and Mitani, Ryosuke and Sekiya, Toshiyuki and Pujara, Jay and Ren, Xiang},
journal={arXiv preprint arXiv:2210.16978},
year={2022}
}