Coder Social home page Coder Social logo

wyu-du / adversarial_decomposition Goto Github PK

View Code? Open in Web Editor NEW

This project forked from text-machine-lab/adversarial_decomposition

0.0 2.0 0.0 9.16 MB

The code for the paper "Adversarial Decomposition of Text Representation", NAACL 2019

Home Page: https://arxiv.org/abs/1808.09042

Python 0.34% Jupyter Notebook 0.09% Roff 99.57%

adversarial_decomposition's Introduction

Adversarial Decomposition of Text Representation

The code for the paper "Adversarial Decomposition of Text Representation", NAACL 2019 https://arxiv.org/abs/1808.09042

Installation

  1. Clone this repo: https://github.com/text-machine-lab/adversarial_decomposition.git
  2. Install NumPy: pip install numpy==1.16.3
  3. Install PyTorch v1.1.0: pip install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-linux_x86_64.whl (for python3.6, use pip install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp36-cp36m-linux_x86_64.whl)
  4. Install dependencies: pip install -r requirements.txt
  5. Download spacy models: python -m spacy download en_core_web_lg

Initial setup

  1. Create dir mkdir -p data/experiments
  2. Create dir mkdir -p data/datasets
  3. Create dir mkdir -p data/word_embeddings
  4. Download the Shakespeare data: git clone https://github.com/cocoxu/Shakespeare.git data/datasets/shakespeare
  5. Download the Yelp data: git clone https://github.com/shentianxiao/language-style-transfer.git data/datasets/yelp
  6. Download the pickled GloVe embeddings wget https://mednli.blob.core.windows.net/shared/word_embeddings/glove.840B.300d.pickled -O data/word_embeddings/glove.840B.300d.pickled
  7. Download the pickled fastText embeddings wget https://mednli.blob.core.windows.net/shared/word_embeddings/crawl-300d-2M.pickled -O data/word_embeddings/crawl-300d-2M.pickled

Running the code

Global constants are set in the file settings.py. In general, you don't need to change this file. Experiment parameters are set in the config.py file.

First, run the preprocessing script: python preprocess.py This scipt will print the ID of the preprocessing experiment, for example preprocess.buppgpnf. Copy this ID and change parameter preprocess_exp_id of the TrainConfig class on the line 12 in the file config.py file accordingly.

After you set the preprocess experiment id, run the training: python train.py. This scirpt will also print the ID of the training experiment. You can paste it in the eval_generation.ipynb notebook to play with the model.

Chaning the form and meaning

The provided eval_generation.ipynb notebook shows how to use the model to swap the meaning and form vectors of the input sentences!

Citation

If you find this code helpful, please consider citing our paper:

A. Romanov, A. Rumshisky, A. Rogers, D. Donahue,Adversarial decomposition of text represen-tation, In Proceedings of NAACL 2019: Conference of the North American Chapter of the Association for Computational Linguistics, 2019

https://arxiv.org/abs/1808.09042

@inproceedings{romanov2019adversarial,
  title={Adversarial Decomposition of Text Representation},
  author={Romanov, Alexey and Rumshisky, Anna and Rogers, Anna and Donahue, David},
  booktitle={Proceedings of NAACL 2019: Conference of the North American Chapter of the Association for Computational Linguistics},
  year={2019}
}

adversarial_decomposition's People

Contributors

jgc128 avatar nrshka avatar wyu-du avatar

Watchers

 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.