All Projects → ChenWu98 → Point-Then-Operate

ChenWu98 / Point-Then-Operate

Licence: Apache-2.0 License
Code for the ACL 2019 paper ``A Hierarchical Reinforced Sequence Operation Method for Unsupervised Text Style Transfer``

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Point-Then-Operate

rudetoxifier
Code and data of "Methods for Detoxification of Texts for the Russian Language" paper
Stars: ✭ 30 (-31.82%)
Mutual labels:  style-transfer
awesome style transfer
The style transfer paper collection in International CV conference
Stars: ✭ 42 (-4.55%)
Mutual labels:  style-transfer
CariMe-pytorch
Unpaired Caricature Generation with Multiple Exaggerations (TMM 2021)
Stars: ✭ 33 (-25%)
Mutual labels:  style-transfer
NLP Toolkit
Library of state-of-the-art models (PyTorch) for NLP tasks
Stars: ✭ 92 (+109.09%)
Mutual labels:  style-transfer
CS231n
PyTorch/Tensorflow solutions for Stanford's CS231n: "CNNs for Visual Recognition"
Stars: ✭ 47 (+6.82%)
Mutual labels:  style-transfer
CoMoGAN
CoMoGAN: continuous model-guided image-to-image translation. CVPR 2021 oral.
Stars: ✭ 139 (+215.91%)
Mutual labels:  style-transfer
CycleGAN-Music-Style-Transfer-Refactorization
Symbolic Music Genre Transfer with CycleGAN - Refactorization
Stars: ✭ 28 (-36.36%)
Mutual labels:  style-transfer
Splice
Official Pytorch Implementation for "Splicing ViT Features for Semantic Appearance Transfer" presenting "Splice" (CVPR 2022)
Stars: ✭ 126 (+186.36%)
Mutual labels:  style-transfer
Text-to-Speech-Landscape
No description or website provided.
Stars: ✭ 31 (-29.55%)
Mutual labels:  style-transfer
CNTKUnityTools
Some Deep learning tools in Unity using CNTK
Stars: ✭ 21 (-52.27%)
Mutual labels:  style-transfer
dreamsnap
Real life through the eyes of an artist
Stars: ✭ 16 (-63.64%)
Mutual labels:  style-transfer
groove2groove
Code for "Groove2Groove: One-Shot Music Style Transfer with Supervision from Synthetic Data"
Stars: ✭ 88 (+100%)
Mutual labels:  style-transfer
neural style synthesizer
No description or website provided.
Stars: ✭ 15 (-65.91%)
Mutual labels:  style-transfer
SANET
Arbitrary Style Transfer with Style-Attentional Networks
Stars: ✭ 105 (+138.64%)
Mutual labels:  style-transfer
TET-GAN
[AAAI 2019] TET-GAN: Text Effects Transfer via Stylization and Destylization
Stars: ✭ 74 (+68.18%)
Mutual labels:  style-transfer
CartoonGAN-tensorflow
Simple code implement the paper of CartoonGAN(CVPR2018)
Stars: ✭ 14 (-68.18%)
Mutual labels:  style-transfer
ada-conv-pytorch
No description or website provided.
Stars: ✭ 46 (+4.55%)
Mutual labels:  style-transfer
pytorch-neural-style-transfer-johnson
Reconstruction of the fast neural style transfer (Johnson et al.). Some portions of the paper have been improved by the follow-up work like the instance normalization, etc. Checkout transformer_net.py's header for details.
Stars: ✭ 85 (+93.18%)
Mutual labels:  style-transfer
CS231n
My solutions for Assignments of CS231n: Convolutional Neural Networks for Visual Recognition
Stars: ✭ 30 (-31.82%)
Mutual labels:  style-transfer
tf-adain
TensorFlow implementation of the paper "Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization" by Xun Huang and Serge Belongie
Stars: ✭ 61 (+38.64%)
Mutual labels:  style-transfer

Point-Then-Operate

This repository contains PyTorch implementations of the ACL2019 paper "A Hierarchical Reinforced Sequence Operation Method for Unsupervised Text Style Transfer". [paper] | [slides]

     

Overview

  • data/yelp/ and data/amazon/ are placeholder directories for the Yelp and the Amazon datasets, respectively
  • PTO-yelp/ and PTO-amazon/ contain implementations of the proposed method for the Yelp and the Amazon datasets, respectively
  • In the following lines, {} denotes or, e.g., {yelp, amazon} denotes yelp or amazon
  • All commands should be run in PTO-{yelp, amazon}/, instead of the root directory
  • PTO-{yelp, amazon}/Experiment.py builds the experiment pipeline, which has undergone incremental modifications and currently includes abstract (e.g., with heavy use of getattr() and setattr()) lines of codes. Thus, it is not recommended to heavily rely on the pipeline for your own projects

