TL;DR
Standard next-token prediction severely limits a transformer's ability to plan ahead. By switching to MLM-$\mathcal{U}$—a masked language modeling objective with a uniform masking rate—transformers learn to predict multiple steps both forward and backward, enabling them to solve complex mazes perfectly. This simple change in the learning objective allows an 8M parameter model to outperform a 175M parameter autoregressive model boosted with algorithmic search traces.
What Problem Does This Paper Address?
Autoregressive transformers trained on next-token prediction are the undisputed champions of modern language modeling. However, they notoriously struggle with long-term planning and foresight. In tasks like maze navigation, a model cannot just react to the immediate next step; it must plan multiple steps ahead and successfully navigate dead ends.
Because standard next-token training offers no explicit mechanism to look ahead or revisit past paths, models often fall prey to short-sighted shortcuts (like the "Clever-Hans cheat") that fail completely as path complexity scales. The authors of this paper ask a fundamental question: Can we fix this planning deficit simply by changing the learning objective to explicitly force multi-step forward and backward prediction?
Methods
To isolate the impact of the learning objective, the authors trained parameter-matched transformers from scratch under identical settings, contrasting standard next-token prediction with MLM-$\mathcal{U}$ (Masked Language Modeling with a Uniform masking rate).
Unlike traditional BERT-style masking which uses a fixed corruption rate (e.g., 15%), MLM-$\mathcal{U}$ samples a masking ratio uniformly from $[0, 1]$ for each batch. This means the model is trained to predict arbitrary subsets of the path given highly variable context lengths, effectively forcing it to learn multi-step planning in both directions. Crucially, during inference, both models generate paths token-by-token from left to right, ensuring the comparison remains perfectly fair.
Datasets
The models were evaluated across two distinct maze generation paradigms to ensure the findings weren't artifacts of a specific dataset style:
- DFS Mazes: Generated via randomized Depth First Search. These mazes feature long, winding paths with zero ambiguity—the shortest path is the only path that doesn't backtrack. They are serialized as a sequence of graph edge tuples.
- A* Mazes: A deterministic dataset where walls randomly occupy 30–50% of the grid. These mazes often contain multiple valid shortest paths and are tokenized using explicit X and Y coordinates.
Key Insights and Ideas
- Objectives Over Scale: The core learning objective is a much more powerful lever for long-horizon planning than simply scaling up model parameters or adding heavy algorithmic supervision.
- Mitigating Distributional Shift: Because the uniform masking rate in MLM-$\mathcal{U}$ exposes the model to all possible sequence and context lengths during training, it naturally eliminates the distributional shift typically seen during generative inference.
- Spatial Planning Demands High Precision: A fascinating "aha!" moment occurred when scaling to larger mazes. When using 16-bit floating-point precision, the model would skip or duplicate steps. Switching to full 32-bit precision for the Rotational Positional Encodings (RoPE) was absolutely critical to unlocking perfect navigation on larger grids, proving that precise spatial mapping requires high numerical fidelity.
Key Results
- Flawless Navigation: On 20x20 DFS mazes, an 8M parameter transformer trained with MLM-$\mathcal{U}$ achieved a perfect 100% navigation accuracy, whereas the standard next-token model maxed out at just 20.6%.
- David Beats Goliath: On complex 30x30 mazes, the 8M MLM-$\mathcal{U}$ model achieved 85.5% accuracy, soundly defeating a 175M parameter next-token model (70.2%) that had been explicitly supervised with expert $A^*$ search traces.
- Vastly Superior Efficiency: MLM-$\mathcal{U}$ proved to be 4x more sample efficient in terms of training data and converged 2x faster in actual GPU training hours.
Limitations and Future Work
Despite its success, the approach shares standard transformer limitations, such as a fixed context length that restricts how massive a maze can grow before performance degrades. Additionally, MLM-$\mathcal{U}$ is a inherently harder training objective; because the context is randomly masked every time a maze is seen, the model rarely encounters the exact same conditional sequence twice.
For future work, the authors suggest exploring non-sequential inference heuristics—such as generating tokens based on model certainty rather than a strict left-to-right order—and experimenting with intelligent, difficulty-based mask sampling rather than a purely uniform distribution.
Summary updated