In this project, we try to use the pytorch implementation of Towards Empathetic Open-domain Conversation Models to build a chatbot in Parlai and chat with it. For that, we use a novel dataset of 25k conversations grounded in emotional situations and a fine-tuned bert model pick it from : https://dl.fbaipublicfiles.com/parlai/empatheticdialogues/models.
To download the EmpatheticDialogues dataset:
wget https://dl.fbaipublicfiles.com/parlai/empatheticdialogues/empatheticdialogues.tar.gz
wget https://dl.fbaipublicfiles.com/parlai/empatheticdialogues/models/bert_finetuned_emoprepend1.mdl # BERT, fine-tuned (EmoPrepend-1)
If you want to use ParlAI without modifications, you can install it with:
pip install parlai
git clone https://github.com/facebookresearch/ParlAI.git ~/ParlAI
cd ~/ParlAI; python setup.py develop
To set up the dataset after you dowload it, you must run the build.py script to save it in the ./ParlAI directory:
$python build.py
To evaluate your bert-finetuned model, you should first create a directory ( ./test1 folder in my case) in which your evaluated model will be save it. After that, run the following commands:
python retrieval_train.py \
--batch-size 32 \
--bert-dim 300 \
--cuda \
--dataset-name empchat \
--dict-max-words 250000 \
--display-iter 100 \
--embeddings None \
--empchat-folder ./empatheticdialogues/ \
--max-hist-len 4 \
--model bert \
--model-dir ./test1 \
--model-name model \
--optimizer adamax \
--pretrained ./bert_finetuned_emoprepend1.mdl \
--reactonly
python convert_fairseq_to_parlai.py \
--input ./test1/checkpoint_best.pt \
--merge ./test1/bpe-merges.txt \
--vocab ./test1/bpe-vocab.json \
--output ./model.test --space True --activation gelu
parlai interactive --model-file "${PRETRAINED_MODEL_PATH}"