WorksComputer Science
Learning When to Abort in Transformer Planning: A Mechanistic Study
Abstract
Planning does not by itself imply the ability to recognise errors, but recognising errors can improve planning capacity. In this paper, we study this phenomenon in Transformer planning. To analyze the inner mechanism, we follow the approach of Wang et al. (2024) and abstract planning as path-finding in graphs. In this setting, we train the model to detect the error of invalid transitions, i.e., after the model generates a next node that is not adjacent with the current node, the model should then generate a special abort token x. For expressiveness, we construct a Transformer with feed-forward width for any fixed graph with node set . It can detect all possible invalid transitions, and select a valid next node if the prefix is valid. We then propose a worst-case lower bound on feed-forward width, which makes the detector's linear width near-optimal up to logarithmic factors. In trained models, we demonstrate that invalid-transition detection increases previous-node attention, and most of the valid–invalid separation locates in the feed-forward network's output. This accords with our theoretical insights. Finally, we use this error detection to improve the model's performance: at inference, generating the abort token x will directly cause an external procedure to discard the attempt and restart from the original prompt. Experiments show that error detection combined with retry improves model's planning reliability on graphs, Countdown, and mazes.
Introduction
Planning involves choosing a sequence of steps that leads from an initial state to a goal, and is ubiquitous in daily life. In recent years, Transformer-based large language models (LLMs) are increasingly used for tasks requiring such multi-step planning, including mathematics and coding. Understanding how these models plan, and improving their planning capacity therefore becomes more and more important. In this paper, we study how learning to recognise invalid planning steps (or invalid transitions), could improve language-model planning. Traditional training on correct planning trajectories teaches a model which steps to take, but does not explicitly teach how to recognise invalid steps. In fact, planning ability does not need to bring failure recognition: a model may be able to find valid solutions yet fail to recognise that a problematic input contains invalid steps.
In human planning, however, failure recognition is also thought to play an important role in planning ability ([1, 8]).
Can a Transformer-based language model learn to detect invalid planning steps, what could be the underlying mechanism of this learning process, and how can this improve the model’s performance?
We conduct a mechanistic study on this problem, based on the path planning setup of ALPINE (Wang et al., [15]). In ALPINE, the planning task is abstracted as looking for valid paths in a fixed graph. The graph is not supplied as an input, hence the model must learn the graph’s structure from the training paths and find valid paths for unseen pairs. As for invalid planning steps, we focus on invalid transition, which is a step in the generated path from some node to node that has no corresponding edge in the underlying graph. To enable the Transformer to detect invalid transitions, we generate new training data containing valid path prefixes followed by an invalid transition, and then followed by a special abort token . Only the abort token is supervised on these generated data, so that the Transformer could learn to flag invalid transitions without being trained to produce them. Intuitively, this is analogous to adding wrong planning steps and masking them in a planning task for the model to learn from mistakes.
Graph path-finding lets us distinguish two computations. Selecting the next node uses the current node’s outgoing edges and reachability to the target; detecting an invalid transition instead requires relating the previous node to the current one.
Learning from search traces and error markers can improve planning [9, 11, 10, 17]. Our focus is the mechanism: what computation invalid-transition detection requires, and whether abort supervision induces it in trained models. Theoretically, Proposition 1 of § 4.1 shows that an additive score of the previous and current nodes with a threshold cannot detect arbitrary invalid transitions. In § 4.2, we construct a one-layer Transformer that combines next-node selection with invalid-transition detection using the nonlinear feed-forward layer with width linear in the number of nodes. The lower bound in Section 4.3 makes the detector’s linear width near-optimal up to logarithmic factors within the specified class of ReLU detectors. Empirically, § 5 connects the abort decision to previous-node information and feed-forward network (FFN) processing in real trained Transformers. Attention measurements show whether the model looks back, interventions test whether previous-node information controls the abort decision, and direct logit attribution measures the FFN’s contribution to the abort signal. A fitted additive-logit alternative retains substantial detection error on the same supervised prefixes (Appendix § 11.§ 2). These findings are consistent with the computational dependencies identified by the theory.
We then ask whether the learned signal improves planning. At inference, a harness, an external procedure surrounding the model, discards an attempt when is emitted and restarts from the original prompt. Experiments on random graphs, Countdown and mazes show that this procedure improves planning reliability (§ 6). Unlike verifier-ranked best-of- sampling [7, 12], it does not require a fixed set of complete candidates or a separate correctness verifier: the model supplies the signal for restarting an attempt.
Our contributions are threefold: a simple training method that turns local errors into abort supervision; a mechanistic account of invalid-transition detection, combining a one-layer Transformer construction, a capacity lower bound and experiments on trained models; and an inference-time restart harness that uses the learned signal to improve planning across tasks and models.
Related Work
Our mechanistic starting point is ALPINE [15], which explains how Transformers select the next node using adjacency and reachability information. We build on this account to study invalid-transition detection. Complementary work studies how models compose reachability information to select future steps [18], represent and maintain the current planning state during search [13], and improve planning through reinforcement-learning fine-tuning [16].
Our training approach belongs to the line of work on learning from search and error traces. Gandhi et al. [9] train on complete search trajectories containing exploratory mistakes and backtracking, while Lehnert et al. [11] train models to imitate search dynamics. Closer to our setting, Huang et al. [10] train on erroneous actions followed by in-context corrections. Their models recognise mistakes, but self-correction does not improve plan validity in their evaluation. We instead separate detection from recovery: the model learns to flag an invalid transition, and an external procedure handles retry.
Self-Backtracking [17] is the closest method. It learns a token that triggers rollback and further search from an earlier state; our harness restarts from the original prompt. Its error-example loss supervises both the correct prefix and the backtrack token, whereas ours supervises only the abort token. Our labels require checking one transition, rather than determining that a prefix admits no valid completion, which can require searching over future continuations [5]. In our small-model Countdown experiments, we cross the two objectives with restart and rollback decoders. Abort-only supervision performs better with either decoder, suggesting that the simpler objective contributes to the gain in this setting (Appendix § 11.§ 4). Our mechanistic analysis further distinguishes this work by combining an explicit Transformer construction with experiments on the learned computation.
Additionally, some work uses separate signals to guide generation. State–action verifiers ([2]) check whether an action is valid in the current state. Process-verifier approaches use information about whether a prefix admits a valid completion ([4]), or learned estimates of the quality of partial generations ([14]), to guide sampling and backtracking. In our approach, the planner itself (rather than an independent verifier) learns to emit the abort signal during generation. Confidence-token methods ([6]) are also related, but estimate the reliability of the overall answer rather than whether the latest step is invalid.
Model and Method
Transformer Architecture
We use the following one-layer architecture for the theoretical analysis, following Wang et al. [15]. Let be the sequence length, the embedding size, the number of attention heads, the size of each head, and the vocabulary size. A token sequence is a one-hot matrix , embedded as , where and are the token and positional embedding matrices. The multi-head attention (MHA) sublayer is
where the softmax is causally masked and , , and are the query, key, and value projections for head , and the brackets denote horizontal concatenation over heads. The attention output projection is . With , the feed-forward network is , where acts elementwise, and the layer output is . Here , , , and . The feed-forward width is conventionally fixed at . We name explicitly because it is the resource the abort detector uses. The vocabulary logits (next-token scores before softmax) are , where is the unembedding matrix. Layer normalisation is omitted in the above equations.
Path-Planning Task, Data, and Training
We follow the graph path-finding setup of ALPINE (Wang et al. [15]). Fix a directed acyclic graph (DAG) with nodes. Given a source and a reachable target , the model receives the prompt and needs to generate a node sequence starting at , ending at , and following graph edges. We define a valid path prefix as a node sequence that starts at and follows only graph edges, and write when can reach , including .
There are two types of training trajectories. Correct training trajectories have the form , where is a valid path from to . These trajectories are used to train the usual sequence generation process, and thus receive the usual next-token loss. Error trajectories add supervision about invalid transitions. Each contains a valid prefix followed by one non-edge and the token . Only the final is supervised; the prefix and invalid transition provide context, not prediction targets. We call this training signal abort supervision. We call the resulting model a +x model, and a model trained only on correct trajectories the baseline. The detailed loss formulation is given in (11) (Appendix § 11.§ 1).
Our abort labels are local: in graph planning, determining whether a transition is invalid only requires checking whether , without reasoning about whether the current prefix can still reach the target. Thus, constructing error trajectories requires only a local edge check, rather than solving the remaining planning problem.
For graph experiments, each edge with is included independently with probability 0.1. Reachable source–target pairs are randomly split into training and test sets, except that direct-edge pairs always enter training. Each training pair contributes 20 valid paths. The +x dataset adds one error trajectory per correct trajectory, and minibatches sample uniformly from this mixture. The loss averages over supervised tokens: correct trajectories supply multiple labels, error trajectories only one. Thus, correct trajectories make up half the batch on average but supply most labels.
We denote an architecture by layer count/head count/embedding size and compare 1/1/120, 1/2/120 and 1/2/384. All use feed-forward width , where is embedding size. The experiments use GELUs (Gaussian error linear units), layer normalisation and tied embedding/unembedding weights. Models are trained for updates with batch size 1,024 and learning rate ; Appendix § 11.§ 1 gives the full protocol. Graph results use five seeds, each with an independently generated graph. Error bars are standard errors (s.e.) over seeds and gains are paired.
Theory of Invalid-Transition Detection in Path-Planning
Let be the graph’s adjacency matrix, where is 1 when its condition holds and 0 otherwise. The true reachability matrix has entry .
Additive Detection Is Insufficient
To output the abort token correctly, the model needs to determine whether the most recent transition is valid, that is, whether . We next show that simply adding separate functions of and in a single thresholded score is not sufficient for general graphs.
Proposition 1. If has nodes and with and , then no threshold on an additive function can correctly classify all four transitions as edges or non-edges, whether larger scores indicate validity or invalidity.
To see why, consider the two edges and , whose crossed pairs and are non-edges. For an additive function , with ,
Thus, the two edge scores and the two non-edge scores have the same total, so no threshold can place both edges on one side and both non-edges on the other.
Thus, general invalid-transition detection with a scalar threshold requires a non-additive combination of previous-node and current-node information. In the next subsection, we show how a Transformer implements this check by selecting the current node’s entry from the previous node’s adjacency row.
A Gated Lookup for Invalid Transition Detection
In this subsection, we construct a one-layer, two-head Transformer that performs path planning and invalid-transition detection simultaneously. We consider input sequences of the form “ ,” where .
Theorem 2. Given a DAG with adjacency matrix and reachability matrix , for every there is a 1-layer, 2-head Transformer with embedding size and feed-forward width that, for every input sequence “ ” for which is a valid path prefix, where , , and , generates with probability at least
the token , if , and
otherwise a node that is both an out-neighbour of and able to reach , whenever such a node exists.
Write and for the previous and current nodes. One attention head retrieves the target’s reachability row ; the other retrieves the previous node’s adjacency row . The residual connection returns the current node’s one-hot vector . Thus, at exactly one relevant FFN input blocks are , where denotes concatenation.
The FFN’s first linear map reads the current node’s adjacency row from , and thus the parameter becomes . Its first ReLU units use and compute , selecting out-neighbours of that can reach (if such nodes exist), as in the adjacency–reachability account of Wang et al. [15]. The other units combine with to check the preceding transition. For each node , a unit computes
Their output suppresses the abort logit when the preceding transition is valid (when the sum of detection units is 1), and otherwise do nothing, letting the abort logit be largest (when the sum of detection units is 0).
The detector uses units, while the complete FFN has width . Appendix § 10.§ 1 gives the detailed architecture and weights and shows that the logit separation persists with finite attention scores.
Remark 1 (Observed reachability and retry). Let when a training path ending at contains . Using instead of can affect next-node selection, but not invalid-transition detection. With exact checks of every transition (including the final one) and both endpoints, every accepted path is valid without a global ground-truth check. If independent, length-bounded attempts each succeed with fixed probability , retry succeeds within attempts with probability and terminates almost surely without a fixed budget. Thus, retry can overcome incomplete observed reachability (Wang et al. [15]).
How Much Capacity Does the Detector Require?
Suppose that the previous node , current node , and target node are represented at the FFN input by separate one-hot blocks, i.e., . A width- ReLU FFN computes . Let be the row blocks of acting on the three node inputs. The -th FFN unit receives
The FFN’s contribution to the abort logit is
Since transition validity depends only on , we can fix any target . Then is constant and can be absorbed into . Thus, for a fixed target, invalid-transition detection reduces to a width- ReLU network over the previous and current nodes.
Theorem 3. Suppose that a width- one-hidden-layer ReLU FFN receives the previous node , current node , and target as the input . If, for every DAG on nodes, there exist FFN parameters for which the sign of correctly determines whether for every , then
To prove the theorem, we bound the number of adjacency matrices representable by a width- network using the VC dimension of piecewise-linear networks (Bartlett et al. [3]) and the Sauer–Shelah lemma, and compare it with the DAGs obtained by choosing arbitrary forward edges under a fixed node ordering (Appendix § 10.§ 2). The detector in Theorem 2 uses ReLU units, matching this worst-case lower bound up to logarithmic factors in this class.
Mechanistic Analysis of Abort Supervision
In this section, we examine whether trained models implement the invalid-transition detection mechanism suggested by our theoretical analysis. We study previous-node attention and its causal role in the abort decision, then use direct logit attribution (DLA) to locate the abort signal. Additional analyses of learned adjacency and reachability representations are in Appendix § 11.§ 2. We compare baseline and x models with the 1/2/120 and 1/2/384 architectures. For each graph size and architecture, we train both conditions from scratch on five independently generated graphs (§ 3).
At the beginning, we check that these models can both find valid paths and recognise failures. The 1/2/384 +x models produce a valid path in more than 90% of single draws at every tested graph size, averaging over the five graphs at each size (Figure 2a). Their abort precision, the fraction of emitted aborts whose prefixes admit no valid completion, is 94–99% across these sizes (Appendix § 11.§ 1). For the causal interventions and DLA, we use six independently generated graphs, each with a trained 1/2/384 +x model. On held-out prefixes with an injected invalid transition, these models assign a mean probability of 99.7% to the abort token (Appendix § 11.§ 2). This strong abort response gives us a clear setting in which to study how the decision is made.

