All Projects → uber-research → Pplm

uber-research / Pplm

Licence: apache-2.0
Plug and Play Language Model implementation. Allows to steer topic and attributes of GPT-2 models.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pplm

This Word Does Not Exist
This Word Does Not Exist
Stars: ✭ 640 (-5.04%)
Mutual labels:  natural-language-processing, natural-language-generation
Nonautoreggenprogress
Tracking the progress in non-autoregressive generation (translation, transcription, etc.)
Stars: ✭ 118 (-82.49%)
Mutual labels:  natural-language-processing, natural-language-generation
Gpt2
PyTorch Implementation of OpenAI GPT-2
Stars: ✭ 64 (-90.5%)
Mutual labels:  natural-language-processing, natural-language-generation
Convai Baseline
ConvAI baseline solution
Stars: ✭ 49 (-92.73%)
Mutual labels:  natural-language-processing, natural-language-generation
Nlp Conference Compendium
Compendium of the resources available from top NLP conferences.
Stars: ✭ 349 (-48.22%)
Mutual labels:  natural-language-processing, natural-language-generation
Nlg Rl
Accelerated Reinforcement Learning for Sentence Generation by Vocabulary Prediction
Stars: ✭ 59 (-91.25%)
Mutual labels:  natural-language-processing, natural-language-generation
Transformers
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
Stars: ✭ 55,742 (+8170.33%)
Mutual labels:  natural-language-processing, natural-language-generation
Textaugmentation Gpt2
Fine-tuned pre-trained GPT2 for custom topic specific text generation. Such system can be used for Text Augmentation.
Stars: ✭ 104 (-84.57%)
Mutual labels:  natural-language-processing, natural-language-generation
Nndial
NNDial is an open source toolkit for building end-to-end trainable task-oriented dialogue models. It is released by Tsung-Hsien (Shawn) Wen from Cambridge Dialogue Systems Group under Apache License 2.0.
Stars: ✭ 332 (-50.74%)
Mutual labels:  natural-language-processing, natural-language-generation
Gluon Nlp
NLP made easy
Stars: ✭ 2,344 (+247.77%)
Mutual labels:  natural-language-processing, natural-language-generation
Ludwig
Data-centric declarative deep learning framework
Stars: ✭ 8,018 (+1089.61%)
Mutual labels:  natural-language-processing, natural-language-generation
Practical Pytorch
Go to https://github.com/pytorch/tutorials - this repo is deprecated and no longer maintained
Stars: ✭ 4,329 (+542.28%)
Mutual labels:  natural-language-processing, natural-language-generation
Pqg Pytorch
Paraphrase Generation model using pair-wise discriminator loss
Stars: ✭ 33 (-95.1%)
Mutual labels:  natural-language-processing, natural-language-generation
Languagetoys
Random fun with statistical language models.
Stars: ✭ 63 (-90.65%)
Mutual labels:  natural-language-processing, natural-language-generation
Nlg Eval
Evaluation code for various unsupervised automated metrics for Natural Language Generation.
Stars: ✭ 822 (+21.96%)
Mutual labels:  natural-language-processing, natural-language-generation
Natural Language Processing Specialization
This repo contains my coursework, assignments, and Slides for Natural Language Processing Specialization by deeplearning.ai on Coursera
Stars: ✭ 151 (-77.6%)
Mutual labels:  natural-language-processing, natural-language-generation
Question generation
Neural question generation using transformers
Stars: ✭ 356 (-47.18%)
Mutual labels:  natural-language-processing, natural-language-generation
Rnnlg
RNNLG is an open source benchmark toolkit for Natural Language Generation (NLG) in spoken dialogue system application domains. It is released by Tsung-Hsien (Shawn) Wen from Cambridge Dialogue Systems Group under Apache License 2.0.
Stars: ✭ 487 (-27.74%)
Mutual labels:  natural-language-processing, natural-language-generation
Stanza
Official Stanford NLP Python Library for Many Human Languages
Stars: ✭ 5,887 (+773.44%)
Mutual labels:  natural-language-processing
Nlp Recipes
Natural Language Processing Best Practices & Examples
Stars: ✭ 5,783 (+758.01%)
Mutual labels:  natural-language-processing

PPLM

This repository contains code to run the Plug and Play Language Model (PPLM), as described in this blog post and arXiv paper. A demo and Colab notebook are also available.

Note: If you are planning on using PPLM as a baseline, and would like to use the parameters listed in the paper's Appendix, please use the LM and the discriminator from this folder. Alternatively, tune the hyperparamters on your own if you are using the code/models in the main directory and/or the 🤗/Transformers for a fair comparison (the optimal parameters for these models/discriminators are roughly off by a factor of 5 from those used in the paper).

PPLM is also integrated into the 🤗/Transformers repository.

header image

Plug and Play Language Models: a Simple Approach to Controlled Text Generation

Authors: Sumanth Dathathri, Andrea Madotto, Janice Lan, Jane Hung, Eric Frank, Piero Molino, Jason Yosinski, and Rosanne Liu

PPLM allows a user to flexibly plug in one or more tiny attribute models representing the desired steering objective into a large, unconditional language model (LM). The method has the key property that it uses the LM as is—no training or fine-tuning is required—which enables researchers to leverage best-in-class LMs even if they do not have the extensive hardware required to train them.

See also our arXiv paper, blog post, and try it out for yourself with no setup using the Colab notebook.

Setup

pip install -r requirements.txt

Citation

@inproceedings{
Dathathri2020Plug,
title={Plug and Play Language Models: A Simple Approach to Controlled Text Generation},
author={Sumanth Dathathri and Andrea Madotto and Janice Lan and Jane Hung and Eric Frank and Piero Molino and Jason Yosinski and Rosanne Liu},
booktitle={International Conference on Learning Representations},
year={2020},
url={https://openreview.net/forum?id=H1edEyBKDS}
}

PPLM-BoW

Example command for bag-of-words control

python run_pplm.py -B military --cond_text "The potato" --length 50 --gamma 1.5 --num_iterations 3 --num_samples 10 --stepsize 0.03 --window_length 5 --kl_scale 0.01 --gm_scale 0.99 --colorama --sample

Tuning hyperparameters for bag-of-words control

  1. Increase --stepsize to intensify topic control, and decrease its value to soften the control. --stepsize 0 recovers the original uncontrolled GPT-2 model.

  2. If the language being generated is repetitive (For e.g. "science science experiment experiment"), there are several options to consider: a) Reduce the --stepsize b) Increase --kl_scale (the KL-loss coefficient) or decrease --gm_scale (the gm-scaling term) c) Add --grad-length xx where xx is an (integer <= length, e.g. --grad-length 30).

PPLM-Discrim

Example command for discriminator based sentiment control

python run_pplm.py -D sentiment --class_label 2 --cond_text "My dog died" --length 50 --gamma 1.0 --num_iterations 10 --num_samples 10 --stepsize 0.04 --kl_scale 0.01 --gm_scale 0.95 --sample

Tuning hyperparameters for discriminator control

  1. Increase --stepsize to intensify topic control, and decrease its value to soften the control. --stepsize 0 recovers the original uncontrolled GPT-2 model.

  2. Use --class_label 3 for negative, and --class_label 2 for positive

The discriminator and the GPT-2 model in the root directory are different from those used for the analysis in the paper. Code and models corresponding to the paper can be found here.

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].