Skip to content

PyTorch implementation of the Delete, Retrieve Generate style transfer algorithm

Notifications You must be signed in to change notification settings

akhisud3195/delete_retrieve_generate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

This is an implementation of the DeleteOnly and DeleteAndRetrieve models from Delete, Retrieve, Generate: A Simple Approach to Sentiment and Style Transfer

Installation

pip install -r requirements.txt

This code uses python 3.

Usage

Training

python train.py --config yelp_config.json --bleu

This will reproduce the delete model on a dataset of yelp reviews:

curves

Checkpoints, logs, model outputs, and TensorBoard summaries are written in the config's working_dir.

See yelp_config.json for all of the training options. The most important parameter is model_type, which can be set to delete, delete_retrieve, or seq2seq (which is a standard translation-style model).

Data prep

Given two pre-tokenized corpus files, use the scripts in tools/ to generate a vocabulary and attribute vocabulary:

python tools/make_vocab.py [entire corpus file (src + tgt cat'd)] [vocab size] > vocab.txt
python tools/make_attribute_vocab.py vocab.txt [corpus src file] [corpus tgt file] [salience ratio] > attribute_vocab.txt
python tools/make_ngram_attribute_vocab.py vocab.txt [corpus src file] [corpus tgt file] [salience ratio] > attribute_vocab.txt

Questions, feedback, bugs

rpryzant@stanford.edu

Acknowledgements

Thanks lots to Karishma Mandyam for contributing!

About

PyTorch implementation of the Delete, Retrieve Generate style transfer algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Roff 99.6%
  • Python 0.4%