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.
-
Download Yelp reviews dataset from here. Extract the contents in folder
../data/sentiment_transfer_data/yelp
-
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 scriptfind_attribute_markers.py
-
Generate content only sentences from the given reviews and computed attribute markers using the script:
delete_attribute_markers.py
-
Train the delete only architecture pipline using script
delete_only_pipeline.py
-
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.
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
- Will soon try to add to the repo
Delete and retrieve pipeline
, the second sentiment style transfer approach as shared in the paper. Delete Only
implementation which usesbeam search
decoding strategy.
- Research work: Delete, Retrieve, Generate: A Simple Approach to Sentiment and Style Transfer
- Earlier implementations: