Code Monkey home page Code Monkey logo

style-transfer-through-back-translation's Introduction

Style Transfer Through Back-Translation

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

Style Transfer Through Back-Translation. Shrimai Prabhumoye, Yulia Tsvetkov, Ruslan Salakhutdinov, Alan W Black. ACL 2018. arXiv

Dependencies

  • Python 3.6
  • Pytorch 0.3

Trained Machine Translation Models

  • Dowload the english--french and french--english models from the following link:
http://tts.speech.cs.cmu.edu/style_models/english_french.tar
http://tts.speech.cs.cmu.edu/style_models/french_english.tar

Place these models in the models/translation folder.

Trained Classifier Models

  • Dowload the trained gender, political slant and sentiment classifiers from the following link:
http://tts.speech.cs.cmu.edu/style_models/gender_classifier.tar
http://tts.speech.cs.cmu.edu/style_models/political_classifier.tar
http://tts.speech.cs.cmu.edu/style_models/sentiment_classifier.tar

Place these models in the models/classifierfolder. The three classifiers are trained for the following labels:

Task Label = 0 Label = 1
Gender Male Female
Political Republican Democratic
Sentiment Negative Positive

Trained Style Models

  • Download the trained style models from the following links:
http://tts.speech.cs.cmu.edu/style_models/female_generator.tar
http://tts.speech.cs.cmu.edu/style_models/male_generator.tar
http://tts.speech.cs.cmu.edu/style_models/democratic_generator.tar
http://tts.speech.cs.cmu.edu/style_models/republican_generator.tar
http://tts.speech.cs.cmu.edu/style_models/positive_generator.tar
http://tts.speech.cs.cmu.edu/style_models/negative_generator.tar

Place these models in the models/style_generators folder.

Quick Start

Refer to example.sh file to see the commands.

  • First cd style_decoder and then preprocess your raw data using the following command:
python preprocess.py -train_src TRAIN_SOURCE_FILE -train_tgt TRAIN_TARGET_FILE -valid_src VALID_SOURCE_FILE -valid_tgt VALID_TARGET_FILE -save_data DATA_NAME
  • Then train your model using the following command:
python train_decoder.py -data DATA_NAME.train.pt -save_model MODEL_DIR/MODEL_NAME -classifier_model CLASSIFIER.pt -encoder_model ENCODER_MODEL -tgt_label {0/1}

Data

Dowload the data required for the political slant transfer experiment from the following link and place it in data/ folder.

http://tts.speech.cs.cmu.edu/style_models/political_data.tar
tar -xvf political_data.tar

The train, dev, test and classtrain splits are given as is. If you are using this data then please cite the following papers:

@inproceedings{style_transfer_acl18,
  title={Style Transfer Through Back-Translation},
  author={Prabhumoye, Shrimai and Tsvetkov, Yulia and Salakhutdinov, Ruslan and Black, Alan W},
  year={2018},
  booktitle={Proc. ACL}
  }

@inproceedings{rtgender,
  title={{RtGender}: A Corpus for Studying Differential Responses to Gender},
  author={Voigt, Rob and Jurgens, David and Prabhakaran, Vinodkumar and Jurafsky, Dan and Tsvetkov, Yulia},
  year={2018},
  booktitle={Proc. LREC},
  }

Dowload the data required for the gender transfer experiment from the following link and place it in data/ folder.

http://tts.speech.cs.cmu.edu/style_models/gender_data.tar
tar -xvf gender_data.tar

The train, dev, test and classtrain splits are given as is. If you are using this data then please cite the following papers:

@inproceedings{style_transfer_acl18,
  title={Style Transfer Through Back-Translation},
  author={Prabhumoye, Shrimai and Tsvetkov, Yulia and Salakhutdinov, Ruslan and Black, Alan W},
  year={2018},
  booktitle={Proc. ACL}
  }
  
@inproceedings{reddy2016obfuscating,
  title={Obfuscating gender in social media writing},
  author={Reddy, Sravana and Knight, Kevin},
  year={2016},
  booktitle={Proc. of Workshop on Natural Language Processing and Computational Social Science}
  pages={17--26},
  }

You can find the data used in the sentiment modification experiment described in the paper at this link. The train, dev, test and classtrain splits are given as is.

Download the data used in Multiple-Attribute Text Rewriting paper from the following link.

http://tts.speech.cs.cmu.edu/style_models/yelp_reviews.txt
http://tts.speech.cs.cmu.edu/style_models/yelp_attrs.txt

Acknowledgements

The code used to train the NMT systems is from the OpenNMT toolkit. This code base is based on the code of the toolkit.

style-transfer-through-back-translation's People

Contributors

shrimai avatar

Watchers

 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.