Skip to content

Keras implementation of the Delete, Retrieve, Generate sentiment and style transfer research

Notifications You must be signed in to change notification settings

aniket03/sentiment_transfer_keras

Repository files navigation

Keras Implementation for Sentiment Style Transfer

This repository contains the keras implementation of sentiment style transfer using recurrent neural networks.

Model architecture and approach to perform sentiment style transfer are based on the paper Delete, Retrieve, Generate: A Simple Approach to Sentiment and Style Transfer

Presently, the repository implements Delete Only pipeline explained in the above paper.

Usage

  1. Download Yelp reviews dataset from here. Extract the contents in folder ../data/sentiment_transfer_data/yelp

  2. Compute attribute markers for the dataset. Attribute markers are words/ phrases for a given attribute / label such as positive or negative sentiment, presence or absence of which, is indicative of the given sentiment.
    Example positive sentiment attributes markers: [comfortable, amazing, beautiful]
    Example negative sentiment attributes markers: [horrible, careless, confused]
    To compute attribute markers basis training data run the script find_attribute_markers.py

  3. Generate content only sentences from the given reviews and computed attribute markers using the script: delete_attribute_markers.py

  4. Train the delete only architecture pipline using script delete_only_pipeline.py

  5. Finally, to check how well the model got trained run the script prediction_pipeline.py, to obtain predictions from the learnt model. Presently, the pipeline uses greedy decoding strategy instead of beam search to generate the final text sequence.

Sample results

Some good Results 😄

Original review: this place is just ok
Reverted review: this place is awesome

Original review: now the food , drinks , and desserts are amazing
Reverted review: now the food drinks and desserts are terrible

Original review: i had a horrible experience , and i sadly would not come back
Reverted review: i had a great experience and i would definitely back

Some not so good results 😔

Original review: no stars is what in want to give
Reverted review: thank stars is what to want to

Original review: this is the worst walmart neighborhood market out of any of them
Reverted review: this is the most authentic store out of them

More to come

  1. Will soon try to add to the repo Delete and retrieve pipeline, the second sentiment style transfer approach as shared in the paper.
  2. Delete Only implementation which uses beam search decoding strategy.

References

  1. Research work: Delete, Retrieve, Generate: A Simple Approach to Sentiment and Style Transfer
  2. Earlier implementations:
    1. From the authors
    2. Pytorch implementation

About

Keras implementation of the Delete, Retrieve, Generate sentiment and style transfer research

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages