Introduction
Modern Large Language Models (LLMs) are predominantly Causal Language Models (CLMs), trained to predict the next token in a strict left-to-right sequence. While highly effective for open-ended generation, this unidirectional constraint limits their utility in scenarios requiring bidirectional context, such as text editing, code completion, or template filling. Existing workarounds, like "Causal Masking" (CM), often struggle with logical consistency because they do not inherently "see" the future context during generation.
FiLM (Fill-in Language Model) addresses these limitations by introducing a decoder-only architecture capable of flexible, any-order text generation. By leveraging bidirectional context throughout the generation process, FiLM aims to provide the fluency of standard LLMs with the flexibility of masked models.
The FiLM Architecture and Methods
FiLM extends the Masked Language Modeling (MLM) objective typically associated with models like BERT but adapts it for a generative framework. Unlike standard MLM, which is used for representation learning, FiLM is designed for sequential decoding.
Adaptive Masking via Beta Distribution
A core innovation of FiLM is its "noise schedule" for training. While BERT uses a fixed 15% mask rate, FiLM samples the mask probability $p$ from a Beta distribution. This allows the model to encounter a wide variety of masking scenarios during training—ranging from single-token gaps to almost entirely masked sequences. This diversity is crucial for the model to learn how to generate coherent text from minimal initial context.
Sequential Decoding
At inference time, FiLM avoids the incoherence common in non-autoregressive models by filling masks one at a time. The model conditions each new token on the original context and its own previous predictions. This iterative process allows for various decoding orders:
- Left-to-Right (L2R): The standard sequential order.
- Min-Entropy: An "easy-first" strategy where the model fills the most certain positions first.
- Random/Max-Entropy: Orders used to evaluate the model's robustness to different generation paths.
Key Insights: The Importance of Distribution
The researchers found that the specific distribution of mask probabilities during training significantly impacts performance. A fixed mask ratio is insufficient for generative tasks.
As shown in the experimental results, the mode of the mask probability $p$ influences the model's perplexity. The use of a Beta distribution ensures the model is exposed to the full spectrum of "noise levels," which is essential for learning the underlying structure of language across different scales of missing information.
Evaluation and Results
FiLM was evaluated on three major benchmarks: WikiText-103, One Billion Word (1BW), and ROCStories.
Performance and Scalability
On WikiText-103, a FiLM model fine-tuned from GPT2-xl achieved a perplexity of 14.03. While this remains slightly behind standard CLMs (11.29), the performance gap narrows as the model scales. At 1.6B parameters, FiLM demonstrated superior text infilling capabilities, outperforming state-of-the-art Causal Masking baselines by over 10 ROUGE points.
Human and GPT-4 Evaluation
In human preference studies using the ROCStories dataset, judges preferred FiLM’s completions in 48% of cases, compared to just 21% for a Causal Masking model four times its size. Evaluations using GPT-4 confirmed these findings, highlighting FiLM's superior logical consistency and its ability to avoid the "hallucinations" or contradictions often seen in unidirectional models when forced to fill gaps.
Limitations and Future Directions
The primary trade-off for FiLM's bidirectional flexibility is inference speed. Because it requires a full forward pass for each filled token, it is slower than non-autoregressive alternatives. Future research may explore "semi-parallel" decoding to mitigate this. Furthermore, while FiLM shows great promise when fine-tuned, training a massive-scale FiLM model from scratch remains an open challenge for the field.
Summary updated