D3Mlab / diffu-detox

5 stars 1 forks source link

DiffuDetox

Implimentation of DiffuDetox, based on DiffuSeq.

Datasets

DiffuDetox datasets are small enough to be directly included in the datasets folder.

Requirements:

The code is based on PyTorch and HuggingFace transformers. After creating a virtual environment, run:

pip install -r requirements.txt 

Training

The training script is launched in the scripts folder.

cd scripts
bash train.sh

Arguments explanation:

DiffuDetox Decoding

You need to modify the path to model_dir, which is obtained in the training stage.

cd scripts
bash run_decode.sh

Evaluation & MBR

You need to specify the folder of decoded texts. This folder should contain the decoded files from the same model but sampling with different random seeds.

cd scripts
python eval_seq2seq.py --folder ../{your-path-to-outputs} --mbr

After running eval_seq2seq.py, you will get some .json files. You can evaluate json files using the command below:

python eval_json.py --json_path path/to/json_file.json --save_path path/to/save_results