Giter VIP home page Giter VIP logo

style_transformer's Introduction

Style Transformer: Unpaired Text Style Transfer without Disentangled Latent Representation

This folder contains the code for the paper 《Style Transformer: Unpaired Text Style Transfer without Disentangled Latent Representation》

  1. Requirements
    • pytorch >= 0.4.0
    • torchtext >= 0.4.0
    • nltk
    • fasttext == 0.8.3
    • kenlm
  2. nltk
    • Run the following command to download (or double-check) nltk tokenizer dependency:
    python -c "import nltk; nltk.download('punkt')"
    
  3. LM for evaluator
    • download from ppl_yelp.bin
    • put ppl_yelp.binary in the folder evaluator

Usage

The hyperparameters for the Style Transformer can be found in ''main.py''.

The most of them are listed below:

    data_path : the path of the datasets
    log_dir : where to save the logging info
    save_path = where to save the checkpoing
    
    discriminator_method : the type of discriminator ('Multi' or 'Cond')
    min_freq : the minimun frequency for building vocabulary
    max_length : the maximun sentence length 
    embed_size : the dimention of the token embedding
    d_model : the dimention of Transformer d_model parameter
    h : the number of Transformer attention head
    num_layers : the number of Transformer layer
    batch_size : the training batch size
    lr_F : the learning rate for the Style Transformer
    lr_D : the learning rate for the discriminator
    L2 : the L2 norm regularization factor
    iter_D : the number of the discriminator update step pre training interation
    iter_F : the number of the Style Transformer update step pre training interation
    dropout : the dropout factor for the whole model

    log_steps : the number of steps to log model info
    eval_steps : the number of steps to evaluate model info

    slf_factor : the weight for self reconstruction loss
    cyc_factor : the weight for cycle reconstruction loss
    adv_factor : the weight for style controlling loss

You can adjust them in the Config class from the ''main.py''.

If you want to run the model, use the command:

python main.py

Outputs

Update: You can find the outputs of our model in the "outputs" folder. here is the ckpt for imdb and yelp dataset: ckpt.rar

Example

   ******************** neg sample ********************
   [gold] there chips are ok , but their salsa is really bland .
   [raw ] there chips are ok , but their salsa is really bland .
   [rev ] pub chips are ok but their salsa is really good !
   [ref ] these chips are okay but their salsa is really tasty .
   
   [gold] blue cheese dressing was n't the best by any means .
   [raw ] blue cheese dressing was n't the best by any means .
   [rev ] blue cheese dressing was the best means !
   [ref ] blue cheese dressing was above average .
   
   ******************** pos sample ********************
   [gold] amazing food , great service .
   [raw ] amazing food , great service .
   [rev ] terrible hostess , horrible kfc .
   [ref ] lousy food , slow service .

style_transformer's People

Contributors

jesse1eung 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.