[Paper Review] Enabling Language Models to Fill in the Blanks
This paper introduces Infilling by Language Modeling (ILM), a simple, model-agnostic framework that enables pre-trained language models to effectively predict variable-length text spans at any position in a document by training on masked text concatenated with its ground-truth completions. The method achieves human-undetectable text infilling in short stories, outperforming BERT, specialized models, and standard language models in human evaluation.
We present a simple approach for text infilling, the task of predicting missing spans of text at any position in a document. While infilling could enable rich functionality especially for writing assistance tools, more attention has been devoted to language modeling---a special case of infilling where text is predicted at the end of a document. In this paper, we aim to extend the capabilities of language models (LMs) to the more general task of infilling. To this end, we train (or fine-tune) off-the-shelf LMs on sequences containing the concatenation of artificially-masked text and the text which was masked. We show that this approach, which we call infilling by language modeling, can enable LMs to infill entire sentences effectively on three different domains: short stories, scientific abstracts, and lyrics. Furthermore, we show that humans have difficulty identifying sentences infilled by our approach as machine-generated in the domain of short stories.
Motivation & Objective
- To enable pre-trained language models to infill variable-length text spans at any position in a document, not just at the end.
- To address the limitations of existing models that can only infill fixed-length spans or require specialized architectures.
- To develop a general, flexible, and simple framework that preserves the benefits of standard language models—such as high-quality generation and efficient sampling—while enabling bidirectional context use.
- To demonstrate that off-the-shelf language models fine-tuned via this method can produce infills indistinguishable from human-written text in real-world writing tasks.
- To enable practical applications in writing assistance, document restoration, and idea connection by supporting multi-span, variable-length infilling.
Proposed method
- Reformulate the infilling task as predicting only the missing spans (y), rather than the entire sequence, by replacing blanks with [blank] tokens.
- Construct training examples by concatenating the incomplete input (with [blank] tokens) and the ground-truth completions (y), separated by [answer] tokens.
- Fine-tune a standard unidirectional language model on these concatenated sequences to learn p(y | x̃), where x̃ is the incomplete input.
- During inference, generate text for each [blank] using the fine-tuned LM, then deterministically replace the [blank] tokens with the predicted spans to produce the completed text.
- Use a single forward pass per example, avoiding iterative reprocessing of the input sequence, enabling efficient multi-span infilling.
- Leverage large-scale pre-trained language models as initialization to improve performance, especially in low-data regimes.
Experimental results
Research questions
- RQ1Can standard language models be effectively fine-tuned to infill variable-length spans at arbitrary positions in a document using a simple, generalizable method?
- RQ2Does the proposed ILM framework enable language models to generate infills that are more coherent and contextually consistent than existing approaches?
- RQ3Can ILM-generated infills be indistinguishable from human-written text in human evaluation, particularly in narrative contexts?
- RQ4How does the performance of ILM compare to models like BERT and specialized architectures (e.g., SA) in terms of human detectability and fluency?
- RQ5Does initializing from a large-scale pre-trained language model improve infilling performance in the ILM framework?
Key findings
- The ILM model achieved a human evaluation score of 45%, meaning human annotators failed to identify the machine-generated sentence in 45% of stories—significantly higher than BERT (20%), SA (29%), and standard language models (41%).
- Despite using only left-to-right context, the standard language model outperformed BERT and the specialized SA model in human evaluation, suggesting that context length and architecture are not the only determinants of quality.
- The ILM framework enables effective infilling across diverse domains, including short stories, scientific abstracts, and song lyrics, demonstrating broad applicability.
- Fine-tuning from a large-scale pre-trained language model significantly improves infilling performance, indicating that the ILM framework effectively leverages pre-existing knowledge.
- Qualitative analysis shows that ILM-generated sentences are contextually coherent and account for both preceding and subsequent text, unlike BERT and SA outputs, which are often off-topic or irrelevant.
- The method is model-agnostic and does not require architectural modifications, allowing it to be applied to any pre-trained language model with minimal changes.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.