Figure 2. Graph domain over five seeds, each an independently drawn graph; solid is baseline, dashed +x; harness budget . (a) Single-shot validity. (b) Harness validity. (c) Composition of invalid outputs at for a single draw and for the harness output. (d) Mean draws per instance.
Previous-Node Information Drives the Abort Decision
We first test whether abort supervision increases attention to the previous node. For each model, we feed 3,000 correct held-out paths as fixed input sequences and average the attention weights over the two heads and over sequences containing each position. We measure attention on the previous node (key ) and the mean attention on the other intermediate emitted nodes (keys ). We average each quantity over , where this comparison set is nonempty, and take their ratio. A ratio of 1 means that the previous node receives the same attention as an average intermediate node. This ratio rises from 0.88 to 2.52 at (Figure 1), with an average paired increase of over five seeds and five graph sizes. At , the corresponding increase is .

Figure 1. Previous-node attention ratio over five seeds; shaded bands are s.e.
The above measurement uses only correct paths and therefore captures the model’s general tendency to look back. We then test whether attention depends on transition validity. On six graphs, the head with larger previous-node attention on injected invalid prefixes assigns 0.58 attention mass to the previous node after an invalid transition, compared with 0.17 after a valid transition.
We next test whether previous-node information causally affects the abort decision. We use the six , 1/2/384 +x models described above. For each graph, we take 2,000 held-out correct paths, cut each path at a random interior node , and append a node that is not a successor of . This produces an invalid prefix “”, and we measure at the position immediately after . We retain prefixes for which a previous-node replacement can make both adjacent transitions valid, so the interventions use the same set of prefixes.
| Intervention | |
| None | |
| Remove previous-node attention (main head) | |
| Remove previous-node attention (both heads) | |
| Swap previous node (valid prefix) | |
| Remove FFN output |
Table 1. Interventions after an injected invalid transition, on prefixes whose current node can still reach the target. Mean s.e. over six graphs.
Table 1 reports interventions on the subset of prefixes for which can still reach the target. For each graph, we call the head with more attention to the previous node on invalid prefixes the main head. Removing its attention to the previous node and renormalising lowers from 0.99 to 0.09, while removing previous-node attention from both heads lowers it to 0.008. We also change only the previous node. Specifically, we replace by a node such that and . The resulting prefix is valid and differs from the injected-invalid prefix only at the previous-node position. This change lowers to 0.001. Finally, we set the FFN output at the final position to zero before the residual addition, and then apply the final layer normalisation and unembedding as usual. This totally removes the abort response.
All rows of Table 1 are restricted to prefixes whose injected node can still reach the target. This avoids mixing invalid-transition detection with dead-end detection: after the previous-node swap, the prefix is valid and the target is still reachable, so the model no longer has a reason to abort. Appendix § 11.§ 2 gives the full protocol, controls, and uncertainty estimates.
Direct Logit Attribution Locates the Abort Signal in the FFN
The interventions above show that previous-node information causally affects the abort decision. We next take a closer look at where this information is converted into an abort signal, using direct logit attribution (DLA). Let be the sum of token and positional embeddings. For our one-layer Transformer, the residual stream before the final normalisation is
The first two terms contain the information retrieved by attention, while the last term is the output after this information passes through the nonlinear FFN. Here and are the layer normalisations before attention and before the FFN, respectively.
DLA measures how much each part directly contributes to the abort logit in the same forward pass. For example, let denote the FFN output. Its contribution is . All quantities here are evaluated at the final position: is the abort unembedding vector, is the final layer-normalisation scale vector, and includes the numerical stabiliser. Intuitively, this is the amount of abort logit that disappears if the FFN contribution is set to zero. It is an attribution, rather than rerunning the model with the FFN removed. We similarly compute the contribution before the FFN. Comparing these contributions between valid and invalid prefixes (as described in the last subsection) shows whether most of the valid–invalid separation is already written directly before the FFN or instead appears in the FFN output.
On target-reachable invalid prefixes, the direct contribution before the FFN changes little when the previous node is swapped to make the last transition valid (−0.68 to −1.15), while the FFN contribution drops from +29.6 to +1.5; the total abort logit falls from 29.0 to 0.3. Thus, little of the valid–invalid difference is written directly into the abort logit before the FFN; most of it appears in the FFN output. The same pattern holds for the abort margin, defined as the abort logit minus the largest node logit: the pre-FFN contribution changes from −1.0 to −1.7, while the FFN contribution changes from +22.4 to −10.2. Since the FFN receives only the pre-FFN residual stream, the information needed to distinguish the two prefixes must already be present there, but it is the FFN transforms it into a strong abort-versus-continue signal. This accords with our analysis, i.e., an additive score is not enough (), and the ReLU in FFN layer is critical for the abort signal. Appendix § 11.§ 2 gives the full decomposition, including the unit-level analysis.
Planning with the Learned Abort Signal
We now ask whether the learned abort signal improves planning. We evaluate graphs, Countdown, and mazes; Countdown and maze experiments use models. All models are trained for updates with batch size 1,024 and learning rate . As in § 3, correct trajectories receive standard next-token supervision, while error trajectories supervise only the final abort token. All results use sampling at temperature 1.
We use a simple restart harness with draw budget . If the +x model emits x, the current draw is rejected and generation restarts from the original prompt. Otherwise, the completed output is checked by a domain-specific acceptance test , which provides a second reason to reject a draw without checking full correctness. In graphs, requires at least two path-node tokens and a final node equal to the target, but does not check intermediate edges. In Countdown, it requires a nonempty, well-formed sequence of equations whose last stated result equals the target, without checking arithmetic or operand availability. In mazes, it accepts every non-aborting output. After any rejection, the model draws again until an output is accepted or the budget is exhausted. The baseline uses the same acceptance rule and budget, but has no learned abort signal.
We report three metrics: single-shot validity is the valid-output rate of one draw; harness validity is the rate at which the harness returns a valid output, counting exhausted budgets as failures; and mean draw count is averaged over all evaluation instances, with an exhausted budget counted as draws (Appendix § 11.§ 1).
Graph Path-Finding
Abort supervision can reduce single-shot validity, especially at smaller model size: at , the two models lose about 11 percentage points, whereas the loss for is at most 2.8 points across the tested sizes. With retry, however, the +x model has higher harness validity than the baseline at every graph size for (Figure 2b), reaching 98.9–99.7% compared with 95.0–98.3%. This gain requires only a small number of additional draws: averaged over all instances, the +x harness uses 1.03–1.09 draws per instance, compared with 1.01 for the baseline, an increase of only 0.02–0.08 draws (Figure 2d) in expectation.
Figure 2c shows how the learned abort signal changes the composition of invalid outputs. In a single draw, many errors that would otherwise appear as non-edge or wrong-end outputs are replaced by aborts. The harness then rejects these aborting draws and resamples, so many of these errors disappear from the returned output: the rate of returned outputs with an invalid transition falls from 2.4% for the baseline to 0.4% for +x at , and from 5.4% to 3.6% at . The gain persists when we match correct-trajectory exposure by doubling +x training updates (Appendix § 11.§ 3).
Countdown
In this dataset, three numbers must be combined with , , , to reach a target. Intermediate values and targets are restricted to 1–100. We enumerate all three-number multisets over 1–20 together with all targets reachable under these restrictions, giving 16,117 distinct instances, and hold out a disjoint tenth. A valid solution writes one equation per operation, : the two operands are removed from the available numbers and the result is inserted. Every operation must be correct, and the final result must equal the target.
To construct an error trajectory, we corrupt the result after one . For each trajectory, we choose one of two corruption types with equal probability: either adding or subtracting a small offset of magnitude 1–3, or replacing the result with a random value. Random replacements often produce obviously implausible results, whereas small offsets produce plausible-looking arithmetic errors that require checking the operation more carefully. Mixing the two reduces the chance that the model learns a shortcut based only on unusually large or small results. The corrupted equation is the invalid transition and is followed immediately by x; only this final x receives loss on the error trajectory. We denote by the ratio of error trajectories to correct trajectories.
At , the +x model improves harness validity by percentage points (Figure 3). This comes at a higher sampling cost: averaged over all instances, the +x harness uses 3.7 draws per instance, counting an exhausted budget of 100 in full, compared with 1.1 for the baseline. The +x harness fails on 51% of instances: it returns an output with incorrect arithmetic on 26% and one using an unavailable number on 24%, and it exhausts its budget without accepting an output on 1.2%. The baseline harness fails on 59% of instances (Figure 3c).

