Skip to content

The focused positive and negative emotion based dialogue generation using GAN

Notifications You must be signed in to change notification settings

mSaify/EmoContextDG

Repository files navigation

This is extensions work of https://github.com/qtli/EmpDG combining GAN and MIME approach for mimicking postive and negative emotions. The overall change is only in the encoder layer which used mimicking along with semantic embeddings.

EmpDG: Multiresolution Dialog Generation with semantic focus

Setup

  • Check the packages needed or simply run the command:
pip install -r requirements.txt
  • The dataset (empathetic-dialogue) is preprocessed and stored in pickle format:
.
└── empathetic-dialogue
    └── empdg_dataset_preproc.p
  • Download GloVe vectors from here (glove.6B.300d.txt) and put it into /vectors/.

  • For reproducibility purposes, we place the model checkpoints at Google Drive. You could download and move it under /result/.

  • To skip training, please check folder /Predictions/.

Run code

Training

EmpDG

# 1. Pre-train Empathetic Generator (EmpDG_woD)
# 2. Pre-train two Interactive Discriminators
# 3. Joint-train two components
python3 adver_train.py --cuda --label_smoothing --noam --emb_dim 300 --rnn_hidden_dim 300 --hidden_dim 300  --hop 1 --heads 2 --emotion_disc --pretrain_emb --model EmpDG --device_id 0 --save_path save/EmpDG/ --d_steps 1 --g_steps 5 --pointer_gen

EmpDG_woD

# Empathetic Generator
python train_generator.py --cuda --label_smoothing --noam --emb_dim 300 --hidden_dim 300 --hop 1 --heads 2 --pretrain_emb --model EmpDG_woD --device_id 0 --save_path save/EmpDG_woD/ --pointer_gen

EmpDG_woG

# We regard the baseline EmoPrepend as generator, which only considers the coarse-grained emotional factor. 
# We only use the semantic discriminator to distinguish the generated responses and the gold ones. 

python3 adver_train_no_eg.py --cuda --label_smoothing --noam --emb_dim 300 --rnn_hidden_dim 300  --hidden_dim 300 --hop 1 --heads 2 --cuda --pretrain_emb --model EmpDG_woG --device_id 0 --save_path save/EmpDG_woG/ --d_steps 1 --g_steps 5 --pointer_gen 

Add --resume_g --resume_d into the command to directly use the pre-trained generator or discriminator.

Testing

EmpDG

Make sure that the trained model result/EmpDG_best.tar exists.

python3 train.py --test --model EmpDG --cuda --label_smoothing --noam --emb_dim 300 --rnn_hidden_dim 300 --hidden_dim 300  --hop 1 --heads 2 --pretrain_emb --device_id 0 --save_path save/EmpDG/ --pointer_gen

Interaction

python3 interact.py --model EmpDG --cuda --label_smoothing --noam --emb_dim 300 --rnn_hidden_dim 300 --hidden_dim 300  --hop 1 --heads 2 --pretrain_emb --device_id 0 --save_path save/EmpDG/ --pointer_gen
  • Generation examples from an interactive environment:
Role Response
User i am so excited because i am finally going to visit my old friend !
EmpSem that is awesome ! what kind of visit ?
User we will enjoy chatting and playing .
EmpSem that is a lot of nostalgia .
Role Response
User i argued with my brother .
EmpSem oh no ! what happened ?
User i don't want to recall .
EmpSem i am sorry , that is not a good thing .

About

The focused positive and negative emotion based dialogue generation using GAN

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published