Procedural Knowledge at Scale Improves Reasoning
Organizations: University of California, Los Angeles · Meta FAIR
Abstract
Test-time scaling has emerged as an effective way to improve language models on challenging reasoning tasks. However, most existing methods treat each problem in isolation and do not systematically reuse knowledge from prior reasoning trajectories. In particular, they underutilize procedural knowledge: how to reframe a problem, choose an approach, and verify or backtrack when needed. We introduce Reasoning Memory, a retrieval-augmented generation (RAG) framework for reasoning models that explicitly retrieves and reuses procedural knowledge at scale. Starting from existing corpora of step-by-step reasoning trajectories, we decompose each trajectory into self-contained subquestion-subroutine pairs, yielding a datastore of 32 million compact procedural knowledge entries. At inference time, a lightweight in-thought prompt lets the model verbalize the core subquestion, retrieve relevant subroutines within its reasoning trace, and reason under diverse retrieved subroutines as implicit procedural priors. Across six math, science, and coding benchmarks, Reasoning Memory consistently outperforms RAG with document, trajectory, and template knowledge, as well as a compute-matched test-time scaling baseline. With a higher inference budget, averaged across models and tasks, it improves over no retrieval by 19.5% and over the compute-matched baseline by 8.9%. Ablation studies show that these gains come from two key factors: the broad procedural coverage of the source trajectories and our decomposition and retrieval design, which together enable effective extraction and reuse of procedural knowledge. Our experiment code is available at https://github.com/facebookresearch/reasoning-memory.
Figures & tables
| Method | Ret. | Math | Science | Code (LCB) | ||||
|---|---|---|---|---|---|---|---|---|
| AIME 24’ | AIME 25’ | MATH500 | GPQA-D | V1-4 | V5-6 | |||
| DeepSeek-R1-Distill-Llama-8B | ||||||||
| No RAG | N/A | 8 | 0.461 | 0.350 | 0.806 | 0.427 | 0.220 | 0.211 |
| Trajectory RAG (Prefix) | Proc. | 8 | 0.425 | 0.246 | 0.784 | 0.391 | 0.195 | 0.128 |
| Trajectory RAG (Summary) | Proc. | 8 | 0.408 | 0.321 | 0.822 | 0.431 | 0.184 | 0.121 |
| Template RAG (ReasonFlux) | Proc. | 8 | 0.450 | 0.342 | 0.828 | 0.417 | 0.174 | 0.210 |
| Setting | AIME 2024 | GPQA-D | LCB (V1-4) | Average |
|---|---|---|---|---|
| Removing Subroutine Decomposition | 0.551 | 0.433 | 0.308 | 0.431 |
| Removing Self-Generated Query | 0.567 | 0.453 | 0.295 | 0.438 |
| Full Reasoning Memory (Qwen3-8B) | 0.550 | 0.474 | 0.320 | 0.448 |
| Full Reasoning Memory (QwQ-32B) | 0.575 | 0.461 | 0.310 | 0.449 |
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
| Llama-3.1-8B (Inst.) | Llama-3.1-8B (Reas.) | Qwen2.5-7B (Inst.) | Qwen2.5-7B (Reas.) | Qwen2.5-32B (Inst.) | Qwen2.5-32B (Reas.) | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Fact. | Proc. | Fact. | Proc. | Fact. | Proc. | Fact. | Proc. | Fact. | Proc. | Fact. | Proc. | |
| AIME | 0.040 | 0.029 | 0.075 | 0.090 | 0.015 | 0.012 | 0.096 | 0.167 | 0.025 | 0.067 | -0.013 | -0.023 |
| GPQA | 0.223 | 0.254 | 0.150 | 0.151 | 0.173 | 0.204 | 0.076 | 0.084 | 0.159 | 0.160 | 0.065 | 0.076 |
| LCB | 0.027 | 0.059 | 0.041 | 0.077 | 0.029 | 0.033 | 0.033 | 0.053 | 0.178 | 0.159 | 0.004 | 0.032 |
| Average | 0.097 | 0.114 | 0.089 | 0.106 | 0.072 | 0.083 | 0.068 | 0.101 | 0.121 | 0.129 | 0.019 | 0.028 |
| Model | Method | AIME 2024 | GPQA-D |
|---|---|---|---|
| OpenThinker3-7B | Length Scaling | 0.647 | 0.502 |
| Empty Context + Length Scaling | 0.547 | 0.511 | |
| Majority Vote | 0.573 | 0.533 | |
| Reasoning Memory | 0.758 | 0.542 | |
| DeepSeek-R1-Distill-Llama-8B | Length Scaling | 0.548 | 0.447 |
| Empty Context + Length Scaling | 0.555 | 0.452 |
| DeepSeek-R1-Distill-Llama-8B | OpenThinker3-7B | Qwen3-32B | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Method | AIME 24’ | GPQA | LCB (V1–4) | AIME 24’ | GPQA | LCB (V1–4) | AIME 24’ | GPQA | LCB (V1–4) |
| No RAG | 0.461 | 0.427 | 0.220 | 0.470 | 0.438 | 0.318 | 0.789 | 0.669 | 0.387 |
| + length scaling | 0.508 | 0.426 | 0.255 | 0.612 | 0.484 | 0.333 | 0.792 | 0.699 | 0.399 |
| Trajectory RAG (Summary) | 0.408 | 0.431 | 0.184 | 0.438 | 0.451 | 0.242 | 0.629 | 0.595 | 0.267 |
| + length scaling | 0.483 | 0.439 | 0.175 | 0.533 | 0.444 | 0.290 | 0.567 | 0.580 | 0.224 |
| Template RAG (Self-Discover) | 0.442 | 0.414 | 0.213 | 0.442 | 0.441 | 0.276 | 0.667 | 0.633 | 0.312 |
| Method | AIME 24’ | GPQA | LCB (V1–4) |
|---|---|---|---|
| No RAG | 0.658 | 0.553 | 0.380 |
| Length Scaling | 0.692 | 0.548 | 0.396 |
| Reasoning Memory | 0.708 | 0.534 | 0.395 |
| Metric | AIME 24’ | GPQA-D | LCB (V1–4) |
|---|---|---|---|
| Likelihood | 0.571 | 0.429 | 0.273 |
| Entropy | 0.600 | 0.417 | 0.273 |
| Contrast | 0.563 | 0.419 | 0.269 |
| Self-Eval | 0.571 | 0.402 | 0.263 |
| Length | 0.575 | 0.461 | 0.310 |
| Question | Please answer the following math question. Find the sum of all integer bases for which is a divisor of |
|---|---|
| Query | 17 in base is equal to what in decimal? |
| Retrieved Subquestion | How do you convert a number from an arbitrary base to its decimal (base 10) equivalent? |
| Associated Subroutine | For problems like this, I should first write the number as a sum of each digit multiplied by the base raised to the power of its position index. Here’s how: 1. Identify each digit of the number in the original base. 2. Assign positional indices starting from at the rightmost digit (the least significant digit). 3. Compute the weight of each digit by raising the base to the power of its position index. 4. Multiply each digit by its corresponding weight. 5. Sum all the products to obtain the decimal (base 10) equivalent. For example, a number in base converts to decimal as: Ensure all digits are valid in the original base (i.e., ) before proceeding. |
| Continued Reasoning | Okay, so I have this math problem here: Find the sum of all integer bases for which is a divisor of . Hmm, okay. Let me try to figure this out step by step. First, I remember that when numbers are written with a subscript like , it means they’re in base . So I need to convert both and into decimal (base 10) to work with them more easily. Let’s start with . In base , the rightmost digit is the units place (which is ) and the next digit is the place. So would translate to: Got that. So in decimal. Now, let’s do the same for … |
| Question | Two-thirds of the students at Baker Middle School take music. There are 834 students who take music. How many students are there at Baker Middle School? |
|---|---|
| Query | of something equals 834, what is that something? |
| Retrieved Subquestion | What is the result of dividing 3.6 by 1.6? |
| Associated Subroutine | For problems like this, I should first eliminate decimals by expressing the division as a fraction of whole numbers. For example, if dividing by , multiply both the numerator and denominator by 10 to convert them into whole numbers ( ). Then, simplify the fraction by dividing the numerator and denominator by their greatest common divisor or perform long division directly. If simplifying isn’t straightforward, break the division into parts: calculate how many times the divisor fits into the dividend, subtract that portion, and handle the remainder to find the exact value. This method works for any decimal division where precision is needed. |
| Continued Reasoning | Okay, so I’ve got this math problem here: Two-thirds of the students at Baker Middle School take music, and there are 834 students who take music. The question is asking how many students are there at Baker Middle School in total. Hmm, let’s think about this step by step. Alright, two-thirds of the school takes music, which means if I can figure out what number multiplied by two-thirds gives me 834, that number will be the total number of students at the school. So, essentially, I need to solve for the total number of students, which I’ll call . The equation would be: To find , I should isolate it on one side of the equation. To do that, I can multiply both sides by the reciprocal of two-thirds, which is three-halves . So, multiplying both sides by : Let me compute that. divided by is , and then multiplied by is: , and , so adding those together gives me . So, . |
| Question | Generate a correct Python program that passes all tests for the given problem. Problem Title: Problem Statement: You are given three length- sequences of positive integers: Find the number of pairs of positive integers that satisfy the following condition: It can be proved that the number of such pairs of positive integers satisfying the condition is finite. You are given test cases, each of which should be solved. |
|---|---|
| Query | how to count the number of pairs that satisfy multiple inequalities for all |
| Retrieved Subquestion | How do you count the number of integer pairs that satisfy a linear inequality with non-negative coefficients and bounds? |
| Associated Subroutine | For problems like this, I should consider the following steps: 1. Fix one variable and solve for the other. Choose one variable (e.g., ) and iterate through its possible values within the bounds. For each fixed , determine the minimum or maximum value of the other variable (e.g., ) required to satisfy the inequality. 2. Use complementary counting if feasible. If the inequality’s valid region is large, it may be easier to calculate the total number of candidate pairs (for example, for bounds ) and subtract the count of pairs that do not satisfy the inequality. This is especially useful when the invalid region is smaller or has a simpler structure. 3. Account for variable bounds. Ensure all computed ranges for or respect their given constraints (e.g., ). Adjust the ranges to stay within these bounds, even if the inequality suggests values outside them. 4. Sum valid counts systematically. For each fixed value of the first variable, compute the number of valid values for the second variable and accumulate these counts. Organize the calculations (for example, by grouping cases where the inequality trivially holds or fails) to avoid errors and redundant work. This approach balances direct enumeration with strategic shortcuts to efficiently count solutions while avoiding overcomplication. |
| Continued Reasoning | So I’ve got this programming problem to solve. Let’s read it carefully. The problem is about finding the number of pairs of positive integers that satisfy for all from to . So for each , the same and have to satisfy this inequality. In other words, we need to find all such that for every , holds simultaneously. We are given test cases, and for each test case we get lines of . The goal is: for each test case, compute the number of such pairs. Geometrically, each inequality describes a half-plane in the first quadrant (since and are positive integers). The feasible region is the intersection of all these half-planes restricted to , . The statement that the answer is finite means this intersection is a bounded polygonal region. One possible strategy is to treat as the main loop variable… |
| Question | There are values of in the interval where For of these values of , the graph of is tangent to the -axis. Find . |
|---|---|
| Query | How to find the number of solutions to between and , and how many of those have tangent to -axis. |
| Top-3 Retrieved Subquestion | 1. How do you analyze the behavior of a trigonometric function (e.g., using derivatives) to confirm the number of solutions in a given interval? 2. How do you systematically count and confirm the total number of valid solutions by combining results from both cases and ? 3. How do you analyze the behavior of a function (e.g., ) in intervals between vertical asymptotes to determine the number of solutions? |
| Question | [redacted, luminosities of two stars radiating as black bodies] |
|---|---|
| Query | astronomers luminosity star radius relation |
| Retrieved Subquestion | What is the relationship between a star’s radius and its luminosity? |
| Associated Subroutine | For problems asking about the relationship between a star’s radius and luminosity, I should start by recalling the Stefan–Boltzmann law: where is luminosity, is radius, is temperature, and is the Stefan–Boltzmann constant. Luminosity depends on both radius and temperature. To isolate the radius–luminosity relationship, consider how changes in radius affect while holding temperature constant. However, for main-sequence stars, radius and temperature are not independent—both increase with mass. Use the mass–radius and mass–luminosity relationships (e.g., , ) to deduce the overall correlation. Remember that temperature also contributes strongly to luminosity, so the radius’s role must be analyzed in concert with mass and temperature dependencies. |
| Continued Reasoning | Okay, so I have this astronomy problem here about the luminosities of two stars, Star 1 and Star 2. Let me try to work through it step by step. The question says that Star 1 has a radius times larger than Star 2, and the mass of Star 1 is also times larger. They also mention that the wavelengths at which the stars appear brightest are the same, and their radial velocities are for Star 1 and for Star 2. The question is about the ratio of their luminosities, so I need to compute how much brighter Star 1 is compared to Star 2. I remember that the luminosity of a star is related to its radius and temperature. The Stefan–Boltzmann law is where is luminosity, is radius, is the Stefan–Boltzmann constant, and is the effective temperature. At first I might wonder whether the Doppler effect due to different radial velocities matters here, but the problem states that the wavelengths at which they appear brightest are the same. That suggests their effective temperatures are the same, because the peak wavelength (or color) is determined by temperature via Wien’s law. So I can take . If the temperatures are equal, then the ratio of luminosities depends only on the ratio of radii: Since , this gives which corresponds to choice (D), approximately . |