All Projects → XinnuoXu → CVAE_Dial

XinnuoXu / CVAE_Dial

Licence: other
CVAE_XGate model in paper "Xu, Dusek, Konstas, Rieser. Better Conversations by Modeling, Filtering, and Optimizing for Coherence and Diversity"

Programming Languages

python
139335 projects - #7 most used programming language
perl
6916 projects
emacs lisp
2029 projects
shell
77523 projects
smalltalk
420 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to CVAE Dial

A-Persona-Based-Neural-Conversation-Model
No description or website provided.
Stars: ✭ 22 (+37.5%)
Mutual labels:  seq2seq, sequence-to-sequence, dialogue-generation
Dstc8 Schema Guided Dialogue
The Schema-Guided Dialogue Dataset
Stars: ✭ 277 (+1631.25%)
Mutual labels:  dialogue, nlp-machine-learning
Speech recognition with tensorflow
Implementation of a seq2seq model for Speech Recognition using the latest version of TensorFlow. Architecture similar to Listen, Attend and Spell.
Stars: ✭ 253 (+1481.25%)
Mutual labels:  seq2seq, sequence-to-sequence
Multiwoz
Source code for end-to-end dialogue model from the MultiWOZ paper (Budzianowski et al. 2018, EMNLP)
Stars: ✭ 384 (+2300%)
Mutual labels:  dialogue, seq2seq
Natural Language Processing With Tensorflow
Natural Language Processing with TensorFlow, published by Packt
Stars: ✭ 222 (+1287.5%)
Mutual labels:  seq2seq, nlp-machine-learning
Text summarization with tensorflow
Implementation of a seq2seq model for summarization of textual data. Demonstrated on amazon reviews, github issues and news articles.
Stars: ✭ 226 (+1312.5%)
Mutual labels:  seq2seq, sequence-to-sequence
Seq2seq Chatbot For Keras
This repository contains a new generative model of chatbot based on seq2seq modeling.
Stars: ✭ 322 (+1912.5%)
Mutual labels:  dialogue, seq2seq
Openseq2seq
Toolkit for efficient experimentation with Speech Recognition, Text2Speech and NLP
Stars: ✭ 1,378 (+8512.5%)
Mutual labels:  seq2seq, sequence-to-sequence
Tgen
Statistical NLG for spoken dialogue systems
Stars: ✭ 179 (+1018.75%)
Mutual labels:  dialogue, seq2seq
few shot dialogue generation
Dialogue Knowledge Transfer Networks (DiKTNet)
Stars: ✭ 24 (+50%)
Mutual labels:  emnlp, dialogue-generation
dynmt-py
Neural machine translation implementation using dynet's python bindings
Stars: ✭ 17 (+6.25%)
Mutual labels:  seq2seq, sequence-to-sequence
Video Captioning
This repository contains the code for a video captioning system inspired by Sequence to Sequence -- Video to Text. This system takes as input a video and generates a caption in English describing the video.
Stars: ✭ 131 (+718.75%)
Mutual labels:  seq2seq, sequence-to-sequence
Mlds2018spring
Machine Learning and having it Deep and Structured (MLDS) in 2018 spring
Stars: ✭ 124 (+675%)
Mutual labels:  seq2seq, sequence-to-sequence
Pytorch Seq2seq
Tutorials on implementing a few sequence-to-sequence (seq2seq) models with PyTorch and TorchText.
Stars: ✭ 3,418 (+21262.5%)
Mutual labels:  seq2seq, sequence-to-sequence
Delta
DELTA is a deep learning based natural language and speech processing platform.
Stars: ✭ 1,479 (+9143.75%)
Mutual labels:  seq2seq, sequence-to-sequence
Trade Dst
Source code for transferable dialogue state generator (TRADE, Wu et al., 2019). https://arxiv.org/abs/1905.08743
Stars: ✭ 287 (+1693.75%)
Mutual labels:  dialogue, seq2seq
SequenceToSequence
A seq2seq with attention dialogue/MT model implemented by TensorFlow.
Stars: ✭ 11 (-31.25%)
Mutual labels:  dialogue, seq2seq
Sequence To Sequence 101
a series of tutorials on sequence to sequence learning, implemented with PyTorch.
Stars: ✭ 62 (+287.5%)
Mutual labels:  seq2seq, sequence-to-sequence
Xmunmt
An implementation of RNNsearch using TensorFlow
Stars: ✭ 69 (+331.25%)
Mutual labels:  seq2seq, sequence-to-sequence
Nlp Paper
自然语言处理领域下的对话语音领域,整理相关论文(附阅读笔记),复现模型以及数据处理等(代码含TensorFlow和PyTorch两版本)
Stars: ✭ 67 (+318.75%)
Mutual labels:  dialogue, nlp-machine-learning

CVAE_XGate_dialogue_generator

This project is a pytorch implementation for my paper "Xinnuo Xu, Ondrej Dusek, Yannis Konstas, and Verena Rieser. Better conversations by modeling,filtering, and optimizing for coherence and diversity. In: Conference on Empirical Methods in NaturalLanguage Processing (EMNLP). Brussels, 2018."