Figure 3. Countdown, 1/2/384, five seeds per . (a) Single-shot validity against , with the paired gain over the baseline. (b) Harness validity. (c) Composition of invalid outputs at for a single draw and for the harness output. (d) Mean draws per instance. In (a), (b) and (d) the baseline is a level band (mean s.e. over seeds) because its training data do not depend on .
We next vary the amount of abort supervision. Averaging repeated baseline runs within each seed gives a harness validity of over five seeds. The gain from +x increases monotonically from percentage points at to points at (Figure 3b). Abort supervision also improves single-shot validity, by percentage points at and points at (Figure 3a). This differs from the graph setting, where most of the harness gain comes from retrying after an abort. On Countdown, validity improves even before retry, suggesting that abort supervision may also improve representations used to generate valid equations.
Mazes
In a maze with random walls, the model starts facing East and emits relative-direction tokens: F moves forward, L and R turn left and right, and T turns around. Each token changes direction as needed and then advances one cell. For each of four independently generated mazes, we split reachable source–target pairs between training and test sets with probability each. Training uses correct paths and an equal number of error trajectories.
A valid output reaches the target without crossing a wall. Error trajectories contain one wall-crossing move followed by the supervised abort token. For mazes, the acceptance test accepts every non-aborting output. Thus, the harness retries only when the model emits x; wall crossings are checked only offline when computing validity.
Rejecting outputs that contain x and drawing again improves harness validity by percentage points (Figure 4). This requires 1.70 draws per instance on average for the +x harness, while the baseline always accepts its first draw. In single-shot generation, abort supervision reduces the wall-crossing rate from 22.5% to 9.4%, with some of these failures replaced by aborts. The harness retries aborting draws, reducing wall crossings in returned outputs from 22.5% for the baseline to 13.7% for +x. Wrong-end errors remain at 20–23%: neither the learned abort signal nor the acceptance test detects them (Figure 4a).