Dependencies

  • Python 3.6.5
  • Versions of all depending libraries are specified in requirements.txt. To reproduce the reported results, please make sure that the specified versions are installed. Update 28/08/2019: We receive a security vulnerability alert for the specified version of nltk from GitHub.
  • System outputs are evaluated based on the Moses BLEU script multi-bleu.perl. Download the script and put it into PTO-{yelp, amazon}/utils/
  • Run on a single NVIDIA GeForce GTX 1080 Ti
  • CUDA 10.0

Usage

Test with Pre-Trained Models

  • Download preliminary files from Yelp preliminaries and Amazon preliminaries, which include
    • Pre-trained language models: {yelp, amazon}_{0, 1}_{forward, backward}.pt. Place them in PTO-{yelp, amazon}/LM/saved_models/
    • Pre-trained TextCNN: best-TextCNN-{yelp, amazon}-Emb.ckpt and best-TextCNN-{yelp, amazon}.ckpt. Place them in PTO-{yelp, amazon}/utils/
    • Vocabulary: {yelp, amazon}.vocab. Place them in data/{yelp, amazon}/
  • Download the pre-processed datasets from Yelp dataset and Amazon dataset, which include
    • Non-aligned text files for both styles: sentiment.{train, dev, test}.{0, 1}. Place them in data/{yelp, amazon}/
    • Human written references for the test split: reference.{0, 1}. Place them in data/{yelp, amazon}/
  • Download pre-trained models from Yelp pre-trained and Amazon pre-trained, which include
    • Pointer, operators, and the additional classifier: ten .ckpt files in total. Place them in PTO-{yelp, amazon}/pretrained/
  • Run python3 test.py in PTO-{yelp, amazon}/
  • Evaluation results, i.e., classification accuracy and BLEU score, are printed on the screen, which should be exactly the same as those reported in the paper.
  • System outputs are saved under PTO-{yelp, amazon}/outputs/sampled_results/, which include
    • Negative to positive outputs: sentiment.test.0.ours
    • Positive to negative outputs: sentiment.test.1.ours
  • Reminder: reference.{0, 1} aligns each test sample to its human reference. However, for the Amazon dataset, the order of sentences in reference.{0, 1} is not consistent with that in sentiment.test.{0, 1}. We fix it in PTO-amazon/dataloaders/amazon.py. Take care if you are using the Amazon dataset for your own project

Train the Models

  • Train language models (optional and not recommended since they are only used as extrinsic rewards)
    • Set the flags self.sentiment and self.direction in PTO-{yelp, amazon}/LM/lm_config.py
    • Run python3 language_model.py in PTO-{yelp, amazon}/
    • Repeat the previous two steps for each combination of self.sentiment and self.direction
  • Train TextCNN (optional and strongly not recommended since TextCNN is used for evaluation)
    • Run python3 classifier.py in PTO-{yelp, amazon}/
  • Train the additional classifier (optional and not recommended since they are used only for inference)
    • Set the flag self.train_mode in PTO-{yelp, amazon}/config.py as aux-cls-only
    • Run python3 train.py in PTO-{yelp, amazon}/
  • Pre-train the pointer (obligatory since it is a necessary preparation for the following HRL training)
    • Set the flag self.train_mode in PTO-{yelp, amazon}/config.py as cls-only
    • Run python3 train.py in PTO-{yelp, amazon}/
  • Jointly train the pointer and the operators with hierarchical reinforcement learning (HRL)
    • Move the pre-trained pointer and the additional classifier, along with their embeddings, from PTO-{yelp, amazon}/outputs/saved_models to PTO-{yelp, amazon}/pretrained/ and modify their prefixes from best- to pretrained-
    • Set the flag self.train_mode in PTO-{yelp, amazon}/config.py as pto
    • Run python3 train.py in PTO-{yelp, amazon}/

Citation

Please cite our ACL paper if this repository inspired your work.

@inproceedings{WuRLS19,
  author    = {Chen Wu and
               Xuancheng Ren and
               Fuli Luo and
               Xu Sun},
  title     = {A Hierarchical Reinforced Sequence Operation Method for Unsupervised Text Style Transfer},
  booktitle = {Proceedings of the 57th Conference of the Association for Computational Linguistics, {ACL} 2019, Florence, Italy, July 28- August 2, 2019, Volume 1: Long Papers},
  pages     = {4873--4883},
  year      = {2019},
  url       = {https://www.aclweb.org/anthology/P19-1482/}
}

Contact

  • If you have any questions regarding the code, please create an issue or contact the owner of this repository
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].