* This project is for model CVAE_XGates. For model CVAE_CGate, please visit https://github.com/XinnuoXu/CVAE_Dial_CGate

Requirements

Quickstart

Step1: Download the OpenSubtitles dataset

This code is based on OpenSubtitles dataset Automatic Turn Segmentation for Movie & TV Subtitles. To get the data, please contact the authors Pierre Lison. You should unzip the datset and name it as opensubtitles and put it in

data/filter/

Step2: Creat datasets for generator and discriminator

For the generator, a training pair consists of a dialogue context and a corresponding response. We consider three consecutive turns as the dialogue context and the following turn as the response. For the discriminator, positive examples are dialogue contexts with their following turn as the response, while negative examples are dialogue contexts with an utterance randomly sampled in the same dialogue as the response.

We use toolkit Opensubtitles processing tool owned by Ondrej Dusek to extract dialogues from OpenSubtitles dataset data/filter/opensubtitles/.

~/data/movie_tools/convert_nrno_subs.py -D -s -S train:train-dev:dev:test -r 97:1:1:1 -d all_dialogues_cased opensubtitles/ dial.jsons.txt

The outputs are

  • train.dial.jsons.txt
  • train-dev.dial.jsons.txt
  • dev.dial.jsons.txt
  • test.dial.jsons.txt

as the split ratio 97:1:1:1 with format of one dialogue per line

["utterance 1", "utterance 2", "utterance 3"...]

for example,

["Watch out !", "Oh , what fun !", "JON :", "That was fun .", "Oh , that was great !", "Oh , time for a break ?", "Dad , I 'm hungry .", "I 'm really hungry .", "Can we eat now ?", "Keep your shirt on .", "We 'll be in Potter 's Cove in 20 minutes .", "OK , how about some pictures ?", "Here we go .", "Everybody smile .", "Say cheese ."]

Then, we construct the training dataset for generator and discriminator from train.dial.jsons.txt by running

python data_reading.py

The outputs are

  • train.en inputs of encoder in generator (dialogue contexts)
  • train.vi outputs of decoder in generator (expacted responses)
  • train.pos positive examples for discriminator (dialogue contexts with their following turn as the response)
  • train.neg negative examples for discriminator (dialogue contexts with an utterance randomly sampled in the same dialogue as the response)

The format of train.en is utterance1 <u2> utterance2 <u1> utterance3 in each line, for example

well , i 'm glad you called me . <u2> i 'm not . <u1> no , you did the right thing .

The format of train.vi is response in each line, for example

you 'll protect him , won 't you ?

The formats for train.pos and train.neg are the same utterance1 <u2> utterance2 <u1> utterance3 \t response, for example

pull up sooner . <u2> ok , skipper ! <u1> do you think they 'll ever get it ?	     give them a week .

At last, we randomly sample 5000 cases for train-dev, dev, test separately by running following commands and outputs for each set are similar with training set.

  • python data_reading_shaffle.py train-dev for train-dev set
  • python data_reading_shaffle.py dev for dev set
  • python data_reading_shaffle.py test for testing set

Step3: Filter the training set for generator

Step3.1: Train GloVe model on OpenSubtitles

Run the following command in data/filter/ to read subtitles from json files and save in file bag_of_words in the same directory.

python read_html.py

Then, run the following two commands to train a GloVe model on the OpenSubtitles dataset. get_corpus.py is used to build the corpus model corpus.model and train.py train the model on corpus.model. The trained model is glove.model in the same directory.

python get_corpus.py
python train.py

Step3.2: Filter the training set for generator

python get_glove_score.py train

The outputs for this command is cosine distance of the two semantic vectors of a dialogue context and its response (Eq.1 in the paper). The format is cosine distance \t dialogue context \t response. For example

0.9228650507713863	  they tell the whole story . <u2> i sent them , but i want the weekend . <u1> please , mr president .	    only at the weekend .

Then you can filter training pairs with lower coherence score (cosine distance) and rewrite the train.en file with the filtered dialogue contexts and train.vi file with their responses.

Step4: Training for Generator (and Discriminator)

Step4.1: Data copying

You need to copy the following data from data/filter/ to data/.

  • train.en
  • train.vi
  • dev.en
  • dev.vi
  • test.en
  • test.vi

Step4.2: Dictionary building and data preparation

sh preprocess.sh

This command will create three socuments in data/.

  • dialogue.train.1.pt
  • dialogue.valid.1.pt
  • dialogue.vocab.pt

Step4.3: Discriminator training

cd get_c/
sh train.sh

This command will create glove.model in get_c/.

Step4.4: Generator training

Now, go back to the main directory. Run the following command to train the CVAEf_CGate generator

python train.py -data data/dialogue -save_model dialogue-model -epochs 30 -report_every 100 -batch_size 128 -dropout 0.2 -src_word_vec_size 128 -tgt_word_vec_size 128 -rnn_size 128 -global_attention general -input_feed 0 -glove_dir get_c/glove.model -learning_rate 1 -context_gate both

The trained models are named as dialogue-model_acc_*

Step5: Inference

python translate.py -model $MODEL -src data/test.en -tgt data/test.vi -report_bleu -verbose

The predictions are saved in file pred.txt

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].