Directed Beam Search: Plug-and-Play Lexically Constrained Language Generation

Damian Pascual, Beni Egressy, Florian Bolli, Roger Wattenhofer
12/31/2020
cs.CLcs.AIcs.LG

Official code: dapascual/DirectedBeamSearch (9 stars, Python, last commit 2021-01-30).

Abstract

Large pre-trained language models are capable of generating realistic text. However, controlling these models so that the generated text satisfies lexical constraints, i.e., contains specific words, is a challenging problem.

Show full abstract

Given that state-of-the-art language models are too large to be trained from scratch in a manageable time, it is desirable to control these models without re-training them. Methods capable of doing this are called plug-and-play. Recent plug-and-play methods have been successful in constraining small bidirectional language models as well as forward models in tasks with a restricted search space, e.g., machine translation. However, controlling large transformer-based models to meet lexical constraints without re-training them remains a challenge. In this work, we propose Directed Beam Search (DBS), a plug-and-play method for lexically constrained language generation. Our method can be applied to any language model, is easy to implement and can be used for general language generation. In our experiments we use DBS to control GPT-2. We demonstrate its performance on keyword-to-phrase generation and we obtain comparable results as a state-of-the-art non-plug-and-play model for lexically constrained story generation.

View on arXivView PDF

Code Implementations(1)

91PythonDec 31, 20205 years ago

Similar Papers

Cite this paper

@article{pascual2020directed,
  title  = {Directed Beam Search: Plug-and-Play Lexically Constrained Language Generation},
  author = {Damian Pascual and Beni Egressy and Florian Bolli and Roger Wattenhofer},
  year   = {2020},
  eprint = {2012.15416},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2012.15416}
}

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/2012.15416.svg)](https://codeofpaper.com/paper/2012.15416)

Discussion