---
title: Energy-guided Recursive Model (ERM)
url: https://www.emergentmind.com/topics/energy-guided-recursive-model-erm
type: topic
---

# Energy-guided Recursive Model (ERM)

Energy-guided Recursive Model (ERM) is an inference-time framework for recursive reasoning in which selection among multiple latent trajectories is posed as explicit energy minimization rather than as heuristic voting, token confidence, or auxiliary q-head scoring. In the formulation introduced under the title “Energy-guided Recursive Model,” ERM assigns each decoded candidate a Hopfield-style energy that measures compatibility with task-specific local and global structures, and then returns the minimum-energy trajectory. The same energy also induces a tempered distribution that can be used with parallel tempering for exploration and ranking. On Sudoku, Pencil Puzzle Bench (PPBench), and Maze, ERM is reported to improve selection under a fixed rollout budget of recurrent depth $D=64$ and breadth $K=128$, reaching $98.97\%$, $88.04\%$, and $99.30\%$ optimal-solution rates, respectively [2607.10128].

## 1. Definition and problem setting

ERM addresses what the paper terms the **selection gap in test-time scaling**: recursive reasoners can generate more candidate trajectories by increasing recurrent depth $D$ or stochastic breadth $K$, but existing selection mechanisms often remain heuristic. Majority voting, token confidence, and learned q-heads may correlate with local certainty while failing to capture global correctness, particularly on tasks whose validity depends on structured constraints such as connectivity or permutation consistency [2607.10128].

The framework assumes a small neural network $f_\theta$ that recursively updates a latent state,
$$
s_{t+1} = f_\theta(s_t, x, \xi_t),
$$
where $x$ is the input instance, $t \in \{0,1,\dots,D\}$ indexes recurrent steps, and $\xi_t$ introduces stochasticity that creates breadth. A decoder $g$ maps the final latent state to a structured output $y \in \mathcal{Y}$. From $K$ rollouts, the model obtains a candidate pool
$$
y(x) = \{y_1,\dots,y_K\}, \qquad y_k = g(s_D^{(k)}).
$$
ERM then defines a scalar compatibility score $E(y_k;x)$ and selects
$$
y^* = y_{k^*}, \qquad k^* = \arg\min_{k \in \{1,\dots,K\}} E(y_k;x).
$$
This makes the final decision a task-aware energy minimization problem rather than a post hoc heuristic [2607.10128].

The energy is built from **task-derived memories** rather than learned verification heads. A task is decomposed into factors $j=1,\dots,J$, and each factor has an input-conditioned memory set $\mathcal{M}_j(x)$ containing valid local or global patterns. These memories are not trained in the main ERM experiments; they are constructed from task rules [2607.10128].

## 2. Hopfield-style energy formulation

ERM is explicitly derived from **Modern Hopfield retrieval energy**. The paper recalls the classical Hopfield energy
$$
E_{\text{classic}}(s) = -\frac{1}{2}s^\top W s + b^\top s,
$$
and the modern retrieval energy over a query $q$ and memory set $\mathcal{M}$,
$$
E_{\text{MHN}}(q;\mathcal{M}) = \alpha \|q\|_2^2 - \tau \log \sum_{m \in \mathcal{M}} \exp(\operatorname{sim}(q,m)/\tau),
$$
where $\tau>0$ is a retrieval temperature. Low $\tau$ approximates nearest-memory retrieval [2607.10128].

ERM adapts this principle from continuous retrieval to candidate selection over decoded outputs. Its general energy is
$$
E_{\text{ERM}}(y_k;x) = \mu G(y_k,x) - \sum_{j=1}^{J} \tau \log \sum_{m \in \mathcal{M}_j(x)} \exp\!\left(-\beta d_j(y_k,m)/\tau\right),
$$
where:

- $d_j(y_k,m)\ge 0$ is a factor-specific distance between candidate $y_k$ and memory $m$;
- $\beta>0$ scales memory distance;
- $\tau>0$ controls sharpness of retrieval;
- $G(y_k,x)$ is a global rule-violation score;
- $\mu\ge 0$ weights the global term [2607.10128].

