TL;DR
Causal language models excel at left-to-right generation but struggle to evaluate or sample text conditioned on future context (e.g., text infilling). This paper introduces Arbitrary Conditionals GPT (AC-GPT), a simple modification that prepends position-aware copies of conditioning tokens to a standard causal Transformer. This enables single-pass evaluation of arbitrary conditionals and allows existing large language models (LLMs) to be easily fine-tuned for tasks like text editing without degrading their standard generation performance.
What Problem Does This Paper Address?
Standard autoregressive LLMs predict the next token based strictly on past tokens ($p(x_t | x_{<t})$). However, many real-world tasks require "arbitrary conditioning"—predicting missing text given both past and future context ($p(x_{\text{middle}} | x_{\text{past}}, x_{\text{future}})$), such as text infilling, editing, or rewriting.
Existing approaches like Masked Language Models (MLMs like BERT), any-order autoregressive models ($\sigma$-GPT, XLNet), or discrete diffusion models suffer from significant drawbacks. They either require complex architectural overhauls, suffer from slow multi-pass generation, or waste model capacity trying to learn every possible generation permutation. Crucially, because they alter the core architecture, they cannot easily leverage the massive power of existing pre-trained LLMs.
Methods
The authors propose Arbitrary Conditionals GPT (AC-GPT). Instead of changing the Transformer architecture or the left-to-right factorization order, AC-GPT modifies how the input sequence is presented to a standard causal Transformer.
For a given sequence, tokens are split into a conditioning set ($x_c$) and an evaluation set ($x_e$). AC-GPT handles this via the following mechanisms:
- Token Copying: It creates copies of the conditioning tokens ($\bar{x}_c$) and places them at the very beginning of the sequence.
- Attention Masking: Tokens within the prepended conditioning set can attend to each other bidirectionally. The evaluation tokens follow a standard causal mask, meaning they can attend to the prepended conditioning tokens and any past evaluation tokens, but not future ones.
- Position Encodings: Crucially, the prepended copies retain their original positional encodings (e.g., RoPE) from their true locations in the sequence.
- Information Leakage Prevention: Pre-pending copies rather than just allowing bidirectional attention to the original tokens prevents indirect information leakage across multiple Transformer layers, preserving the strict left-to-right chain rule.
- Loss Function: The model is trained using standard teacher forcing, but the loss is only calculated on the evaluation tokens ($x_e$).
Datasets
The models were trained and evaluated on two natural language corpora:
- Wikitext-103: A standard natural language benchmark based on high-quality Wikipedia articles.
- FineWeb (sample-10BT configuration): A massive, 10-billion-token sample of web text used to verify that the findings scale to web-scale data.
Key Insights and Ideas
- Decoupling Conditioning from Generation Order: Language has an inherent left-to-right temporal structure. Forcing a model to learn how to generate text in random, scrambled orders (as any-order models do) severely wastes model capacity. AC-GPT proves you can condition on arbitrary tokens while keeping the generation order strictly left-to-right.
- Zero Architectural Surgery: Because AC-GPT only changes the input sequence formatting and attention mask, it is fully compatible with standard causal Transformer architectures. This means it can be applied directly to state-of-the-art pre-trained LLMs via parameter-efficient fine-tuning (like LoRA).
- The Importance of Copying: Simply letting tokens look ahead to future conditioning tokens in the original sequence causes multi-layer information leakage. Pre-pending static copies cleanly bypasses this issue.
Key Results
- From-Scr Scratch Training: When trained from scratch (GPT-2 Small, 82M parameters), AC-GPT significantly outperformed any-order models ($\sigma$-GPT-random) and Masked Language Models (BERT) on conditional perplexity, while matching vanilla GPT performance on standard unconditional generation.
- Scaling via Fine-Tuning: The authors successfully fine-tuned large pre-trained models, including Qwen3 (8B, 14B, 32B) and LLaMA-3.1-8B using LoRA.
- Quantifiable Gains: For Qwen3-14B, AC-GPT achieved a 15.4% perplexity advantage over the standard causal baseline on the training distribution of conditionals by successfully leveraging future context.
- Consistency at Scale: The performance gains remained consistent across an order-of-magnitude scale (from 8B to 32B parameters), proving that strong left-to-right priors in large models do not erase the benefits of future-context conditioning.
Limitations and Future Work
- Training Efficiency: AC-GPT only computes and backpropagates loss on the designated evaluation tokens ($x_e$). This makes it less compute-efficient during from-scratch pre-training compared to any-order models that compute loss on all tokens simultaneously.
- Marginalization: The current implementation assumes every token is either known (conditioning) or being evaluated. It does not natively handle marginalizing over completely unknown/ignored tokens, though the authors suggest this could be resolved by introducing a
[MASK]token. - Evaluation Scope: The method was only evaluated on two datasets (Wikitext-103 and FineWeb) and focused primarily on perplexity and distribution metrics (MAUVE) rather than specific downstream text-editing applications.
Summary updated