TL;DR
The Fill-in Language Model (FiLM) is a bidirectional, any-order language modeling framework that fills in missing text at arbitrary locations by looking at both left and right context. By pairing a diffusion-inspired Beta-distributed masking schedule with sequential decoding, FiLM significantly outperforms standard causal language models trained on rearranged text segments, while narrowing the perplexity gap with causal models as model size scales.
What Problem Does This Paper Address?
Standard Causal Language Models (CLMs) like GPT predict tokens strictly left-to-right. While effective for open-ended continuation, this unidirectional inductive bias is poorly suited for infilling tasks—such as text editing, document revision, and code completion—where context is available on both sides of a gap.
Previous approaches to "fill-in-the-middle" rely on Causal Masking (CM), which cuts missing spans, pastes them at the end of the prompt with sentinel tokens, and forces a CLM to generate them sequentially. However, these rearranged sequences often produce disjointed transitions, repetitions, and logical inconsistencies. Conversely, traditional Masked Language Models (MLMs) like BERT leverage bidirectional context but are crippled in autoregressive generation due to their fixed masking ratios (e.g., 15%). FiLM bridges this divide by turning bidirectional MLMs into flexible, any-order text generators.
Methods
FiLM is a decoder-only model without causal attention masking, designed to operate either from scratch (a sequence of masks) or by filling blanks in partially completed text.
- Beta Noise Schedule: Instead of a static masking rate, FiLM samples the sequence mask probability $p \sim \text{Beta}(\alpha, \beta)$ during training. Setting $\alpha = \beta = 2.5$ (mode = 0.5) ensures the model trains across diverse noise levels without over-indexing on trivial (too few masks) or uninformative (almost all masks) states.
- Flexible Initialization: FiLM can be trained from scratch or fine-tuned from existing checkpoints (MLMs like RoBERTa or CLMs like GPT-2 by disabling causal masks).
- Sequential Decoding Strategies: To handle strong token interdependencies without quality degradation, FiLM fills one
[MASK]token per step conditioned on all past predictions and existing context. The authors explore several orders: - Left-to-Right (L2R)
- Right-to-Left (R2L)
- Min-Entropy ("Easy-First"): greedily fills the position the model is most confident in.
- Max-Entropy ("Hard-First") and Random
- Any-Order Perplexity Formulation: The authors compute evaluation perplexity by incorporating sequence length frequency $p_{\text{len}}(n)$ alongside sequential conditional log-likelihoods over decoding permutations, enabling direct apples-to-apples comparisons with CLMs.
Training: [MASK] token drawn with p ~ Beta(2.5, 2.5) -> Predict masked tokens with bidirectional attention
Decoding: Iteratively replace one [MASK] per step using L2R or Min-Entropy order
Datasets
The authors evaluate on three established benchmarks (no new datasets were introduced):
- WikiText-103 (WT-103): Document-level Wikipedia articles chunked into 512-token segments for multi-sentence infilling.
- One Billion Word (1BW): Sentence-level corpus used for short, phrase-level infilling evaluations.
- ROCStories: A corpus of 5-sentence commonsense stories used to evaluate sentence-level completion and logical flow.
Key Insights and Ideas
- The Mode Matters in Variable Masking: Uniform masking $U[0, 1]$ works, but sampling from a $\text{Beta}(2.5, 2.5)$ distribution improves validation perplexity by ~0.4 points. A fixed 15% mask schedule (BERT-style) fails dramatically for generation, yielding over 7–8 points worse perplexity.
- Inherent Sequentiality of Language: Despite training on random token subsets, left-to-right decoding consistently yields the lowest perplexity.
- Easy-First Emergence: The min-entropy ("easy-first") heuristic naturally generates cohesive chunks (e.g., predicting "thank you" and "for your service" before tackling ambiguous proper nouns).
- Architecture Memory: When fine-tuned from RoBERTa, FiLM easily adapts to R2L decoding (even rivaling L2R on 1BW). In contrast, GPT-2-initialized models exhibit severe resistance to right-to-left decoding, performing worse than random order.
- The Scaling Convergence: While CLMs maintain a perplexity edge in unconditional generation, the gap between FiLM and CLM narrows from 5.85 to 2.74 on WikiText-103 as model size scales from 124M to 1.6B parameters.
Key Results
- Multi-Span Infilling (vs. GPT2-xl Causal Masking baseline, 1.6B params):
- WikiText-103: FiLM achieves 35.34 ROUGE-1 / 13.29 ROUGE-2 / 27.26 ROUGE-L vs. CM’s 21.73 / 7.14 / 16.66 (+10.12 average ROUGE improvement). GPT-4 prefers FiLM over CM by an 8.4% margin.
- One Billion Word: FiLM achieves 42.55 / 13.35 / 42.25 vs. CM's 33.69 / 8.88 / 33.54.
- Commonsense Story Completion (ROCStories):
- A 0.4B RoBERTa-large FiLM beats a 4× larger 1.6B GPT2-xl CM baseline across ROUGE metrics (38.19 vs. 33.15 ROUGE-1).
- In blind human evaluations, FiLM is preferred 48% of the time, compared to just 21% for CM (31% ties).
Limitations and Future Work
- Inference Latency: FiLM relies on autoregressive, single-mask-at-a-time decoding, requiring $O(N)$ forward passes over the full bidirectional transformer. The authors highlight accelerating generation via parallel multi-token decoding or speculative sampling as critical future work.
- Pretraining Gap: When generating unconditional text from scratch, FiLM still slightly underperforms pure CLMs of matching parameter counts, though scaling trends suggest this gap shrinks in larger parameter regimes.
Summary updated