Giter VIP home page Giter VIP logo

nc_style_transfer's Introduction

Controllable Text Attribute Transfer

Code for the paper: Controllable Unsupervised Text Attribute Transfer via Editing Entangled Latent Representation(Arxiv:1905.12926)

Introduction

In this work, we present a controllable unsupervised text attribute transfer framework, which can edit the entangled latent representation instead of modeling attribute and content separately. Specifically, we first propose a Transformer-based autoencoder to learn an entangled latent representation for a discrete text, then we transform the attribute transfer task to an optimization problem and propose the Fast-Gradient-Iterative-Modification algorithm to edit the latent representation until conforming to the target attribute. To the best of our knowledge, this is the first one that can not only control the degree of transfer freely but also perform sentiment transfer over multiple aspects at the same time.

Model architecture

Documents

Dependencies

Python 3.6
PyTorch 0.4

Directory description

Root
├─data/*        Store the data files used by models.
├─method/*      Store the source code of models.
└─outputs/*     Store the final output of models.

Data Preprocessing

In the data directory,run:

python preprocessed_data.py 

Model Training

To train the model, run in the method directory:

python main.py 

After the training finished, you can specify the check point directory in main.py,

args.if_load_from_checkpoint = True
args.checkpoint_name = "xxx"

Or you can load my check-point file:

'/save/1557667911' for yelp;
'/save/1557668663' for amazon;
'/save/1557891887' for captions;    

and run:

python main.py 

Example

Negative ->Positive:

Source:                 it is n’t terrible , but it is n’t very good either .
Human:                  it is n’t perfect , but it is very good .
Our model(w={1.0}):     it is n’t terrible , but it is n’t very good either .
Our model(w={2.0}):     it is n’t terrible , but it is n’t very good delicious either .
Our model(w={3.0}):     it is n’t terrible , but it is very good delicious either .
Our model(w={4.0}):     it is n’t terrible , but it is very good and delicious .
Our model(w={5.0}):     it is n’t terrible , but it is very good and delicious appetizer .
Our model(w={6.0}):     it is excellent , and it is very good and delicious well .

LICENSE

MIT

Citation

If you find our codes is helpful for your research, please kindly consider citing our paper:

@inproceedings{DBLP:journals/corr/abs-1905-12926,
  author    = {Ke Wang and Hang Hua and Xiaojun Wan},
  title     = {Controllable Unsupervised Text Attribute Transfer via Editing Entangled Latent Representation},
  booktitle = {NeurIPS},
  year      = {2019}
}

nc_style_transfer's People

Contributors

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