Manuscript Offprint

arXiv:2608.29376

Evaluating Tiny Recursive Models Across Training for Code Generation

Anjani Sirivella, Aanisha Newaz, Glaucia Melo

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Anjani Sirivella

Dept. of Computer Science

Toronto Metropolitan University

Toronto, ON, Canada

asirivella@torontomu.ca

Aanisha Newaz

Dept. of Computer Science

Toronto Metropolitan University

Toronto, ON, Canada

aanisha.newaz@torontomu.ca

Glaucia Melo

Dept. of Computer Science

Toronto Metropolitan University

Toronto, ON, Canada

glaucia@torontomu.ca

Abstract—Code generation increasingly relies on large transformer models, whose capability advances with scale. Yet such a scale is costly, creating demand for small models, especially where data is limited. Recursive models address this by reusing a single block to add depth rather than stacking independent layers. Such models are typically evaluated by teacher-forced fit (next-token loss on ground-truth prefixes) or task accuracy, at a single checkpoint, whereas code is produced by free-running generation, where the model extends its own output. Whether a teacher-forced advantage survives free-running generation, and whether it holds across training, remains open. To study both, we compare a ∼\sim28M-parameter autoregressive Tiny Recursive Model (TRM-AR) on natural-language-to-Python code generation against parameter-matched and depth-matched controls, tracking fit and generation across 40 epochs and three seeds. The fit ranking between the recursive model and the depth-matched control reverses twice. Selecting each checkpoint by validation loss and examining the trajectory yields a consistent comparison. At equal parameters, TRM-AR fits, generates, and generalizes better than the parameter-matched control while recovering approximately 45% of the validation-loss gap and 57% of the generation-quality gap between the two controls, at roughly 175×175\times the per-step cost of the parameter-matched control. However, at equal effective depth, the larger transformer fits and generates better at its validation optimum, suggesting TRM-AR's advantage lies in resistance to overfitting, not greater capability. These findings suggest that recursive code generation models should be evaluated jointly on fit and generation across the training trajectory rather than at a single checkpoint.

Index Terms—Software Engineering, Tiny Recursive Models, Recursive Neural Networks, Code Generation, Training Dynamics, Weight Sharing

I. INTRODUCTION

Code generation from natural language has become a central task in software engineering [1]. The systems that dominate it are transformer-based language models [2], whose capability has advanced largely by scaling parameters and data [3]. State-of-the-art code models now reach billions of parameters, trained on vast code corpora [4]–[7]. Models at this scale are costly to train and to serve [8], which creates practical demand for small models that generate code well. That demand is most acute where training data is limited, since additional parameters are hardest to feed in exactly that regime [9]. Whether small models can generate code well without scaling parameters remains open.

Recursive models address this directly: they obtain computational depth by reusing a single small block of weights rather than by stacking independent layers [10], [11]. The Tiny Recursive Model (TRM) [12], a minimal simplification of the Hierarchical Reasoning Model [13], is a striking instance: with only 7M parameters, it reaches roughly 45% test accuracy on ARC-AGI-1, reportedly surpassing far larger language models such as DeepSeek R1, o3-mini, and Gemini 2.5 Pro [12]. Yet the literature evaluates this family almost entirely through teacher-forced fit (next-token prediction from ground-truth prefixes) [14], or task accuracy [15]; for TRM and its predecessor specifically, that accuracy comes from puzzle tasks whose answers are scored by exact match, reported at a single converged checkpoint [12]. Generating code, however, requires free-running generation, in which the model conditions on its own earlier output rather than on a ground-truth prefix [16].

We argue that the comparison between recursive and standard models is time-indexed: which model performs better depends on what is measured and when in training it is read. A teacher-forced advantage need not reach free-running generation, because the two regimes are known to diverge [17] and because early errors can compound over a long generated sequence [18]. Model behaviour also changes across training, so the point at which a comparison is read can change its conclusion [19]. Teacher-forced fit and free-running generation must therefore be tracked jointly across the whole training trajectory.

In this paper, we instantiate this evaluation as a controlled, multi-epoch crossover-curve study of natural-language-to-Python code generation at ∼\sim28M parameters on the tiny-codes corpus [20]. A recursive model differs from a plain transformer on two axes at once: parameter count and effective depth. We therefore compare an autoregressive adaptation of TRM (TRM-AR) against two controls that each hold one axis fixed: a transformer matched to its parameter budget (iso-parameter) and a transformer matched to its effective depth (iso-depth), the latter necessarily larger. We evaluate all three across 40 epochs and three seeds, measuring teacher-forced fit separately from free-running generation.

Across training, the fit ranking between TRM-AR and the iso-depth control is not stable across checkpoints: it reverses twice within the budget. The latter reversal is an overfitting effect, arising as the iso-depth control's validation fit worsens while the recursive model holds steady. We select each model's checkpoint on validation loss and read the whole trajectory, which gives two stable comparisons a single checkpoint cannot: one at equal parameters and one at equal effective depth.

Single-checkpoint comparisons of recursive models can therefore be artifacts of the training time at which they are read. We accordingly recommend that evaluations of such models report teacher-forced fit and free-running generation jointly across the training budget, echoing broader calls to strengthen empirical rigor in machine learning [21].

We ask the following research questions (RQs). The first concerns how the comparison evolves across training; the remaining three examine parameter efficiency, compute cost, and generation quality.

• RQ1: How does the recursive depth’s advantage over a depth-matched, larger transformer change across the training budget?

• RQ2: How does recursive depth affect parameter efficiency for code generation at equal parameters?

• RQ3: How does the per-step compute cost of recursion compare to the fit gain it yields at equal parameters?

• RQ4: How does recursive depth affect free-running generation quality at equal parameters?

This paper makes the following contributions:

• A multi-epoch crossover-curve evaluation that tracks teacher-forced fit against free-running generation across training and three seeds, with parameter- and depth-matched controls; we show that a single checkpoint can produce a misleading ranking, as several epochs here do, which reading the full trajectory corrects.

• Evidence that, at equal parameters, the TRM-AR configuration (recursive depth with deep supervision) improves fit, generation as scored by an LLM judge [22], and generalization from early training onward, extending the established parameter-efficiency claim for looped models to free-running code generation (Section IV).

• A boundary result: at equal effective depth, a larger plain transformer both fits and generates better at its optimum, so what recursion retains against it is resistance to overfitting (consistent with implicit regularization), not superior capability (Section IV).

• A measurement of the per-step compute cost of recursion, showing that it is parameter-efficient but not compute-efficient (Section III-F).

• A replication package with code, configuration, and the aggregated crossover-curve results is publicly available [23].

The remainder of this paper is organized as follows. Section II reviews related work. Section III describes the experimental methodology. Section IV presents the results and Section V interprets them. Section VI states the limitations of this study and Section VII concludes the paper.

References (50)