• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Implementation of NeurIPS 19 paper: Paraphrase Generation with Latent Bag of Words

**Update**: working on a Pytorch Version!!

  • Thank you for asking! I'll update a pytorch version! Hopefully within this month (Oct 2021)

**Update**: On the Interpretability of Discrete Set Representations: A Bayesian Perspective

  • The discussion about the identifiability and interpretability of the LBOW model in the unsupervised setting.
  • Work in progress

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.

More Repositories

1

chain-of-thought-hub

Benchmarking large language models' complex reasoning ability with chain-of-thought prompting
Jupyter Notebook
2,556
star
2

Deep-Generative-Models-for-Natural-Language-Processing

DGMs for NLP. A roadmap.
392
star
3

GPT-Bargaining

Code for Arxiv 2023: Improving Language Model Negociation with Self-Play and In-Context Learning from AI Feedback
Jupyter Notebook
198
star
4

FlanT5-CoT-Specialization

Implementation of ICML 23 Paper: Specializing Smaller Language Models towards Multi-Step Reasoning.
Jupyter Notebook
122
star
5

Distributional-Generalization-in-Natural-Language-Processing

Distributional Generalization in NLP. A roadmap.
Jupyter Notebook
86
star
6

Gumbel-CRF

Implementation of NeurIPS 20 paper: Latent Template Induction with Gumbel-CRFs
Python
53
star
7

PoincareProbe

Implementation of ICLR 21 paper: Probing BERT in Hyperbolic Spaces
Jupyter Notebook
50
star
8

Partially-Observed-TreeCRFs

Implementation of AAAI 21 paper: Nested Named Entity Recognition with Partially Observed TreeCRFs
Python
49
star
9

franxyao.github.io

35
star
10

Language-Model-Pretraining-for-Text-Generation

LM pretraining for generation, reading list, resources, conference mappings.
19
star
11

pivot_analysis

Implementation of INLG 19 paper: Rethinking Text Attribute Transfer: A Lexical Analysis
Python
15
star
12

RDP

Implementation of ICML 22 Paper: Scaling Structured Inference with Randomization
Jupyter Notebook
13
star
13

Complexity-Based-Prompting

Complexity Based Prompting for Multi-Step Reasoning
10
star
14

prompt-handbook

Rules of Thumb 👍 for Writing Good Magical Prompts
5
star
15

nlu-cw2

Python
4
star
16

Natural-Ansewr-Generation

Python
2
star
17

Retrieval-Head-with-Flash-Attention

Efficient retrieval head analysis with triton flash attention that supports topK probability
Jupyter Notebook
2
star
18

SCAN_reproduce

Python
1
star