This is the official respository for the Automating Empathy in Dialogue Systems project. A complete technical report is available here. All our model checkpoints can be found here. In case of any queries, please contact [email protected].
Please run pip install -r requirements.txt
to install all third-party libraries required by the framework.
To setup the EPITOME, EMO-ACC, and INTENT-ACC models, use the following steps:
- Download all files from the Google Drive hosted by Lee et al., 2022.
- Create a directory called
empathy_metric_models
in your root folder. - Create a sub-directory in
empathy_metric_models
calledepitome_models
and place thefine_tuned_ER.pth
,fine_tuned_EX.pth
, andfine_tuned_IP.pth
files in this sub-directory. - Create a sub-directory in
empathy_metric_models
calledemo_classifier
. Unpackemotion.tar.gz
and place all its contents in this sub-directory. - Create a sub-directory in
empathy_metric_models
calledintent_classifier
. Unpackempintent.tar.gz
and place all its contents in this sub-directory.
We provide some example commands for the training and testing framework below. Additional command line arguments can also be included. Simply refer to the available list of arguments in the parse_args
function of the corresponding python script. We also have additional scripts such as test_gpt3.py
, interact.py
, evaluate.py
, compare.py
, and multi-turn.py
to aide with testing and evaluation as well as interact with models. Please refer to these scripts to learn how to use them.
Following is an example command:
python3 src/train_dialogue_model.py --dataset_dir datasets/empathetic_dialogues --model GODEL_LARGE --output_dir ~/fine_tuned_models/GODEL_LARGE --max_epochs 5 --batch_size 8 --initial_lr 0.00001
To add a custom model, follow these steps:
- Add the model class inherited from
EncoderDecoderModel
orDecoderModel
tosrc/dialogue_models.py
with appropriately defined functions (seebase_classes.py
for all top-level functions for the model class) - Add the tokenizer class inherited from
TokenizerBase
orHuggingFaceTokenizerBase
tosrc/custom_tokenizers.py
with appropriately defined functions (seebase_classes.py
for all top-level functions for the tokenizer class) - Add a model configuration in
configs.json
with any custom name and the corresponding model and tokenizer class as well as any additional arguments. The format can be copied from some pre-defined configurations.
A custom dataset can be added by splitting the dataset directory into train
, val
, and test
subdirectories and formatting the data in each directory in the following categories which should be self-explanatory: contexts.json
, targets.json
, instructions.json
(optional), and knowledge.json
(optional). See datasets/empathetic_dialogues
or datasets/blended_skill_talk
for reference.
Following is an example command:
python3 src/train_reward_model.py --dataset_dir datasets/reward_dataset --model GODEL_LARGE --output_dir ~/reward_models/GODEL_LARGE --max_epochs 1 --initial_lr 0.00001
.
Batch size support is not included yet. Custom models are added exactly as discussed in the last section. To add a custom dataset, specify a train
subdirectory in the dataset directory formatted in the following categories: contexts.json
, responses.json
, and ratings.json
. We use the same dataset for validation and have not yet included support for testing reward models. See datasets/reward_dataset
for reference.
Following is an example command:
python3 src/train_rlhf_pipeline.py --dataset_dir datasets/empathetic_dialogues --pretrained_model_dir ~/fine_tuned_models/GODEL_LARGE/tensorboard_logs/version_0 --reward_model_dir ~/reward_models/GODEL_LARGE/tensorboard_logs/version_0 --output_dir ~/fine_tuned_models/GODEL_LARGE_RLHF --max_epochs 5 --batch_size 8 --initial_lr 0.00001 --beam_width 1 --sample --top_p 0.9 --top_k 50
.
Following is an example command:
python3 src/test.py --dataset_dir datasets/empathetic_dialogues --pretrained_model_dir ~/fine_tuned_models/GODEL_LARGE_RLHF/tensorboard_logs/version_0 --emo_classifier_dir ~/empathy_metric_models/emo_classifier --intent_classifier_dir ~/empathy_metric_models/intent_classifier --epitome_dir ~/empathy_metric_models/epitome_models --reward_model_dir ~/reward_models/GODEL_LARGE --batch_size 128
.