The factorized form can also be written as
$$
E_{\text{local}}(y_k;x) = - \sum_{j=1}^{J} \tau \log \sum_{m \in \mathcal{M}_j(x)} \exp\!\left(-\beta d_j(y_k,m)/\tau\right),
$$
$$
E_{\text{global}}(y_k;x) = G(y_k,x),
$$
$$
E_{\text{total}}(y_k;x) = \lambda_{\text{local}} E_{\text{local}} + \lambda_{\text{global}} E_{\text{global}},
$$
with $\lambda_{\text{local}}=1$ and $\lambda_{\text{global}}=\mu$ in the paper’s Equation (3) [2607.10128].

The authors state that this construction **subsumes confidence and hard verification as special cases**. A one-cell factor with memories equal to labels recovers nearest-label behavior, while a single complete memory $m^*(x)$ yields energy proportional to distance from a fully specified verifier [2607.10128]. This suggests that ERM is not merely an alternative selector, but a more general compatibility formalism in which standard confidence-based rules appear as degenerate cases.

## 3. Inference mechanism and energy-based sampling

ERM is an **inference-time method**. In the main experiments, the base reasoner is an EqR checkpoint that generates candidate trajectories through depth-$D$ recurrent computation; no additional ERM training is performed. Memory sets and global penalties are defined directly from task rules. The appendix includes a training-side energy-transformer variant on Sudoku, but the paper identifies that as motivation rather than the main focus [2607.10128].

The reported test-time procedure for $D=64$ and $K=128$ has four stages:

1. **Candidate generation**: run $K$ stochastic rollouts of the recursive reasoner to obtain decoded candidates $y_1,\dots,y_K$.
2. **Energy evaluation**: compute $E_{\text{ERM}}(y_k;x)$ for each candidate.
3. **Selection without parallel tempering**: return the lowest-energy candidate.
4. **Optional parallel tempering**: sample and swap candidates across a temperature ladder, then return the lowest-energy candidate among replicas [2607.10128].

A diagnostic extension tracks per-step energies $E(y_k^{(t)};x)$ and may aggregate them as
$$
\hat{E}(y_k;x)=\sum_{t=1}^{D} w_t E(y_k^{(t)};x), \qquad w_t\ge 0,
$$
but the reported results select using the **final-step energy** rather than a trajectory-aggregated score [2607.10128].

The same scalar energy defines a tempered distribution
$$
p_T(y\mid x)\propto \exp(-E(y;x)/T), \qquad T>0,
$$
which enables **parallel tempering (PT)**. With replicas at temperatures $\{T_1<\dots<T_R\}$, ERM periodically proposes swaps between neighboring temperatures with acceptance probability
$$
A((y_i,T_i),(y_j,T_j)) = \min\!\left(1,\exp\!\left((1/T_i-1/T_j)\,[E(y_j;x)-E(y_i;x)]\right)\right).
$$
The paper interprets this as allowing hot chains to explore broadly while cold chains exploit low-energy basins, with swaps transmitting promising candidates discovered at higher temperature to lower-temperature replicas [2607.10128].

A common misunderstanding is to view ERM as primarily a sampling algorithm. In the reported system, PT is optional. The core method is the explicit energy selector itself; PT uses the same energy for improved exploration when needed [2607.10128].

## 4. Task-specific energies and representations

The paper instantiates ERM on three structured reasoning domains, each with a different memory design.

### Sudoku

For 9×9 Sudoku-Lite, each candidate is a grid assignment over digits $1,\dots,9$. If $L_k[i,d]$ denotes the base model’s log-probability that cell $i$ has digit $d$, then for each structural unit $u$ (row, column, or box), the memory set $M_u$ contains all $9!$ permutation matrices enforcing “each digit appears exactly once.” The unit score is
$$
S_u(k)=\tau \log \sum_{\sigma \in S_9} \exp\!\left(\frac{1}{\tau}\sum_{r=1}^{9} L_k[i_r,\sigma(r)]\right),
$$
where $(i_1,\dots,i_9)$ are the cells in unit $u$. This log-sum-exp over permutations is evaluated exactly via dynamic programming, described as **log-permanent** computation. The Sudoku energy is then
$$
E_{\text{Sudoku}}(y_k;x) = -\sum_u S_u(k),
$$
with clue cells clamped to the provided digits [2607.10128].

