Deep neural network based sentence classification attack.
We offer a docker image with all dependencies are installed.
If you do not prefer using docker please skip this section and see the instructions from the next section (Requirements).
You can build an image, called autowordbug
, with the following command.
$ docker build . --tag autowordbug
Then, you can create a docker container with the created image with the following command.
$ docker run --rm -it autowordbug
Inside the container, we offer 3 system-wide programs, which are prepare
, train
, and evaluate
.
You can see how to use them by passing --help
argument as follows:
$ prepare --help
$ train --help
$ evaluate --help
You also can get some hints at Training and Evaluation sections in this document.
Following libraries are required. Install them using your pip
.
- numpy
- pytorch
Before start, all scripts (.py files at the root directory) offer --help
option.
Please, see the usage message for more details which not explained in this document.
You can train AutoWordBug
with the following steps.
First, you need to prepare the datasets.
The following command will create train.pkl
, val.pkl
, and test.pkl
at experiments
folder.
$ python prepare.py
Then, you can train an AutoWordBug
with the following command. If you want to utilize your GPU, type in --cuda
option additionaly.
$ python train.py --train experiments/train.pkl --val experiments/val.pkl
# Training will take a while.
Now, you can find trained model at the experiments
folder
With trained model, you can evaluate the performance of AutoWordBug
.
$ python evaluate.py --model experiments/AutoWordBug_best.pt --test experiments/test.pkl
# Generation result of each sentences will be print out.