Figure 4. Maze task, 1/2/384, four independently generated mazes. (a) Composition of invalid outputs for a single draw and the harness output. (b) Harness validity per maze, averaged over two runs. (c) Mean draws per instance.
Conclusion
Error trajectories can teach a Transformer to detect invalid transitions by supervising only a final abort token. Our theoretical analysis characterises the required previous–current interaction and gives a one-layer construction in which attention retrieves information and the FFN checks transition validity. The width lower bound further characterises the capacity required within the specified readout class. In trained models, abort supervision increases previous-node attention, and the FFN produces most of the validity-dependent abort signal. Using this learned signal to reject and retry improves planning reliability on graphs, Countdown and mazes.
AI Use Statement
Generative artificial intelligence (AI) tools were used to assist with parts of the research and writing process. Claude (Anthropic) was used for code debugging and as an aid in literature search, while Claude and Codex (OpenAI) were used for limited drafting and editing of the manuscript. The research questions, problem formulation, theorem statements, proof strategies, experimental design, and interpretation of results were developed by the authors. The authors reviewed and verified all AI-assisted content and take responsibility for the final manuscript and accompanying artifacts.
Reproducibility Statement
Reproducibility details are provided in the paper and appendices. § 3 describes the architectures, training objective and graph data, and § 6 describes the Countdown and maze tasks and the retry procedure. Appendix § 11.§ 1 gives the training and evaluation protocols, Appendix § 11.§ 2 details the mechanistic analyses, and Appendices § 11.§ 3 and § 11.§ 4 report additional experiments, controls and method comparisons. Appendix § 10 provides the explicit Transformer construction and proofs. We will release the code publicly.
Theoretical Analysis
Appendix A.1 proves Theorem 2 and Appendix A.2 proves Theorem 3. We also checked auxiliary steps in Lean 4 using the Mathlib library: the ReLU identity (2) and its sum over nodes, the bounds on the errors caused by finite attention scores, the bounds on softmax probabilities, and the counting inequality used in Theorem 3. These checks cover individual lemmas rather than the complete Transformer construction; the attention-score calculation in §A.1 and the cited VC-dimension bound of Bartlett et al. [3] are not formalised. A numerical check builds the Transformer of Appendix A.1 from its weights at the constants of the proof and verifies both clauses, the dead-end case and the first step on random DAGs.
Construction and Proof of Theorem 2
We use the architecture of §3.1 and the notation of §4. The construction below has embedding size and feed-forward width , of which units form the detector.
Theorem 2. Given a DAG with adjacency matrix and reachability matrix , for every there is a 1-layer, 2-head Transformer with embedding size and feed-forward width that, for every input sequence “s t s u_1 \ldots u_k” for which is a valid path prefix, where , , and , generates with probability at least (i) the token x, if , and (ii) otherwise a node that is both an out-neighbour of and able to reach , whenever such a node exists.
Proof. Throughout the proofs, denotes the standard basis vector for coordinate , with dimension determined by the containing space. Layer normalisations are omitted, as in Wang et al. [15]. Write , with , for the token preceding , so clause (i) asks the model to detect . We first consider exact attention, with each head assigning unit weight to its intended position, then bound the effect of finite attention scores.
Embedding. Take tokens (the nodes, “\n”, x), per-head size and . Coordinates carry the one-hot token ( denotes the node coordinates), coordinate a flag set to a fixed on row 2 only, coordinates and the position and , and two disjoint blocks of coordinates in the second half hold the two head outputs. All other embedding coordinates are zero. Positions are numbered starting at 1, so the target occupies position 2. Thus row of is on the token coordinates, with the token at position , plus . Writing , every row has , which is how the model queries independent of and the DAG path has distinct nodes. The final node need not extend that path, so and the length satisfies . All constants below depend only on and .
Heads. For , Head 1 has query at every row (from ) and key at row , so after scaling its score at column is with . Its value projection is from the node coordinates into , so at exact attention it writes into . For , Head 2 uses key at row and query at row , with all remaining query and key coordinates zero. These are linear projections of the embeddings. After the standard scaling, the score is . At the final position , the first term is constant in , so under the causal mask the score is maximised at and every other column is lower by at least . Its value projection is from the node coordinates into , so at exact attention it writes the row into . places the two outputs in and and nothing in . Both value projections are zero on non-node token coordinates and on positional coordinates; all unspecified projection entries are zero. Thus, after the residual connection exactly.
Both heads have one column leading all others by a margin, and respectively, among at most columns; the softmax weight off that column is therefore at most and by the softmax bound used below.
Feed-forward network. Write and . At exact attention, the three blocks read by the FFN are
where denotes concatenation. The first linear map extracts the current node’s adjacency row from : its th entry is . We give two groups of columns. The entries of are on the first group and on the second, producing two groups of inputs to the ReLU activation:
All entries of not specified by these expressions are zero. Applying ReLU to both groups in parallel gives
Thus exactly for the out-neighbours of that can reach , for nodes with one of the two properties, and otherwise, as in the adjacency–reachability account of Wang et al. [15]; the planning inputs are non-negative, so their ReLU is the identity. The detection units implement (2): only can be nonzero, and . The current node’s adjacency row is thus read linearly, and the same ReLU layer implements the gate.
Choose . In , the output row for is , while the row for is ; set . The planning units write only to node coordinates, and the detection units write only to the abort coordinate. The abort logit is , hence on a non-edge and on an edge, independent of reachability. The feed-forward width is .
Output at exact attention. Choose to read the token coordinates. The vocabulary logits at row of are then
A DAG has , so a node logit is exactly when the node is an out-neighbour of that reaches , at most when it has one of the two properties, and at most otherwise. Writing for the set of desired output tokens, in clause (i) at against at most for every other token. In clause (ii), is the nonempty set of out-neighbours that can reach , each with logit , against at most for other nodes, for , and for . In both cases
because the respective gaps are at least and . If the most recent transition is valid but no out-neighbour can reach , the abort logit is still , below every non-abort logit. Taking to be all non-abort tokens then gives a gap of at least , so (5) also holds in this case. Thus even at a dead end, a valid preceding transition suppresses abort; the next-node guarantee applies only when an out-neighbour that can reach exists, as stated in clause (ii). At such a dead end the nodes with , namely the out-neighbours of and the nodes that can reach (a set that contains ), have logit at least , and every other node has logit at most . Taking to be this set gives a gap of at least , so the model samples from this narrower set.
Finite attention scores. Two FFN groups must be considered. The planning group reads , a convex combination of rows of that puts weight at most off the row . The adjacency input is exact, and ReLU cannot increase the difference between the inputs, so the node logits change by at most . This group has no effect on the abort logit. The detection group reads exactly and as a convex combination of rows of , so unit sees some in place of , with . For the argument is non-positive and the unit stays at ; for the unit equals . Through its output row this moves only the logit, by at most . Together, these deviations bound every logit change by
Taking
gives , so every logit is within of (4) and the gap is still at least . The softmax probability assigned outside the desired set is at most , which is at most once . So and the two attention-score bounds above give the theorem, with and . The same bound with equal to all non-abort tokens shows after a valid transition into a dead end. At finite attention the abort logit is exactly and still has no reachability input. Its softmax probability shares a denominator with the node logits, but whether abort is the highest-logit token is determined by transition validity under the bounds above.
Boundary cases. The theorem concerns positions after at least one generated transition and before the current node equals the target. It does not specify the initial prediction of from “ ” or the end-of-line prediction after reaching . At the first step, and the input is “ ”. Head 2 then attends to position 2, so the detector reads the pair , which is not a transition of the path, and because in a DAG; as constructed, the model would emit x. One further value map covers this step without changing or : head 2 also copies the flag coordinate into the abort coordinate with weight . At , head 2 places weight at least on position 2, so the abort logit is at most , while the planning units select an out-neighbour of that reaches , as in clause (ii). At later positions the map lowers the abort logit by at most ; taking in place of keeps the total change of the abort logit at most , so the bounds above are unchanged.
The case analysis uses only that the reachability matrix has entries in . It therefore also holds with in place of , the setting of Remark 1. Detection is unchanged. After a valid transition, or at the first step, if no out-neighbour of the current node is observed to reach , the model outputs with probability at least an out-neighbour of the current node or a node observed to reach , provided this set is nonempty.
Lower Bound on FFN Width
We prove Theorem 3 in the setting of §4.3: the FFN input is with , and the FFN’s contribution to the abort logit is (3).
Scalar form and fixed target. With the row blocks of from §4.3, let be the weight with which unit enters the abort logit and . Because each block of is one-hot, (3) is the scalar ReLU network
We take to mean “invalid”; the argument is identical under the opposite convention. Fix a target and absorb into the bias, , giving
Let be the class of Boolean functions on , with , and arbitrary. An FFN that is correct for every target must also be correct for this fixed target. Its decision rule belongs to , so a lower bound for this class also applies when the FFN receives the target as an input.
Theorem 3. Suppose that a width- one-hidden-layer ReLU FFN receives the previous node , current node , and target as the input . If, for every DAG on nodes, there exist FFN parameters for which the sign of correctly determines whether for every , then .
Proof. Fix and let be the class defined above. The proof compares how many labellings of the class can induce with how many it must induce.
Step 1: number of parameters. A member of is specified by the entries of and , the entries each of and , and . Hence
since is equivalent to .
Step 2: VC dimension. contains the binary decisions obtained by thresholding a one-hidden-layer ReLU network with real parameters, evaluated on the finite input set . The Vapnik–Chervonenkis (VC) dimension is the largest number of inputs on which a function class can realise every binary labelling. The VC dimension of the sign of a piecewise-linear network with parameters and a constant number of layers is at most for an absolute constant [3]; restricting the domain cannot increase it. By Step 1 and monotonicity of ,
Step 3: how many labellings can induce. The domain has points. By the Sauer–Shelah lemma, a class of VC dimension induces at most distinct labellings of an -point set. Thus the number induced by on satisfies
Step 4: how many labellings it must induce. Fix the node ordering and consider the graphs whose edges all go from a smaller index to a larger index. Every subset of the pairs is such a graph, and each is a DAG because its edges follow a fixed topological order. Distinct subsets have distinct adjacency matrices, so there are distinct adjacency relations. By hypothesis each of these DAGs is detected by some FFN, and by the fixed-target reduction the restriction of that FFN’s decision rule to is a member of whose labelling of is the indicator of the non-edges of that DAG. Distinct DAGs give distinct labellings, so
Conclusion. Combining (9) and (10) and taking base-two logarithms,
With (8) this gives , that is,
If , the claimed asymptotic lower bound already holds. Otherwise , so , and dividing the display by gives . In either case .
Matching upper bound. The detector of Theorem 2 lies in this class with . Setting , , , , and , unit computes (2) and , which is positive exactly on non-edges. In the Transformer of Appendix A.1 the map is supplied by head 2; here it is absorbed into . Width therefore suffices for every DAG, and Theorem 3 shows that this is optimal up to a factor .
Experimental Details and Extended Results
Setup and Evaluation Details
Training objective. The trained models apply layer normalisation before attention, before the FFN and before unembedding. Let be the training set. For each sequence , the supervision mask marks which tokens receive a loss:
Correct trajectories supervise every non-padding next token after the first; an error trajectory , with when , supervises only the final x. Minibatch losses are averaged over supervised labels.
Graph data. The distinct non-edges used in the error trajectories cover 82–93% of all non-edges, more at larger . The +x data sets range from 67,000 sequences (2.1 million padded token slots) at to 2.49 million sequences (79.6 million slots) at . On the data, of the positions supervised to emit x also end at a node from which the target is unreachable, so the abort label is not a dead-end label. A correct trajectory carries 6.1 supervised labels on average at and 8.1 at , whereas an error trajectory carries one; with half of each +x batch made of error trajectories, the +x model sees 0.50× the baseline’s correct trajectories per update in expectation (measured at , 300 and 500). This is a ratio of trajectory counts, not a ratio of loss weights. Appendix § 11.§ 3 doubles +x updates to match correct-trajectory exposure.
Output classification. Prompted with , the model emits tokens until end-of-line or, for a +x model, the abort token, subject to the generation-length limit. An output is valid if it is a path from to containing only graph edges, and invalid otherwise. Invalid outputs are classified in the evaluator’s order as abort (it contains x), syntax (too few node tokens), wrong-end ( or for the output ) or non-edge (correct endpoints but some ). Every output containing x counts as abort, whether or not the abort is justified, including one whose last transition before x is a non-edge; a wrong-end output may also contain a non-edge.
Evaluation, abort precision and selective accuracy. Harness results use 3,000 instances drawn with replacement from the held-out set, with , in all three domains of § 6. Graph single-shot validity is evaluated on every held-out instance, the Countdown single-shot results use the same 3,000 instances as the harness, and the maze results average two independent sampling runs per maze. An abort emitted after a prefix is
and abort precision is the fraction of emitted aborts that are justified. In the graph domain a prefix admits a valid completion exactly when it starts at , follows edges and ends at a node that can reach , which we check exhaustively on . For the fitted models of Appendix § 11.§ 2, we instead report the fraction of total abort probability assigned to prefixes that admit a valid completion.
We also compare aborting with rejecting outputs that have low mean token log-probability. Coverage is the fraction of instances whose outputs are retained; selective accuracy is the fraction of those retained outputs that are valid. For +x, we retain every non-aborting output. For the baseline, we discard the lowest-scoring outputs until the same fraction is retained. These measurements use one draw per instance, without retry.
Compute. Graph models are trained in bfloat16 on one NVIDIA H200 GPU. The two architectures have the same 0.2 million parameters, because increasing the head count divides the same embedding size among more heads; the model has about 1.9 million.
Additional Mechanistic Results
Interventions on previous-node attention and the FFN. The interventions of § 5.1 use the 1/2/384 +x models of six graphs: the five evaluation seeds and the graph of Figure 6. For each graph, we take 2,000 held-out valid prefixes for which a previous-node swap exists, append a non-successor node and measure at the next position. Removing attention to a position sets its weight at the final query to zero and renormalises the remaining weights; the main head is the head with more previous-node attention on invalid prefixes. Removing the FFN output sets it to zero before the residual addition. Means s.e. are over graphs.

