https://github.com/ruotianluo/neuraldialog-cvae-pytorch
https://github.com/ruotianluo/neuraldialog-cvae-pytorch
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ruotianluo/neuraldialog-cvae-pytorch
- Owner: ruotianluo
- License: apache-2.0
- Created: 2017-08-18T03:12:32.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-01T03:07:26.000Z (over 7 years ago)
- Last Synced: 2025-01-28T21:46:08.864Z (8 months ago)
- Language: OpenEdge ABL
- Size: 16.4 MB
- Stars: 94
- Watchers: 3
- Forks: 25
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Knowledge-Guided CVAE for dialog generation
It is a PyTorch implementation of the CVAE-based dialog model described in
**Learning Discourse-level Diversity for Neural Dialog Models using Conditional Variational Autoencoders**, accepted as a long paper in ACL 2017.
See the [paper](https://arxiv.org/abs/1703.10960) for more details. This project is modified from original tensorflow implementation [snakeztc/NeuralDialog-CVAE](https://github.com/snakeztc/NeuralDialog-CVAE)# Prerequisites
- TensorFlow 0.12.1+ (for tf.flag and tf.name_scope)
- PyTorch 0.4
- Python 2.7
- Numpy
- NLTK
- You may need to pip install beeprint if the module is missing# Usage
## Train a new model
python kgcvae_swda.py
will run default training and save model to ./working## Test a existing model
Modify the TF flags at the top of kgcvae_swda.py as follows to run a existing modelforward_only: False -> True
test_path: set to the folder contains the model. E.g. runxxxx
Then you can run the model by:python kgcvae_swda.py
The outputs will be printed to stdout and generated responses will be saved at test.txt in the test_path.## Use pre-trained Word2vec
Download Glove word embeddings from https://nlp.stanford.edu/projects/glove/
The default setting use 200 dimension word embedding trained on Twitter.At last, set **word2vec_path** at line 15 of kgcvae_swda.py.
## Dataset
We release two dataset:1. full_swda_clean_42da_sentiment_dialog_corpus.p is a binary dump using python Pickle library that contains the raw data and used for training
2. json_format: the same dialog data also is presented in JSONL format in the data directory.
3. test_mutl_ref.json is only the test data set with multiple references responses with dialog act annotations. The multiple referneces are collected
according to the method described in the Appendix of the paper.# Data Format
If you want to train the model on your own data. Please create a pickle file has the following format:# The top directory is a python dictionary
type(data) = dict
data.keys() = ['train', 'valid', 'test']# Train/valid/test is a list, each element is one dialog
train = data['train']
type(train) = list# Each dialog is a dict
dialog = train[0]
type(dialog)= dict
dialog.keys() = ['A', 'B', 'topic', 'utts']# A, B contain meta info about speaker A and B.
# topic defines the dialog prompt topic in Switchboard Corpus.# utts is a list, each element is a tuple that contain info about an utterance
utts = dialog['utts']
type(utts) = list
utts[0] = ("A" or "B", "utterance in string", [dialog_act, other_meta_info])# For example, a utterance look like this:
('B','especially your foreign cars',['statement-non-opinion'])Put the resulting file into ./data and set the **data_dir** in kgcvae_swda.py
# References
If you use any source codes or datasets included in this toolkit in your
work, please cite the following paper. The bibtex are listed below:
[Zhao et al, 2017]:
@article{zhao2017learning,
title={Learning Discourse-level Diversity for Neural Dialog Models using Conditional Variational Autoencoders},
author={Zhao, Tiancheng and Zhao, Ran and Eskenazi, Maxine},
journal={arXiv preprint arXiv:1703.10960},
year={2017}
}