### Pencil Puzzle Bench

PPBench contains heterogeneous puzzle types with enumerable local patterns and global constraints. The paper lists several examples: Lightup uses numbered-clue exact-count memories and line-of-sight at-most-one-bulb memories; Tapa uses cyclic run-pattern memories around clues; Heyawake uses room-count and adjacency memories; Nurikabe uses no-2×2-sea memories and island/sea potentials; and a Sudoku subset reuses permutation memories. Local energies are defined through distances to valid pattern memories using normalized Hamming distance inside the log-sum-exp term. Global energy $G(y_k,x)$ captures connectivity and coverage violations, since enumerating all fully global valid boards is intractable. The reported configuration is $\gamma=0$, $\beta=128$, and $\mu=64$ [2607.10128].

### Maze

For unique-path 30×30 mazes, the paper emphasizes that local path-degree memories are insufficient because they admit disconnected cycles. ERM therefore uses a **global input-conditioned shortest-path memory** $m_{\text{BFS}}(x)$ computed by BFS. Similarity and energy are
$$
S_{\text{Maze}}(y_k;x)=\beta \cdot \operatorname{sim}(y_k,m_{\text{BFS}}(x)), \qquad E_{\text{Maze}}(y_k;x) = -S_{\text{Maze}}(y_k;x),
$$
where $\operatorname{sim}$ is the fraction of matching tokens and $\beta=64$. The reported Maze configuration sets the local memory weight to zero so that the global verifier dominates [2607.10128].

These three instantiations illustrate a central feature of ERM: the energy is not a generic learned scalar, but a structured verifier grounded in the combinatorics of each task. A plausible implication is that ERM’s effectiveness depends strongly on whether the relevant validity constraints can be encoded as tractable memories or global penalties.

## 5. Quantitative performance, oracle gaps, and ablations

Under a **shared-candidate selection** protocol with $D=64$ and $K=128$, ERM is compared against baseline one-rollout prediction, majority voting, q-head selection, and confidence-based selection. The paper reports the following exact-accuracy results [2607.10128]:

| Task | Non-ERM selectors | ERM |
|---|---|---|
| Sudoku (2048 puzzles) | Baseline 89.31%; Majority 97.90%; q-head 98.54%; confidence 98.58% | 98.83% |
| PPBench (301 puzzles) | Baseline 68.44%; Majority 79.07%; confidence 80.73%; q-head 83.39% | 88.04% |
| Maze (1000 mazes) | Baseline 89.10%; Majority 97.80%; q-head 97.30%; confidence 97.80% | 99.30% |

ERM matches the **candidate oracle** on Sudoku and PPBench at $98.83\%$ and $88.04\%$, respectively, and also matches the candidate oracle on Maze at $99.30\%$ [2607.10128]. The paper interprets this as closing, or nearly closing, the selector-oracle gap under the same rollout budget.

With **parallel tempering**, ERM remains the strongest selector. The reported selected/oracle accuracies are:

- **Sudoku**: PT-q-head $98.63\%$; PT-confidence $98.63\%$; PT-ERM $98.97\%$ selected and $98.97\%$ oracle, with swap rate approximately $0.90$.
- **PPBench**: PT-q-head $83.39\%$; PT-confidence $81.06\%$; PT-ERM $88.04\%$ selected and $88.04\%$ oracle, with swap rate approximately $0.94$.
- **Maze**: PT-q-head $97.40\%$; PT-confidence $97.90\%$; PT-ERM $99.30\%$ selected and $99.30\%$ oracle, with swap rate approximately $0.95$ [2607.10128].