Figure 6. Average per-head attention for baseline and +x models, 1/2/384 at . One representative seed is shown because head identities can swap across runs.
Table 2 adds controls and the full sample to Table 1. On target-reachable prefixes, removing target or current-node attention leaves at 0.911 or 0.997, and removing previous-node attention in the other head leaves it at 0.861, so the effect is specific to previous-node attention, mostly in the main head. On the other of prefixes the appended node cannot reach the target, so an abort remains justified after the swap; the model still aborts there with mean probability , which keeps the all-prefix column near 0.6. On valid prefixes, removing previous-node attention in both heads makes on only of prefixes.
| condition | all prefixes | target reachable |
| invalid prefix, no intervention | ||
| remove previous-node attention, main head | ||
| remove previous-node attention, other head | ||
| remove previous-node attention, both heads | ||
| remove target attention, both heads | ||
| remove current-node attention, both heads | ||
| drop the FFN output | ||
| swap the previous node (last transition valid) | ||
| patch attention output from the valid swap | ||
| valid prefix |
Table 2. Interventions after an injected invalid transition, six graphs: mean s.e. over all prefixes and over those whose target remains reachable. Removing target or current-node attention, and the valid prefix, are controls.
As a consistency check, we also copy the complete attention output at the final position between the invalid and swapped prefixes. Because the model has only one layer, the final token and its positional embedding are identical in the two prefixes, and the attention output is the only component at that position that depends on the earlier tokens before the FFN. The patched prefix therefore gives the same abort decision as the corresponding swapped input. On target-reachable prefixes, copying the swapped prefix’s attention output into the invalid prefix gives , as does the previous-node swap itself (Table 2). This checks the intervention implementation rather than providing an independent test of the mechanism.
Direct logit attribution. At the final position, write the residual stream before the final layer normalisation as , where is the stream entering the FFN and is the FFN output, as in § 5.2. With zero column sum of and the scale of the final layer normalisation, which has no bias, the abort logit is , where includes the numerical stabiliser. Centring is linear and is a single scalar for the forward pass, so the logit splits exactly into with
For the abort margin, replace by , where is the node with the highest logit on that prefix. The trained FFN has no output bias, so , with the activation of unit , and the same formula gives each unit’s contribution. Table 3 reports these quantities on the prefixes of Table 2.
| Prefix | Abort logit | to abort logit: pre-FFN | to abort logit: FFN | to margin: pre-FFN | to margin: FFN |
| valid continuation | 3.0 | ||||
| swap-valid, target reachable | 0.3 | ||||
| invalid, target reachable | 29.0 | ||||
| invalid, target unreachable | 28.8 |
Table 3. Direct logit attribution at the abort position, means over six graphs (s.e. at most 0.4). Contributions of the pre-FFN stream and FFN output to the abort logit and margin (abort logit minus highest node logit); “swap-valid” swaps the previous node to make the last transition valid.
The pre-FFN contribution stays near in all four conditions, including the valid continuation and the target-unreachable invalid prefixes. On valid prefixes the FFN’s contribution to the abort logit is positive on 90% of prefixes, while its margin contribution is : it raises the highest node logit more than the abort logit. This polarity is the reverse of the construction in Appendix § 10.§ 1, where a constant abort bias is cancelled by units that fire after a valid transition. In the trained models the ten units with the most negative contributions on valid prefixes sum to only there, and to on invalid prefixes. A detection unit ReLU which fires after an invalid transition, implements the same check with the same width when its output weight is and the abort bias is . Most of the FFN contribution on invalid prefixes comes from a small set of units: 16 units exceed 0.25 when the target remains reachable (22 when it does not), the ten largest carry 63–87% of the FFN contribution, and 16 (31) units reach 90% of it.
Additive fits. Could the supervised abort decision be reproduced by separate additive contributions of the previous node , current node and target ? We fit, to the supervised training labels of the graph of Figure 6 rather than to the trained model, the additive-logit model
where is a candidate output token and , , are free matrices: a linear readout of three one-hot inputs with no term depending jointly on and . This is the form computed by a fixed-attention Transformer in which two heads copy the target and previous-node representations, the residual supplies the current node, and the remaining maps are linear. With it is the additive model of Wang et al. [15], which gives every prefix with the same the same next-token distribution. The abort probability of (13) is a softmax over all candidate logits rather than a thresholded additive score, so Proposition 1 does not apply directly; we test the fit empirically.
The fit uses every supervised position whose prefix ends at or at a later node, 2,784,440 positions grouped by : 425,002 follow an invalid transition, and the rest come from correct trajectories and all admit a valid completion. The logits are linear in the fitted matrices, so the objective is convex; Adam followed by L-BFGS reaches for the loss averaged over these positions. Let be the multiset of these prefixes and those admitting a valid completion (source-only prefixes, for which the fit sets , belong to ). The unjustified-abort mass fraction is the share of total abort probability placed on prefixes that could still be completed correctly; we also report the mean over . For the fit these two percentages sum to 100%, because at a stationary point of the objective the total abort probability equals the number of abort labels; this need not hold for the trained Transformer.
The fit also assigns about 8% abort probability after a valid transition, against 0.01% for the trained model (Table 4). Separate additive contributions therefore do not reproduce the learned rejection quality even with the previous node available.
| Model | Mean after an invalid transition | Unjustified-abort mass fraction |
| Additive (13) | 56.6% | 43.4% |
| Trained, same positions | 99.9% | 0.03% |
Table 4. The previous-node additive fit against the trained 1/2/384 Transformer on the same 2.78 million supervised positions of one graph.
Planning representations and attention heads. We examine planning information with two probes adapted from Wang et al. [15]. Let be the value map of the attention layer when both heads place all their attention on the target position, and let be the one-hot vector of node . The probes are
with . The first probe passes the current-node embedding through the FFN with its residual connection and probes adjacency information associated with the current node; the second does the same for the target embedding after the value map and probes reachability information associated with the target. Here FFN is the trained GELU map, and positional embeddings and layer normalisations are omitted, following Wang et al. [15]. Because the FFN is nonlinear, the probes are diagnostics of the learned weights, not decompositions of the actual logits; primes distinguish them from the fitted matrices of (13).
At the end of training, the edge/non-edge gap of the +x models is slightly above the baselines’ at both sizes, 0.119 against 0.110 at and 0.220 against 0.202 at (Figure 5a). The gap compares edges and non-edges among forward pairs in the graph’s node ordering. This is consistent with error trajectories providing additional adjacency supervision.

