This is the project for "ALTER: Auxiliary Text Rewriting Tool for Natural Language Generation" (EMNLP2019 demo) (cite). This tool aims at facilitating the rewriting process for natural language generation tasks by i) recording word-level revision histories and ii) incorporating flexible auxiliary edit support and instant feedback to annotators.
python, pytorch, docker
Go to web server folder ./service
.
-
(optional) It is recommended to work under a virtual environment by
virtualenv
orconda env
. -
Install dependent packages:
make install
- Initialise the database:
make database.upgrade
- Initialise database with admin:
make seed
Username: admin Password: password
- Download models for auxiliary feedback components:
python src/manage.py download_models
-
classifcation model: is the model that predicts the probability of target labels. The default
gender_model
(model, vocab) is trained on the task of gender classification, as described in our paper, is placed in./data/gender_model
-
w2v is a Word2Vector model (GoogleNews-vectors-negative300.bin), which is placed in
data/models
. -
bert: the bert model will be automatically downloaded to
data/models
, at the first request.
NB: You can adapt the models to your target tasks, by replacing the models in data/models
or gender_model
and modifying the paths of corresponding models in config.py
.
The frontend webapp server runs in Docker.
Go to ./webapp
, and build the docker image:
docker build -t alter:latest .
Start the backend server, under ./service
:
APPLICATION_HOST=0.0.0.0 APPLICATION_PORT=8000 ENVIRONEMENT=NO python src/server.py
Start the frontend webapp server, under./webapp
:
docker run -d --rm -p 3000:3000 -v `pwd`:/app/webapp alter:latest /bin/bash -c "cd /app/webapp; npm start"
Visit the local website at:
Notice the default CORS check from modern browsers will stop you from accessing the framework except by http://localhost:3000. See section deployment for following steps.
- Stop the backend API server by simply pressing "CTRL+C".
- Stop the frontend server by stopping the running container.
docker stop [CONTAINER_ID]
We recommend deploying the server through reverse-proxy. We have provided a nginx
setting as in /deploy/fairedit.nginx
(optional) If you need instant access to the website without nginx
for now, you can add your external IP (say, 1.2.3.4 for both backend and fronend servers) to the server to bypass the CORS check.
- Add your external IP to ALLOWED_ORIGINS
/service/src/config.py
, for example:
ALLOWED_ORIGINS = ["http://localhost:3000", "http://1.2.3.4:3000"]
- Run the webapp with the external IP of the backend server:
docker run -d --rm -p 3000:3000 -v `pwd`:/app/webapp alter:latest /bin/bash -c "SERVICE_SERVER=http://1.2.3.4:8000/application npm run build; npm run start:prod"
This project is under MIT License - see LICENSE for more details.
If you use this repository in your project, we would appreciate you citing our paper as below.
@inproceedings{qiongkai2019alter,
title={ALTER: Auxiliary Text Rewriting Tool for Natural Language Generation},
author={Qiongkai Xu, Chenchen Xu and Lizhen Qu},
booktitle={2019 Conference on Empirical Methods in Natural Language Processing and 9th International Joint Conference on Natural Language Processing},
pages={13-18},
year={2019},
url={https://www.aclweb.org/anthology/D19-3003},
doi={10.18653/v1/D19-3003},
organization={SIGDAT}
}