Parametric memory enables large language models (LLMs) to retain information from past experience and reuse it in subsequent tasks. Yet how training data supports the internalization of reusable task rules remains unclear. We introduce FSMem (Finite-State Machine Memory), a state-transition framework for constructing training data and studying how data content and organization shape memory formation. We evaluate rule reuse across synthetic worlds, classical planning, and code execution through valid-action identification and execution-outcome prediction, complemented by next-operation prediction in code. Our experiments reveal several systematic learning patterns. Under matched training conditions, even unchanged task rules become harder to internalize when learned alongside a larger variety of action types; by contrast, scaling the training data to provide broader state-action coverage generally improves rule learning. We further find that training at a single execution depth produces depth-specialized behavior, with models performing best when training and test executions have similar lengths. Motivated by this finding, we construct cumulative corpora that combine short and long trajectories, which can outperform long-trajectory-only training while using fewer training tokens. Together, these results demonstrate that the same task rules can be internalized differently depending on how execution experience is constructed, and that understanding these learning patterns can guide the design of more effective training data for parametric memory.
Figures & tables
Figure 1: An illustration of FSMem in Blocksworld. (a) Recalling facts about specific entities. (b) Constructing training data from execution trajectories. (c) Identifying valid actions and predicting execution outcomes on held-out instances, without access to training records.
Figure 2: Valid-action identification as action complexity A increases. (a) Synthetic order-robust accuracy: light curves show individual settings and the green curve their mean. (b) Exact-set accuracy in 13 planning domains; the gray curve is an exponential fit. (c) Exact-set accuracy as more action types are included in training within each of seven planning domains.
Figure 3: Next-state and next-operation prediction as action complexity increases.
Figure 4
Depth
BW
Dep.
Ferry
Grip.
Sat.
Grid
GM
Swap
VA
Avg.
6 -only
35.2
6.4
50.2
22.5
55.3
36.2
69.1
35.9
75.3
42.90
2
31.5
6.7
33.7
9.8
32.7
31.1
37.6
35.4
46.8
29.47
2+4
62.3
11.4
55.8
24.0
66.0
45.2
77.3
91.8
79.3
57.01
2+4+6
77.0
11.8
67.8
31.1
95.9
47.1
99.4
99.7
80.0
67.76
Δ Tok
−2.9
−3.5
−3.4
−4.3
−4.9
−3.2
−4.3
−2.6
−5.6
−3.79
Table 2: Planning exact-set accuracy (%) and token use.
Figure 8: Synthetic accuracy by evaluation depth.
Training
Avg. acc.
Tokens
depths
(%)
(M)
16-only
64.4
6.86
1
32.3
3.34
1+4
91.6
3.67
1+4+8
98.3
4.09
1+4+8+16
99.0
4.78
Table 3: Synthetic Results.
Figure 9: Code Execution on long executions.
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
Exact-set accuracy (%)
Training tokens
Domain
2
2+4
C
L
Δ Acc (pp)
C (M)
L (M)
Δ Tok (%)
Blocksworld
31.50
62.28
77.00
35.17
+41.83
1.424
1.466
−2.9
Depots
6.72
11.44
11.83
6.39
+5.44
2.972
3.080
−3.5
Ferry
33.72
55.78
67.78
50.17
+17.61
2.342
2.424
−3.4
FloorTile
0.11
0.06
0.00
0.11
−0.11
5.142
5.212
−1.3
GoldMiner
37.56
77.28
99.44
69.06
+30.39
3.953
4.132
−4.3
Appendix
Table 4: Full planning depth results. Exact-set accuracy (%) averages evaluation depths 2, 4, and 6. C denotes training on depths 2+4+6 ; L denotes 6-only training. Δ Acc and Δ Tok compare C with L . Tokens are mean non-padding training tokens in millions.
Training corpus
Step t
N=50
N=200
N=800
N=1600
Valid-action identification (depth 4)
1
50
193
683
1,191
2
49
180
602
982
3
47
149
399
604
4
35
97
192
291
Next-state prediction (depth 1)
1
50
200
800
1,600
Appendix
Table 5: Measured breadth bt in synthetic training corpora ( A=20 ); N counts distinct sources.
Setting
Value
Optimizer
AdamW
LoRA rank / alpha / dropout
8 / 16 / 0
LoRA target modules
q_proj , v_proj
Peak learning rate
2×10−4
Example presentations per optimizer update
16
Appendix
Table 6: Fine-tuning settings for synthetic valid-action identification.
Figure 10: Action complexity and breadth across models. Top: synthetic accuracy; gray lines show individual settings, green their mean, and dashed brown the 0.5B reference. Bottom: planning gains relative to N=50 , where N counts distinct training sources; colors identify domains.
Figure 11: Depth specialization and cumulative training. Top: Blocksworld training–test matrices; numbers show accuracy (%), colors show deviations from column means, and outlines mark matched depths. Bottom: cumulative-training gains over 6-only training (dashed zero line). Each condition uses 300 steps; colors identify domains.
Train depth 2
Train depth 4
Train depth 6
Test depth
2
4
6
2
4
6
2
4
6
Δ
Qwen2.5-3B-Instruct
Logistics
86.6
72.5
70.0
81.9
77.4
79.7
76.7
77.0
75.2
+3.4
Depots
99.1
92.8
84.0
97.8
98.7
97.5
96.9
98.1
99.0
+4.5
Ferry
100.0
95.0
79.6
99.9
99.8
97.9
99.8
100.0
100.0
+4.6
Grippers
99.9
93.4
82.8
96.4
99.5
95.5
99.1
99.8
99.3
+5.1
Appendix
Table 7: Training–test depth matrices for the remaining planning domains. Values are order-robust accuracy (%); bold marks matched depths. Δ is the matching gain in percentage points. Blocksworld appears in Figure 11 .
Figure 12: Planning gains by candidate count. Top: N=1600 minus N=50 . Bottom: cumulative 2+4+6 minus 6-only training. All comparisons use 300 training steps. The dashed line marks zero gain; colors identify domains.
Figure 13: Cumulative-training gains at each evaluation depth. Curves show 2+4+6 minus 6-only order-robust accuracy in all complete planning comparisons. The dashed line marks zero gain; colors identify domains.
Domain
Qwen2.5-3B
Qwen2.5-7B
Qwen3-8B
Blocksworld
68.00
88.17
86.00
Depots
56.00
65.00
68.33
Ferry
67.83
92.00
92.33
FloorTile
0.50
0.00
4.17
GoldMiner
47.83
71.83
64.33
Grid
67.00
71.17
69.83
Appendix
Table 8: Complete valid-action-set accuracy (%) in 11 planning domains.
2+4
2+4+6
Domain
300 steps
600 steps
300 steps
900 steps
Qwen2.5-3B-Instruct
Blocksworld
95.08
96.15
97.32
98.03
Logistics
90.62
92.03
95.55
95.96
Depots
98.76
99.33
99.28
99.64
Ferry
99.24
99.39
99.96
99.96
Appendix
Table 9: Order-robust accuracy (%) with 300 total steps or 300 steps per included depth.
The training paradigm of large language models has shifted from traditional one-pass training to multi-epoch training, as reasonable reuse of limited high-quality data can improve both model performance and sample efficiency. Meanwhile, excessive repetition introduces the risk of overfitting and diminishing returns. Determining when and how to reuse data effectively thus emerges as a natural but under-explored question. Through a novel observation of model's "Memorization Window" signals derived from loss retention dynamics and downstream evaluation scores, we propose "Memorization-guided Data Reuse", a training paradigm that adaptively determines when and how data should be reused, enabling principled decisions on the number of training epochs and the scheduling of data replays. Our preliminary experiments reveal a consistent memorization-driven regime: performance continues to improve with repetition far beyond current practice (e.g., the commonly cited four-epoch limit). While a full scheduler remains future work, these insights provide a foundation for memorization-aware training schedules, helping to determine reuse budgets and move toward training LLMs smarter rather than longer with limited high-quality data.
Memory expertise is a learned skill: knowing what to encode, when to retrieve, and how to organize knowledge--a capacity known in cognitive science as metamemory. We bring this perspective to LLMs by treating memory management as a trainable skill. We promote file-system operations to first-class memory actions alongside task actions, letting the model itself decide how to manage its memory. This memory skill improves along two axes: the structure that supports it (prompts, file schemas, action vocabulary), and the proficiency of the model exercising it. Both axes resist manual optimization: episodes in long-horizon tasks run for thousands of steps, and a single memory mistake can hide long before it surfaces, making human review of full trajectories impractical. We introduce AutoMem, a framework that automates both axes. In the first loop, a strong LLM reviews complete agent trajectories and iteratively revises the memory structure that shapes how the agent interacts with its memory files. In the second loop, the agent's own good memory decisions are identified from many episodes and used as training signal to sharpen the model's memory proficiency directly. Across three procedurally generated long-horizon games (Crafter, MiniHack, and NetHack), optimizing memory alone--without modifying the model's task-action behavior--improved the base agent's performance ~2x-4x, bringing a 32B open-weight model competitive with frontier systems such as Claude Opus 4.5 and Gemini 3.1 Pro Thinking. Our results show that memory management is an independently learnable skill, and a high-leverage objective yielding large gains on long-horizon tasks.
Large Language Models (LLMs) must continuously learn and update knowledge to remain effective in dynamic real-world environments. While Low-Rank Adaptation (LoRA) is widely used for such memory updates, existing studies mainly rely on qualitative downstream evaluations, leaving the quantitative capacity limits and underlying dynamics of exact parametric memory largely unexplored. To bridge this gap, we employ LoRA as a controlled memory capacity probe within the latent space to systematically quantify exact parametric memory. We introduce the Parametric Memory Law, a robust power law linking loss reduction Delta L to effective parameters and sequence length. At the token level, fine-grained analysis reveals a deterministic phase transition, demonstrating that a prediction probability of p > 0.5 constitutes a sufficient condition for verbatim recall under greedy decoding. Driven by these insights, we introduce MemFT, a threshold-guided optimization strategy that dynamically redistributes the training budget toward sub-threshold tokens. Empirical evaluations demonstrate that MemFT can enhance memory fidelity and efficiency. Code will be released at https://github.com/zjunlp/ParametricMemoryLaw.