Figure 5. Planning representation probes over five seeds; shaded bands are s.e. (a) Edge–non-edge gap in at . (b) by reachability group in baseline models. Architecture colours match (a).
For reachability, a pair is observed reachable if , with as in Remark 1, unobserved reachable if but , and unreachable if . Figure 5b shows mean values over for these groups in the two-head baseline models. The observed-reachable minus unobserved-reachable gap is positive across all three architectures and five graph sizes, and the unobserved-reachable minus unreachable gap is larger in 13 of these 15 configurations, so carries some information about true reachability beyond the observed pairs, with additional separation for observed pairs.

Figure 5a. edge/non-edge gap, . by reachability class.
At 1/2/384 one head attends to the target and the other to the current position in all five seeds, for both baseline and +x models (Figure 6); which head takes which role varies between runs.
Additional Graph Planning Results
Single-shot validity and model size. Abort supervision leaves single-shot validity unchanged at for all three architectures. It lowers it for the models by and $2.5 \pm 0.3 percentage points at (one and two heads) and by and points at ; at the change is within the error bars at and between and points from on (Figure 2a). The cost is larger for the models, whose abort precision is also lower (68–94%, against 94–99% at ). The difference is associated with embedding size rather than head count: 1/2/120 tracks 1/1/120 within about one point at the same parameter count, which is why § 5 uses the two-head models.
Matched correct-trajectory supervision. Because half of the trajectories in a batch carry a single label, the model receives half the baseline’s correct-trajectory supervision per update (§B.1). We therefore also train both 1/2/384 models for 20,000 updates on the graph of Figure 6, after which the model has seen the correct-trajectory supervision the baseline receives in 10,000. Harness validity in percent on that graph:
| updates | baseline + retry | +x + retry | gain |
| 10,000 (the setting used throughout) | 97.6 | 99.6 | +2.0 |
| 20,000 | 96.9 | 99.6 | +2.7 |
Table 1 (PDF p. 21).
At matched correct-trajectory exposure, the 20,000-update model exceeds the 10,000-update baseline by 2.0 percentage points. The longer-trained baseline is slightly worse, its invalid-transition rate rising from 2.4% to 3.1%.
Additional Tasks and Method Comparisons
A pretrained model on Blocksworld. The three domains above use one-layer models trained from scratch. We also evaluate abort supervision on a pretrained language model, Qwen3-0.6B-Base, on Blocksworld with 8 or 9 blocks. A move takes an uncovered block and places it on the table or on another uncovered block. The prompt gives the initial and goal configurations as stacks; the model writes one move per line (move A onto B, move A onto table) and then done, and never restates the state. Each instance is an initial–goal pair whose shortest solution, found by breadth-first search from the goal, has 4–15 moves. Of 300 goals (150 per block count), 255 are training goals with 40 initial states each, giving 10,200 plans; 45 are held-out goals with 60 initial states each, and evaluation uses 2,000 of these 2,700 instances. Error trajectories take a valid prefix of a training plan, append one invalid move (moving a buried block, moving onto a buried block, or a no-op) and a new token <|abort|> playing the role of , with the loss on that token only; . Both models are fine-tuned for 3 epochs (learning rate , batch size 64) on one NVIDIA A100 GPU; because the training set is nine times as large, it receives nine times as many updates, and a second baseline trained for 27 epochs matches its update count. The harness draws at most plans per instance at temperature 1 and accepts the first that does not abort and ends with done; it does not check moves or the final state, and validity is scored by simulation.
Retrying on the abort raises harness validity from to , a gain of percentage points at 1.10 draws per instance, and of points over the baseline trained for the same number of updates. Illegal moves account for most invalid outputs in every arm: they appear in 26.7% of the outputs returned by the baseline harness, 8.9% for the matched-steps baseline and 5.9% for the +x harness (Figure 7b). At the coverage of the +x model, 93.1% of instances, its selective accuracy is 94.1%, against 75.1% for a mean-log-probability threshold on the baseline and 88.4% on the matched-steps baseline.

