[Paper Review] Physics of Language Models: Part 2.1, Grade-School Math and the Hidden Reasoning Process
This paper investigates how small language models solve grade-school math problems by training a GPT-2-like model from scratch on a large, diverse synthetic dataset of logical reasoning math problems. It demonstrates that models develop genuine reasoning skills beyond memorization, generalize out-of-distribution, and achieve 99% accuracy on GSM8K-like problems, revealing hidden reasoning processes and generalization mechanisms in LLMs.
Recent advances in language models have demonstrated their capability to solve mathematical reasoning problems, achieving near-perfect accuracy on grade-school level math benchmarks like GSM8K. In this paper, we formally study how language models solve these problems. We design a series of controlled experiments to address several fundamental questions: (1) Can language models truly develop reasoning skills, or do they simply memorize templates? (2) What is the model's hidden (mental) reasoning process? (3) Do models solve math questions using skills similar to or different from humans? (4) Do models trained on GSM8K-like datasets develop reasoning skills beyond those necessary for solving GSM8K problems? (5) What mental process causes models to make reasoning mistakes? (6) How large or deep must a model be to effectively solve GSM8K-level math questions? Our study uncovers many hidden mechanisms by which language models solve mathematical questions, providing insights that extend beyond current understandings of LLMs.
Motivation & Objective
- To determine whether language models learn true reasoning skills or merely memorize templates when solving grade-school math problems.
- To investigate whether models trained on GSM8K-like datasets develop generalizable reasoning abilities beyond the specific task.
- To understand the minimal model size and architecture requirements for solving complex reasoning problems.
- To uncover the hidden mental processes behind model reasoning and error patterns.
- To eliminate data contamination concerns by training from scratch on a controlled, synthetic dataset with high diversity.
Proposed method
- Designed a synthetic dataset generation framework that produces diverse, logically structured math problems with controlled dependencies and parameter relationships.
- Constructed problems using abstract parameters and dependency graphs to ensure logical reasoning is required, avoiding reliance on common sense or arithmetic.
- Used a GPT-2 model with rotary positional embeddings (RoPE) trained from scratch on the synthetic dataset to avoid pretraining data contamination.
- Implemented algorithms to generate problem structures with specific reasoning depth and necessary dependencies, ensuring solution templates are not memorizable.
- Employed topological ordering and dependency tracking to ensure all parameters are necessary for computing the query, enforcing logical reasoning over rote computation.
- Evaluated model performance on in-distribution and out-of-distribution generalization, including longer reasoning chains than seen during training.
Experimental results
Research questions
- RQ1Can language models develop genuine reasoning skills, or do they simply memorize problem templates?
- RQ2What is the hidden reasoning process that language models use to solve math problems?
- RQ3Do models trained on GSM8K-like datasets learn reasoning skills that generalize beyond the benchmark?
- RQ4What causes models to make reasoning errors, and how can these be diagnosed?
- RQ5How small can a language model be and still solve grade-school math problems effectively?
Key findings
- The model achieved 99% accuracy on GSM8K-like problems, demonstrating strong performance even when trained from scratch on a synthetic dataset.
- The model generalized to out-of-distribution problems with longer reasoning chains than seen during training, indicating robust reasoning generalization.
- The number of distinct solution templates in the dataset exceeded 90 trillion, making memorization impossible for a model of GPT2-small size.
- The model’s reasoning process is structured and hierarchical, relying on dependency chains rather than pattern matching, as confirmed by analysis of attention and generation paths.
- Mistakes were primarily due to incorrect dependency tracking or misordering of reasoning steps, not arithmetic or vocabulary issues.
- Depth (number of layers) was more critical than width for reasoning performance, suggesting architectural depth supports complex reasoning chains.
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.