[Paper Review] Can You Learn an Algorithm? Generalizing from Easy to Hard Problems with Recurrent Networks
This paper demonstrates that recurrent neural networks trained on easy instances of reasoning problems—such as prefix sums, mazes, and chess—can generalize to significantly harder problems by increasing their inference-time recurrence steps, effectively emulating algorithmic reasoning through iterative computation. The key contribution is showing that such models learn scalable, algorithm-like behaviors that extend beyond their training distribution without retraining or architectural changes.
Deep neural networks are powerful machines for visual pattern recognition, but reasoning tasks that are easy for humans may still be difficult for neural models. Humans possess the ability to extrapolate reasoning strategies learned on simple problems to solve harder examples, often by thinking for longer. For example, a person who has learned to solve small mazes can easily extend the very same search techniques to solve much larger mazes by spending more time. In computers, this behavior is often achieved through the use of algorithms, which scale to arbitrarily hard problem instances at the cost of more computation. In contrast, the sequential computing budget of feed-forward neural networks is limited by their depth, and networks trained on simple problems have no way of extending their reasoning to accommodate harder problems. In this work, we show that recurrent networks trained to solve simple problems with few recurrent steps can indeed solve much more complex problems simply by performing additional recurrences during inference. We demonstrate this algorithmic behavior of recurrent networks on prefix sum computation, mazes, and chess. In all three domains, networks trained on simple problem instances are able to extend their reasoning abilities at test time simply by "thinking for longer."
Motivation & Objective
- To investigate whether recurrent neural networks can learn algorithmic reasoning that generalizes beyond training data to harder problem instances.
- To explore if increasing inference-time recurrence enables models to solve problems of greater complexity than seen during training.
- To determine if recurrent architectures can achieve logical extrapolation in reasoning tasks traditionally solved by hand-crafted algorithms.
- To compare the performance of recurrent models with fixed-depth feed-forward networks in out-of-distribution generalization.
- To visualize and analyze the iterative reasoning process learned by recurrent networks during inference.
Proposed method
- Training recurrent networks on small, easy instances of reasoning problems using a fixed number of recurrence steps.
- Testing the same models on harder problem instances by increasing the number of recurrence steps at inference time.
- Using standard recurrent architectures (e.g., GRUs or LSTMs) with weight sharing across recurrence steps to enable scalable reasoning.
- Evaluating performance on three domains: prefix sum computation, maze solving, and chess puzzle solving.
- Visualizing the internal activations and attention patterns across recurrence steps to interpret learned reasoning processes.
- Comparing generalization performance against feed-forward networks of equivalent depth, which lack iterative reasoning capacity.
Experimental results
Research questions
- RQ1Can recurrent networks trained on easy problems generalize to harder problems by increasing inference-time recurrence?
- RQ2Does extending the number of recurrence steps at test time lead to improved performance on out-of-distribution, harder instances?
- RQ3How does the performance of recurrent models compare to feed-forward networks when solving problems beyond the training distribution?
- RQ4Do recurrent networks learn algorithmic-like behaviors that resemble classical iterative algorithms (e.g., BFS, reduction trees)?
- RQ5Can the internal dynamics of recurrent networks be interpreted as deliberate, step-by-step reasoning in working memory?
Key findings
- Recurrent networks trained on easy mazes generalize to much larger mazes when given more recurrence steps at test time, outperforming fixed-depth feed-forward networks.
- Models trained on small prefix sum problems generalize to arbitrarily large inputs by increasing inference-time iterations, achieving exact results with sufficient recurrence.
- In chess puzzles, models trained on lower-rated puzzles solve higher-rated puzzles at test time by increasing recurrence, demonstrating logical extrapolation.
- Performance improves monotonically with more recurrence steps, even without retraining or architectural changes, indicating scalable reasoning.
- Visualization shows that the network’s internal activations evolve progressively, first identifying key elements (e.g., rook in chess) and then determining optimal moves.
- The behavior is specific to recurrence: feed-forward networks with equivalent depth fail to generalize to harder problems, highlighting the role of iterative computation.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.