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

Sumanth Dathathri, Andrea Madotto, Janice Lan, Jane Hung, Eric Frank +3 more
12/4/2019
cs.CLcs.AIcs.LG

Official code: uber-research/PPLM (1,152 stars, Apache-2.0, last commit 2024-02-20).

Abstract

Large transformer-based language models (LMs) trained on huge text corpora have shown unparalleled generation capabilities. However, controlling attributes of the generated language (e.g. switching topic or sentiment) is difficult without modifying the model architecture or fine-tuning on attribute-specific data and entailing the significant cost of retraining. We propose a simple alternative: the Plug and Play Language Model (PPLM) for controllable language generation, which combines a pretrained LM with one or more simple attribute classifiers that guide text generation without any further training of the LM. In the canonical scenario we present, the attribute models are simple classifiers consisting of a user-specified bag of words or a single learned layer with 100,000 times fewer parameters than the LM. Sampling entails a forward and backward pass in which gradients from the attribute model push the LM's hidden activations and thus guide the generation. Model samples demonstrate control over a range of topics and sentiment styles, and extensive automated and human annotated evaluations show attribute alignment and fluency. PPLMs are flexible in that any combination of differentiable attribute models may be used to steer text generation, which will allow for diverse and creative applications beyond the examples given in this paper.

View on arXivView PDF

Code Implementations(1)

uber-research/PPLMOfficial100%
Apache-2.0

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

1,152203Shell, PythonNov 5, 20192 years agoApache-2.0
deep-learninglanguage-modelingmachine-learningnatural-language-generationnatural-language-processing+1 more

Similar Papers

Cite this paper

@article{dathathri2019plug,
  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},
  year   = {2019},
  eprint = {1912.02164},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1912.02164}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1912.02164.svg)](https://codeofpaper.com/paper/1912.02164)

Discussion