Giter Club home page Giter Club logo

dgm_latent_bow's Introduction

The Latent Bag of Words Model

Implementation of Yao Fu, Yansong Feng and John Cunningham, Paraphrase Generation with Latent Bag of Words. NeurIPS 2019. paper

example

As is shown in the above example, given a source sentence, our model first infers the neighbor words of each source words, then sample a bag of words from the neighbors, then generate the paraphrase based on the sampled words

For more background about deep generative models for natural language processing, see the DGM4NLP journal list.

Reproduce

mkdir models
mkdir outputs
cd src
python3 main.py 

# quicker start
python3 main.py --batch_size=5 --train_print_interval=10

# Monitor training:
loss: 9.1796  -- total loss
enc_loss: 3.1693  -- BOW NLL loss
dec_loss: 6.0103  -- Decoder loss 
precision_confident: 0.4794  -- BOW precision on confident = most confident word neighbors 
recall_confident: 0.1727  -- BOW recall on confident = most confident word neighbors
precision_topk: 0.1186  -- BOW percision on topk = tok predicted word neighbors
recall_topk: 0.2387  -- BOW recall on topk = tok predicted word neighbors

May need to install nltk stopwords first, just follow the prompt

Data

We use the MSCOCO(17) dataset and the Quora dataset. The Quora dataset is provided in the data/ folder. The MSCOCO dataset can be downloaded from its offical website

Code Structure

The core implementation is in the following files:

  • config.py
  • main.py
  • controller.py
  • latent_bow.py

Others

There are certain codes about testing the Wikibio dataset. These part of the code is not included in the paper, its just for tesing the data-to-text task. So the published part might be incomplete. If you do want to extend the model to data-to-text, feel free to contact me.

The rouge evaluation is from here: https://pypi.org/project/py-rouge/. There is also a google implementation recently: https://github.com/google-research/google-research/tree/master/rouge.

The main_test.py is not for testing the model, it is for debugging in the ipython terminal.

Embarrassingly, I cannot replicate the results in Pytorch ... I moved to Pytorch after this project and there are still many things to understand (as a many-year tfer). It seems that the pytorch LSTM does not support residual connections, which results in degraded performance when I changed the number of layers to be 2. If you happen to find a solution, or find something close, do contact me.

dgm_latent_bow's People

Contributors

franxyao avatar

Watchers

James Cloos 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.