Figure 7. Blocksworld, Qwen3-0.6B-Base; mean s.e. over three seeds. (a) Validity for a single draw and under the harness. (b) Invalid outputs for a single draw and for the harness output. (c) Mean draws per instance.
Self-Backtracking on Countdown. We adapt Self-Backtracking [17] to the same error trajectories as +x. Its loss supervises the correct prefix and a backtrack token after the invalid step, masking only that step. Training otherwise matches the Countdown runs of § 6: the same model, split, error trajectories at , 10,000 updates, optimiser and five seeds, and the backtrack token uses the same vocabulary entry as the abort token. The baseline and +x models are the models of § 6, evaluated on the same 3,000 test instances with fresh samples, so their single-shot validity differs slightly from the values there.
At inference, Self-Backtracking first samples trajectories and keeps completed outputs without a backtrack token as candidates. For outputs that emit the token, it removes the last equation and selects up to distinct shortened prefixes. It then samples continuations from each selected prefix. This is one round of backtracking, denoted . The likelihood selection rule returns the candidate with the highest mean token log-probability. We also evaluate the harness rule of § 6, which selects the first candidate whose last written value is the target.
For each instance, the output-token count used by Self-Backtracking at a given sets a hard budget for baseline and +x restart. A final restart draw that would exceed this budget is truncated and discarded. We also exchange the inference procedures to separate their effect from the training loss: the Self-Backtracking model uses restart under the same token budget, and the +x model uses backtracking with the same . The latter has similar, but not identical, token counts. All combinations are evaluated under both selection rules; the resource comparison concerns generated output tokens, not wall-clock time.
Figure 8 shows the results. Single-shot validity rises by +2.1 ± 0.5 percentage points for +x and by +0.3 ± 0.7 for Self-Backtracking. Under the likelihood rule at (about 470 tokens per instance) the baseline reaches 43.1 ± 0.8%, Self-Backtracking 49.3 ± 0.7% and +x 51.5 ± 0.8%. The paired difference between +x and Self-Backtracking is +2.0 to +2.2 points at every budget from on and positive on every seed, and +1.7 to +2.3 points under the harness rule (+0.7 ± 0.7 and +0.8 ± 0.9 at ). Exchanging inference procedures suggests that the loss accounts for most of the difference in this setting: at , the +x model with backtracking reaches 51.6 ± 0.9%, and the Self-Backtracking model with restart reaches 49.3 ± 0.7%, close to their results with the original procedures. One round of backtracking adds 0.3 to 1.6 points over selecting from the same initial samples without backtracking (). We also evaluate the released-code variant, which expands only one shortened prefix and does not expand it if no equations remain, and a temperature-0.7 variant. Both are shown in the figure and perform at or below the rule at temperature 1 under likelihood selection.

