The Dichotomy Between Pattern Recognition and Step-by-Step Reasoning
Organizations: University of Pennsylvania
Abstract
We argue that pattern recognition and step-by-step reasoning are two ends of a spectrum. A large language model (LLM) learns to reason step-by-step when data is structured such that the next token depends on a small amount of preceding context. Inference in LLMs resembles pattern recognition when the next token depends on a large amount of preceding context. If the next token depends on only the most recent tokens, reasoning traces are paths on a De Bruijn graph whose nodes are -length contexts and edges are next-token transitions between contexts. The set of reasoning traces of a task forms a directed acyclic subgraph of the De Bruijn graph. An LLM that has learned all edges of this subgraph can compose them to solve longer, unseen tasks, i.e., it reasons step-by-step. We prove that the number of edges is vanishingly small compared to the number of reasoning traces. Empirically, the number of training samples a transformer needs is a power law in the number of edges, so learning to reason step-by-step is sample efficient. We can induce De Bruijn structure in any task by maintaining a ``state'' that makes future reasoning independent of the past. The frequency of states in the reasoning trace determines . We show, by fine-tuning Qwen2.5-1.5B-Instruct to solve equations and answer questions about stories, that frequent states (small ) result in higher accuracy but greater fragility to perturbations at test time. LLMs trained with a large are only as good as models that perform pattern recognition without reasoning. A moderate density of states balances accuracy and robustness. We show that real-world data has De Bruijn structure: Qwen3-14B and Qwen3-32B retain over 75% of their accuracy on GSM8K, MATH-500 and GPQA-Diamond when attention is restricted to a sliding window less than 15% as long as the full reasoning trace.
Figures & tables
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
| 8 | 2 | 5 | 8 |
| 10 | 2 | 6 | 10 |
| 12 | 2 | 8 | 12 |
| 8 | 3 | 10 | 20 |
| 10 | 3 | 12 | 24 |
| 11 | 3 | 14 | 28 |
| Action | Templated sentence | Prob. |
| Enter room | {P} entered the {R}. | 0.170 |
| Leave room | {P} left the {R}. | 0.085 |
| Move to container | {P} moved the {O} to the {C}, which is also located in the {R}. | 0.255 |
| Move to room | {P} moved the {O} to the {R}, leaving the {C} in its original location. | 0.170 |
| Tell privately (topic) | {P1} told privately to {P2} about the {T}. | 0.092 |
| Tell privately (location) | {P1} told privately to {P2} that the {O} is in the {C}. | 0.137 |
| Question type | Share | False-belief share |
| Knowledge, second-order | 55.9% | 34.9% |
| Knowledge, first-order | 18.7% | 0.0% |
| Room location, second-order | 11.8% | 34.3% |
| Container location, second-order | 8.4% | 53.7% |
| Container location, first-order | 5.1% | 33.3% |
| All | 100.0% | 29.8% |