The ablation analysis isolates several conditions under which ERM is effective:

- **Energy choice on PPBench**: pure memory-distance energy with $\gamma=0$ avoids elevating confident but invalid candidates; $\beta=128$ and $\mu=64$ are identified as critical.
- **Global memory on Maze**: BFS-derived global memory is necessary because local degree memories cannot reject disconnected cycles.
- **Memory capacity on Sudoku**: exact log-permanent dynamic programming makes large permutation memories computationally feasible.
- **Depth and breadth**: increasing $D$ improves candidate quality and increasing $K$ raises the oracle; ERM’s advantage grows when ordinary selectors lag behind a substantially better oracle.
- **Failure cases**: if the oracle is low, the bottleneck is candidate generation rather than selection; if PT is ineffective under weak base models, the paper attributes this to misaligned landscapes rather than to the PT mechanism itself [2607.10128].

The theoretical discussion is correspondingly modest. ERM does not update latent states by energy descent, but its selector is described as choosing the minimum of a **Lyapunov-like** function over a discrete candidate set. The paper also states that the factor energies are log-sum-exp over memory distances, making $E_{\text{ERM}}$ convex in the logits and sharp in the low-temperature limit [2607.10128].

## 6. Relation to earlier energy-guided sequence modeling and terminological scope

The label “ERM” has close conceptual neighbors in earlier work on text generation, but those systems address a different setting. “Residual Energy-Based Models for Text” defines a globally normalized joint model
$$
p_\theta(x)\propto p_0(x)\exp(-E_\theta(x)),
$$
where a base autoregressive language model $p_0$ is corrected by a sequence-level residual energy $E_\theta(x)$. The paper derives an exact step-wise decomposition in which local token probabilities are multiplicatively corrected by expectations of $\exp(-E_\theta)$ over suffixes sampled from the base model, and it uses importance resampling for generation rather than heuristic reranking. It reports improvements in perplexity and human evaluation, including CCNews test perplexity improving from $17.57$ for a 12-layer base LM to $14.61$–$14.64$ with Joint BiT-Base, and human preferences favoring joint samples over base LM samples on CCNews [2004.10188].

A later single-network method, E-ARM, makes the autoregressive model itself an energy-based model by reinterpreting softmax logits as energies without adding parameters. It trains with a contrastive-divergence objective and uses ancestral samples from the autoregressive model for the negative phase via importance weighting, rather than MCMC. The paper reports gains in neural machine translation, language modeling, and image generation; for example, on language modeling with Transformer-Base it improves CC-News perplexity from $18.29$ to $15.78$ without resampling and to $15.63$–$15.67$ with Top-K energy resampling [2206.12840].

These earlier methods share ERM’s broad intuition that **energy can guide recursive or autoregressive generation**, but they differ materially from the 2026 ERM formulation. The 2026 ERM is an **inference-time selector for recursive reasoning trajectories** built from explicit Hopfield-style task memories; the text-generation methods are **probabilistic generative models** over token sequences with learned energy terms [2607.10128]. The terminological overlap therefore reflects a family resemblance rather than identity.

A separate probabilistic model, the Derrida–Retaux recursive model, also uses the language of “free energy” and recursion, with update
$$
X_{n+1}=\left(\sum_{i=1}^{v}X_{n,i}-1\right)_+,
$$
but this is a distinct mathematical object from the neural ERM framework. Its “free energy” is the asymptotic normalized expectation
$$
F(p)=\lim_{n\to\infty} m^{-n}\mathbb{E}[X_n],
$$
studied in the context of hierarchical pinning and critical exponents rather than test-time candidate selection [1705.03792]. The shared vocabulary should not be conflated with the 2026 reasoning model.

In this broader lineage, ERM can be situated as a task-structured, selector-centric variant of energy-guided computation: explicit energy defines what constitutes a valid candidate, and test-time inference chooses or samples according to that criterion rather than according to confidence heuristics alone.

Source: https://www.emergentmind.com/topics/energy-guided-recursive-model-erm