Git Product home page Git Product logo

text-style-transfer's Introduction

Alter the style: A neural text style transfer model

In this project we want to build a system that can transfer a language style into another style while preserving the main content (e.g. given a factual event, we can rewrite it like a romantic story).

Our goal:

  1. Transer the style (e.g. positive -> negative, factual -> romantic).

  2. Preserve the content.

This task is non-trivial, because normally we do not have sufficient data that have aligned sentences with the same content but expressed in different styles. Therefore, we have to learn a model which can disentangle style attributes and content given only unaligned sentences.

Model Architecture:

Usage

Training

python train.py --config sample_config.json

Train a negative auto-encoder based on data data/yelp/sentiment.train.0, which takes the neutral content and negative attributes as inputs, and will output a negative comment.
You can also train a positive auto-encoder by simply modifying the "src": "data/yelp/sentiment.train.1", in sample_config.json.

Testing

python test.py --config sample_config.json --bleu

Generate a negative comment based on positive comment dataset data/yelp/sentiment.truth.1, the procedure is as follows:

  • Take a positive comment, and extract its neutral content as the one of the inputs;

  • Retrieve a negative comment based on the neutral content, and extract its negative attributes as one of the inputs;

  • Combine the neutral content and negative attributes together, and feed them into the well-trained model;

  • Output the generated negative comment.

The script will generate the following files:

  • sample_run/inputs.epoch : the input neutral contents

  • sample_run/auxs.epoch : the input negative attributes

  • sample_run/preds.epoch : the generated negative comments

  • sample_run/golds.epoch : the ground truth negative comments

And you can also see the precision, recall, edit_distance and rouge score on the logging info.

Reference

text-style-transfer's People

Contributors

enihsuns avatar wyu-du avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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