GithubHelp home page GithubHelp logo

tonydeep / a-hierarchical-latent-structure-for-variational-conversation-modeling Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ctr4si/a-hierarchical-latent-structure-for-variational-conversation-modeling

0.0 2.0 0.0 53 KB

PyTorch Implementation of "A Hierarchical Latent Structure for Variational Conversation Modeling" (NAACL 2018 Oral)

License: MIT License

Python 100.00%

a-hierarchical-latent-structure-for-variational-conversation-modeling's Introduction

Variational Hierarchical Conversation RNN (VHCR)

PyTorch 0.4 Implementation of "A Hierarchical Latent Structure for Variational Conversation Modeling" (NAACL 2018 Oral)

Prerequisite

Install Python packages

pip install -r requirements.txt

Download & Preprocess data

Following scripts will

  1. Create directories ./datasets/cornell/ and ./datasets/ubuntu/ respectively.

  2. Download and preprocess conversation data inside each directory.

python cornell_preprocess.py
    --max_sentence_length (maximum number of words in sentence; default: 30)
    --max_conversation_length (maximum turns of utterances in single conversation; default: 10)
    --max_vocab_size (maximum size of word vocabulary; default: 20000)
    --max_vocab_frequency (minimum frequency of word to be included in vocabulary; default: 5)
    --n_workers (number of workers for multiprocessing; default: os.cpu_count())
python ubuntu_preprocess.py
    --max_sentence_length (maximum number of words in sentence; default: 30)
    --max_conversation_length (maximum turns of utterances in single conversation; default: 10)
    --max_vocab_size (maximum size of word vocabulary; default: 20000)
    --max_vocab_frequency (minimum frequency of word to be included in vocabulary; default: 5)
    --n_workers (number of workers for multiprocessing; default: os.cpu_count())

Training

Go to the model directory and set the save_dir in configs.py (this is where the model checkpoints will be saved)

We provide our implementation of VHCR, as well as our reference implementations for HRED and VHRED.

To run training:

python train.py --data=<data> --model=<model> --batch_size=<batch_size>

For example:

  1. Train HRED on Cornell Movie:
python train.py --data=cornell --model=HRED
  1. Train VHRED with word drop of ratio 0.25 and kl annealing iterations 250000:
python train.py --data=ubuntu --model=VHRED --batch_size=40 --word_drop=0.25 --kl_annealing_iter=250000
  1. Train VHCR with utterance drop of ratio 0.25:
python train.py --data=ubuntu --model=VHCR --batch_size=40 --sentence_drop=0.25 --kl_annealing_iter=250000

By default, it will save a model checkpoint every epoch to <save_dir> and a tensorboard summary. For more arguments and options, see config.py.

Evaluation

To evaluate the word perplexity:

python eval.py --model=<model> --checkpoint=<path_to_your_checkpoint>

For embedding based metrics, you need to download Google News word vectors, unzip it and put it under the datasets folder. Then run:

python eval_embed.py --model=<model> --checkpoint=<path_to_your_checkpoint>

Reference

If you use this code or dataset as part of any published research, please refer the following paper.

@inproceedings{VHCR:2018:NAACL,
    author    = {Yookoon Park and Jaemin Cho and Gunhee Kim},
    title     = "{A Hierarchical Latent Structure for Variational Conversation Modeling}",
    booktitle = {NAACL},
    year      = 2018
    }

a-hierarchical-latent-structure-for-variational-conversation-modeling's People

Contributors

j-min avatar solrefa-csi avatar yookoon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.