No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Tianxiao Shen
Tianxiao Shen readme
Latest commit f078a9d Feb 6, 2018
Failed to load latest commit information.
code clean Feb 6, 2018
data/yelp data Feb 6, 2018
img img Sep 20, 2017
.gitignore .DS_Store Jul 14, 2017
LICENSE Initial commit Jul 14, 2017 readme Feb 6, 2018 download trained model Feb 6, 2018

Language Style Transfer

This repo contains the code and data of the following paper:

"Style Transfer from Non-Parallel Text by Cross-Alignment". Tianxiao Shen, Tao Lei, Regina Barzilay, and Tommi Jaakkola. NIPS 2017. arXiv

The method learns to perform style transfer between two non-parallel corpora. For example, given positive and negative reviews as two corpora, the model can learn to reverse the sentiment of a sentence.

Spotlight Video


Data Format

Please name the corpora of two styles by "x.0" and "x.1" respectively, and use "x" to refer to them in options. Each file should consist of one sentence per line with tokens separated by a space.

The data/yelp/ directory contains an example Yelp review dataset.

Quick Start

  • To train a model, first create a tmp/ folder (where the model and results will be saved), then go to the code/ folder and run the following command:
python --train ../data/yelp/sentiment.train --dev ../data/yelp/ --output ../tmp/ --vocab ../tmp/yelp.vocab --model ../tmp/model
  • To test the model, run the following command:
python --test ../data/yelp/sentiment.test --output ../tmp/sentiment.test --vocab ../tmp/yelp.vocab --model ../tmp/model --load_model true --beam 8
  • To download a trained model, run bash, and then run the testing command with --vocab and --model options specifying ../model/yelp.vocab and ../model/model respectively.

  • Check code/ for all running options.


Python >= 2.7, TensorFlow 1.3.0