Generalization in LLM Problem Solving: The Case of the Shortest Path

Yao Tong, Jiayuan Ye, Anastasia Borovykh, Reza Shokri

The AI community is currently locked in a debate: can Large Language Models (LLMs) actually "reason" systematically, or are they just high-end stochastic parrots? The challenge in answering this lies in the complexity of modern benchmarks. When a model fails a math word problem, it is difficult to isolate the root cause. Is it due to insufficient training data, a flawed training paradigm, or limited inference-time strategies?

To strip away this noise, researchers have introduced a controlled synthetic environment based on Composable Sequential Optimization Problems (SOPs)—specifically, shortest-path navigation on a grid. Because the rules of finding a shortest path are mathematically clear and easily verifiable, this setup enables a clean separation of variables to test how data, training, and inference independently contribute to an LLM's ability to generalize.

The "Clean Room" Methodology

The authors built a rigorous evaluation pipeline to test model capabilities:

  • Synthetic Environment: A 50x40 sparse grid where the model must output a sequence of directional moves (North, South, East, West) to navigate from point A to point B.
  • Model Architecture: 8-layer, 8-head Transformers trained from scratch, utilizing a LLaMA-style architecture with RoPE positional embeddings.
  • The Learning Pipeline: Models underwent pretraining (exposure to "random walks" to learn map connectivity) followed by fine-tuning. The researchers compared Supervised Fine-Tuning (SFT) against Reinforcement Learning (RL), specifically using the Dr.GRPO algorithm. Finally, they tested inference scaling using decoding strategies like "Majority-of-10" and an objective-guided "Shortest-of-10" search.

To ensure findings weren't just a quirk of the grid-world, the authors also validated their data-selection theories on the MathQA dataset, which contains math word problems annotated with operation programs.

Key Findings: The Generalization Asymmetry

The most striking discovery of the study is a distinct asymmetry in how models generalize: they exhibit strong spatial transfer but consistently fail at length scaling.

Models achieved >90% success rates on entirely unseen maps, proving they successfully internalized the underlying "rules" of navigation rather than just memorizing specific paths. However, performance plummeted as soon as the required path length exceeded the maximum length seen during training. For example, success rates dropped from near-perfect on length-20 paths to roughly 50% when moving to a length-40 horizon.

Success rate drops significantly as path length exceeds the training distribution.

This failure in long-horizon problems isn't simply because the problems are "harder." It is driven by recursive instability. Because LLMs generate answers autoregressively, a tiny error in the first few steps of a long path compounds, leading to a total breakdown in the remaining sequence. The model learns the logic of how to move toward a goal, but it struggles to maintain that logic over extended distances.

Optimizing the Pipeline: Data, RL, and Inference

By isolating different stages of the learning pipeline, the researchers uncovered several critical insights into how we train models to reason.

Data Allocation: Breadth Over Depth

When constructing a training dataset, the study found that Coverage (exposing the model to many different types of "primitives" or nodes) is far more important than Diversity (showing the model many different ways to solve the exact same problem).

Heatmap demonstrating that higher coverage yields better spatial transfer success rates than higher diversity.

This principle held true beyond the synthetic grid. On the MathQA dataset, a "High Coverage" strategy that maximized unique operation sets improved accuracy from 0.70 to 0.82, significantly outperforming a strategy focused on providing more solutions to fewer problems.

RL is a Stabilizer, Not a Magic Wand

Reinforcement Learning (RL) helped prevent the model from overfitting and made the training process more stable. However, it did not raise the fundamental performance ceiling. If a model lacked the capability to solve a problem via SFT, applying RL generally could not "teach" it to do so.

Inference Scaling Cannot Rescue Length Failures

While advanced decoding strategies like "Shortest-of-10" improved overall performance, they could not rescue the model from the fundamental decay caused by length scaling. The only reliable way to fix length-scaling failures was a curriculum-style approach: exposing the model to paths just slightly longer than its current training set.

Limitations and Future Directions

The authors acknowledge that their primary experiments utilized relatively small, custom-trained models to maintain a controlled environment. While they validated core data-selection findings on a 7B-parameter model (Qwen2.5), it remains to be seen exactly how "recursive instability" manifests in massive frontier models.

Future work will likely explore Chain-of-Thought (CoT) prompting as a potential remedy for recursive instability. This study focused on "direct-answer" settings to isolate the model's internal logic. Allowing a model to "think" step-by-step or utilize intermediate scratchpads might provide the necessary stability to handle longer horizons without compounding errors.

Summary updated

BibTeX
@inproceedings{tong2026generalization,
  author = {Yao Tong and Jiayuan Ye and Anastasia Borovykh and Reza Shokri},
  title = {{Generalization in LLM Problem Solving: The Case of the Shortest Path}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=RnRHNEeqvI},
}
Figure