Skip to content

vlordier/Parlai-chatbot

 
 

Repository files navigation

Parlai-chatbot

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.

Dowload Dataset :


To download the EmpatheticDialogues dataset:
wget https://dl.fbaipublicfiles.com/parlai/empatheticdialogues/empatheticdialogues.tar.gz

Dowload model:


wget https://dl.fbaipublicfiles.com/parlai/empatheticdialogues/models/bert_finetuned_emoprepend1.mdl  # BERT, fine-tuned (EmoPrepend-1)

Installing ParlAI:


Standard Installation

If you want to use ParlAI without modifications, you can install it with:
pip install parlai

Development Installation

If you want to make some modifacations of Parlai, you can set up a development environment by running the following commands:
git clone https://github.com/facebookresearch/ParlAI.git ~/ParlAI
cd ~/ParlAI; python setup.py develop

Dependencies

Those version of libraries given are what the code was tested on:

Set up the Dataset:

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

Commands


Evaluate Bert model

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

Convert model to Parlai chatbot

To convert model into a model that we can use it in Parlai , we map the weights of the evaluated model over to something that can be used in ParlAI by runnig the following commands:
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

Chat with your chatbot

To chat with your Parlai model, you can run the following command on the terminal:
parlai interactive --model-file "${PRETRAINED_MODEL_PATH}"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%