TL;DR
Blank Language Models (BLM) introduce a flexible framework for text generation by dynamically creating and filling blanks within a sequence. Unlike standard left-to-right models, BLM allows for fine-grained control over where text is inserted and naturally handles variable-length infilling, making it a powerful tool for text editing, style transfer, and ancient document restoration.
What Problem Does This Paper Address?
Most neural language models are designed to generate text autoregressively from left to right. While this works well for generating text from scratch, it is ill-suited for "text infilling"—the task of completing a sentence where parts are missing or need rewriting.
Existing approaches to infilling often suffer from significant drawbacks: they might require knowing the exact number of missing tokens in advance (like BERT-based models), rely on complex and slow inference algorithms to adapt left-to-right models, or fail to guarantee that the generated content actually fits the specified gaps. The authors seek a model that can start from any partial text, respect both preceding and following context, and handle an unknown number of missing tokens at specific locations.
Methods
The core innovation is the Blank Language Model (BLM), which treats generation as an iterative process of expanding a "canvas."
- The Canvas: The model operates on a sequence of words interspersed with special blank symbols (
_). - The Action: In each step, the model performs a three-part action:
- Choose a blank: Select one of the existing blank locations for expansion.
- Predict a word: Determine which word from the vocabulary should fill that spot.
- Create new blanks: Decide whether to insert new blanks to the immediate left and/or right of the newly placed word.
- Architecture: The model uses a Transformer encoder to map the canvas into vector representations. A specialized head then factorizes the joint distribution of the action (location, word, and new blanks) as shown in the architecture diagram below.
Training: Because a single sentence can be generated through many different sequences of actions (trajectories), the authors train the model by maximizing a lower bound of the marginal data likelihood. This encourages the model to be robust, learning to complete a sentence effectively regardless of the order in which words are filled in.
Datasets
The authors evaluated BLM across several diverse tasks:
- Yahoo Answers: Used for general text infilling benchmarks.
- PHI-ML: A dataset of ancient Greek inscriptions used to test character-level restoration of damaged historical texts.
- Yelp & Amazon Reviews: Used for sentiment transfer, where the model must rewrite a sentence to change its emotional tone while keeping the topic intact.
- Penn Treebank (PTB) & WikiText (WT2/WT103): Standard benchmarks for evaluating general language modeling perplexity.
Key Insights and Ideas
- Dynamic Expansion: By allowing a blank to produce a word and new blanks, the model can expand a single gap into a phrase of arbitrary length. This is a "grammar-like" approach to generation that is much more flexible than fixed-length masking.
- Trajectory Independence: Training on all possible generation orders makes the model "order-agnostic." It doesn't care if it fills the middle of a sentence first or the end; it learns to use the available context globally.
- Joint Modeling: Unlike Masked Language Models (like BERT) that often predict missing tokens independently, BLM models the sequence jointly. This leads to significantly higher fluency and coherence, especially when large chunks of text are missing.
Key Results
BLM demonstrated superior performance across all tested applications:
- Text Infilling: On the Yahoo Answers dataset, BLM achieved the highest BLEU scores across all mask ratios (10% to 50%), outperforming the Insertion Transformer and Seq2seq baselines.
- Ancient Text Restoration: In complex "multi-slot" scenarios where multiple parts of a Greek inscription were missing, BLM reduced the character error rate (CER) by up to 4.4 points compared to previous state-of-the-art methods.
- Sentiment Transfer: BLM achieved a transfer accuracy of 92.5% on the Amazon dataset. As seen in the examples below, it can dynamically adapt the length of its completions to fit the required sentiment.
Limitations and Future Work
While BLM excels at infilling, the authors note a performance gap in pure language modeling (generating from a single blank) compared to massive, specialized left-to-right models like Transformer-XL. Language modeling remains challenging for "free-order" models.
Additionally, the model can occasionally struggle with logical consistency if specific "trigger" words (like "either," which implies a future "or") are left unmasked while their counterparts are removed. Future work could involve extending BLM to conditional generative models for machine translation editing or dialogue systems.
Summary updated