Figure 8. Countdown, five seeds, mean ± s.e. (a), (b) Final validity against output tokens per instance under the likelihood and harness selection rules; budgets are set by Self-Backtracking at . Dashed orange and dash-dotted green exchange the inference procedures. (c) Single-shot validity.
References
- [1]William H Alexander and Joshua W Brown. Computational models of performance monitoring and cognitive control. Topics in cognitive science, 2(4):658–677, 2010.pubmed.ncbi.nlm.nih.gov/21359126
- [2]Daman Arora and Subbarao Kambhampati. Learning and leveraging verifiers to improve planning capabilities of pre-trained language models. arXiv preprint arXiv:2305.17077, 2023.arxiv.org/abs/2305.17077
- [3]Peter L Bartlett, Nick Harvey, Christopher Liaw, and Abbas Mehrabian. Nearly-tight vc-dimension and pseudodimension bounds for piecewise linear neural networks. Journal of Machine Learning Research, 20(63):1–17, 2019.
- [4]Edoardo Botta, Yuchen Li, Aashay Mehta, Jordan T Ash, Cyril Zhang, and Andrej Risteski. On the query complexity of verifier-assisted language generation. arXiv preprint arXiv:2502.12123, 2025.arxiv.org/abs/2502.12123
- [5]Tom Bylander. The computational complexity of propositional strips planning. Artificial Intelligence, 69(1-2):165–204, 1994.DOI
- [6]Yu-Neng Chuang, Prathusha Kameswara Sarma, Parikshit Gopalan, John Boccio, Sara Bolouki, Xia Hu, and Helen Zhou. Learning to route llms with confidence tokens. arXiv preprint arXiv:2410.13284, 2024.arxiv.org/abs/2410.13284
- [7]Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, et al. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.arxiv.org/abs/2110.14168
- [8]Zhongzheng Fu, Amirsaman Sajad, Steven P Errington, Jeffrey D Schall, and Ueli Rutishauser. Neurophysiological mechanisms of error monitoring in human and non-human primates. Nature Reviews Neuroscience, 24(3):153–172, 2023.DOI
- [9]Kanishk Gandhi, Denise Lee, Gabriel Grand, Muxin Liu, Winson Cheng, Archit Sharma, and Noah D Goodman. Stream of search (sos): Learning to search in language. arXiv preprint arXiv:2404.03683, 2024.arxiv.org/abs/2404.03683
- [10]Sukai Huang, Trevor Cohn, and Nir Lipovetzky. Chasing progress, not perfection: Revisiting strategies for end-to-end llm plan generation. In Proceedings of the International Conference on Automated Planning and Scheduling, volume 35, pp. 204–212, 2025.arxiv.org/abs/2412.10675
- [11]Lucas Lehnert, Sainbayar Sukhbaatar, DiJia Su, Qinqing Zheng, Paul McVay, Michael Rabbat, and Yuandong Tian. Beyond a*: Better planning with transformers via search dynamics bootstrapping. arXiv preprint arXiv:2402.14083, 2024.arxiv.org/abs/2402.14083
- [12]Hunter Lightman, Vineet Kosaraju, Yuri Burda, Harrison Edwards, Bowen Baker, Teddy Lee, Jan Leike, John Schulman, Ilya Sutskever, and Karl Cobbe. Let’s verify step by step. In International Conference on Learning Representations, volume 2024, pp. 39578–39601, 2024.arxiv.org/abs/2305.20050
- [13]Yin Jun Phua, Tony Ribeiro, Tuan Nguyen, and Katsumi Inoue. Can transformers learn to verify during backtracking search? arXiv preprint arXiv:2605.22221, 2026.arxiv.org/abs/2605.22221
- [14]Dhruv Rohatgi, Abhishek Shetty, Donya Saless, Yuchen Li, Ankur Moitra, Andrej Risteski, and Dylan Foster. Taming imperfect process verifiers: A sampling perspective on backtracking. In International Conference on Learning Representations, volume 2026, pp. 128647–128722, 2026.arxiv.org/abs/2510.03149
- [15]Siwei Wang, Yifei Shen, Shi Feng, Haoran Sun, Shang-Hua Teng, and Wei Chen. Alpine: Unveiling the planning capability of autoregressive learning in language models. Advances in neural information processing systems, 37:119662–119688, 2024.arxiv.org/abs/2405.09220
- [16]Siwei Wang, Yifei Shen, Haoran Sun, Shi Feng, Shang-Hua Teng, Li Dong, Yaru Hao, and Wei Chen. Benefits and pitfalls of reinforcement learning for language model planning: a theoretical perspective. In International Conference on Learning Representations, volume 2026, pp. 677–701, 2026.arxiv.org/abs/2509.22613
- [17]Xiao-Wen Yang, Xuan-Yi Zhu, Ding-Chu Zhang, Wen-Da Wei, Jie-Jing Shao, Zhi Zhou, Lan-Zhe Guo, and Yu-Feng Li. Step back to leap forward: Self-backtracking for symbolic reasoning and planning in language models. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 40, pp. 27657–27665, 2026.DOI
- [18]Qimin Zhong, Hao Liao, Siwei Wang, Mingyang Zhou, Xiaoqian Wu, Rui Mao, and Wei Chen. Understanding and enhancing the planning capability of language models via multi-token prediction. arXiv preprint arXiv:2509.23186, 2025.arxiv.org/abs/2509.23186