Auguste Rodin's The Thinker

Learning to Generate in the Right Order

PONDER: a learned policy for where to generate next, and what it should reconsider

1 Photogrammetry and Remote Sensing Group, ETH Zurich, Switzerland

2 Max Planck Institute for Informatics, Saarland Informatics Campus, Germany

3 Saarland University, Germany

Masked generators fill an image piece by piece, usually in a random order. PONDER uses reinforcement learning to train a small policy that decides which pieces a frozen generator fills next, and which earlier ones it should erase and redo (rethinking). Allowing more rethinking at inference time generally improves quality, with no retraining.

Try it: solve a visual Sudoku with PONDER

No solver. No rules. Just order. Here the image is a Sudoku board of handwritten digits. The generator only ever saw images of solved boards. The policy never sees a rule; its only reward was whether the finished board is valid. That alone takes hard puzzles from 4.5% to 96.7% solved.

Draw or type digits (typed digits become real MNIST handwriting). After each move, the policy, running in your browser, marks the cell it would write next. Press Ponder's move to let it act: it writes a digit or erases one to rethink it.

 0:00
Draw a digit for the selected cell
or write a handwritten digit

Keyboard (after clicking the board): 1–9 writes, Backspace erases, arrows move, Enter places a drawing.

given clue how likely Ponder writes there next Ponder's next cell written by Ponder
How this works

Ponder's move fills the blue cell or erases a digit to try again. Let Ponder finish plays the rest, with up to nine rethinks. Green dots mark Ponder's digits.

Small numbers show how your handwriting was read. Each puzzle has one solution. Ponder can choose orders that are not optimal for human players.

4.5% → 96.7%
hard visual Sudoku accuracy
random order → PONDER, \(R=9\)
random order with \(R=9\) random re-masks: 4.4%
4.09 → 2.70
MAR-B ImageNet FID
random order → PONDER, \(R=32\)
random order with \(R=32\) random re-masks: 3.80
24.50 → 27.80
MaskGen-KL-XL HPSv2
random order → PONDER, \(R=32\)
random order with \(R=4\) random re-masks: 25.19

All with the generator frozen; only the position policy is trained.

Abstract

We introduce PONDER, a method that learns in which order an image generator should fill in content and which of its earlier predictions to revise. Masked generative models construct a sample by repeatedly filling in subsets of missing variables. The order of these partial predictions determines the context available in subsequent steps and therefore affects the quality of the final sample. Common strategies are to choose the order randomly or based on local confidence estimates.

Conditioned on the partially generated sample and the generator's features, our policy chooses which positions to fill next and/or which previously filled positions to mask for later regeneration, a mechanism we call rethinking. In this way, the generation process is able to adapt to the evolving context and also to revise earlier predictions. We optimize the policy using group-relative policy gradients, with rewards that measure constraint satisfaction, human preference, or distribution quality. For the latter, we introduce FIDgrad, an image-level reward derived from the (first-order) change in Fréchet Inception Distance caused by adding a generated sample to the current feature distribution.

With the generators frozen, learned ordering reduces MAR-B ImageNet FID from 4.09 to 2.78 and raises the accuracy on hard visual Sudokus from 4.5% to 56.6%, surpassing uncertainty-based greedy ordering (41.0%). Rethinking further improves these results to 2.70 FID and 96.7% accuracy, while increasing the rethinking budget of a fixed policy yields continued improvements at inference time.

How it works

Overview of PONDER: a frozen backbone produces features, a trainable policy samples positions to fill or re-mask, a frozen generator updates the canvas; a terminal reward trains only the policy with group-relative policy gradients.

Learned order

In each iteration the frozen generator's backbone is evaluated on the current canvas. A small bidirectional transformer reads these features and samples which positions to fill next, without replacement. The generator then fills them using the same context.

Rethinking

The same policy may also select an already visible patch. That patch is masked again and regenerated later, when more context is available. With a budget of \(R\) removals, a roll-out over \(N\) patches takes \(T = N + 2R\) decisions. \(R\) can be changed at inference time without retraining.

Training

Only the policy is trained, with group-relative policy gradients on a terminal reward: rule satisfaction for Sudoku, human-preference scores for text-to-image, and FIDgrad for distribution quality. Group members share the generator noise, so reward differences come from the order alone.

Random order vs. PONDER on visual Sudoku

Every cell is a handwritten digit produced by a frozen masked generator. The three boards share the puzzle and the generator noise; only the order of decisions differs.

given clue next cell to generate next cell to re-mask rule conflict re-masked, waiting to be regenerated just regenerated policy log-probability, −8 to 0

Rethinking on ImageNet (MAR-B)

Class-conditional MAR-B generates 256 latent patches over 76 iterations. Below, the same class and noise are rolled out with random order, random order with 32 random re-masks, and PONDER with a budget of \(R=32\), synchronized by iteration (selected examples).

next patches to generate next patches to re-mask re-masked, waiting to be regenerated just regenerated policy log-probability over masked patches, −8 to 0

FIDgrad: a per-image reward for a distribution metric

FID judges a whole set of images, not a single one, so it cannot directly serve as a reward for one roll-out. FIDgrad asks a simple question about each new image: would adding it to the images generated so far bring FID down or up? Images that pull the generated distribution towards the real one earn a positive reward; images that push it further away earn a negative one.

(a) Positive mean contribution: a new feature z pulls the generated mean toward the reference. (b) Negative covariance contribution: z adds spread where the generated pool is already too wide.
Show the formula

With Inception features \(z\) of the new image, generated statistics \(\mu_g, \Sigma_g\), real statistics \(\mu_r, \Sigma_r\) and \(u = z - \mu_g\), FIDgrad is the negative first-order change of FID when a small amount of probability mass is moved onto \(z\):

$$ r_{\mathrm{FIDgrad}}(z) = -2(\mu_g-\mu_r)^{\top}u \;-\; u^{\top}(I-B)\,u \;+\; \operatorname{tr}\!\big[(I-B)\Sigma_g\big], \qquad B=\Sigma_r^{1/2}\big(\Sigma_r^{1/2}\Sigma_g\Sigma_r^{1/2}\big)^{-1/2}\Sigma_r^{1/2}. $$

The first term is the mean contribution (a), the remaining terms the covariance contribution (b). The generated statistics are tracked with moving averages during training, so the same image can earn a different reward as the policy improves.

Quality generally improves with the rethinking budget

Each table reports the endpoints; the plot next to it sweeps the inference-time budget \(R\) (log scale) with the policy and generator fixed.

Visual Sudoku, accuracy (%)

Policy \(R\) Overall Hard Medium Easy
Random order 0 52.7 4.5 56.9 96.7
SRM greedy 0 71.6 41.0 77.2 96.8
Random order 9 52.7 4.4 57.0 96.7
PONDER 0 80.2 56.6 87.1 96.9
PONDER + rand. rethinking 9 83.1 62.7 89.0 97.6
PONDER 9 98.2 96.7 98.4 99.6

MAR-B, class-conditional ImageNet 256

Policy \(R\) FID↓ FDr-5↓ IS↑
Random order 0 4.09 13.69 181.22
Random order 32 3.80 12.82 185.90
PONDER 0 2.78 13.28 206.55
PONDER + rand. rethinking 32 2.76 12.68 209.00
PONDER 32 2.70 12.47 212.60

FDr-5 is not used as a training reward, yet it also improves.

MaskGen-KL-XL, text-to-image

Policy \(R\) HPSv2↑ PickScore↑ ImageReward↑ GenEval↑
Random order 0 24.50 21.04 0.44 37.3
Random order 4 25.19 21.26 0.59 38.0
PONDER 0 26.50 21.32 0.68 41.1
PONDER + rand. rethinking 4 26.40 21.33 0.67 41.9
PONDER 4 26.95 21.41 0.73 42.6

The preference columns and the GenEval column come from two separately trained policies (HPSv2 reward and GenEval reward).

Random order vs. PONDER

Same prompt or class and the same generator noise. Drag the handle to compare.

MaskGen-KL-XL, text-to-image (random \(R=0\) vs. HPSv2 policy \(R=4\))

“A Pixar lemon wearing sunglasses on a beach.”
“A whale is reading a book about avoiding Japanese spears in an underwater library.”
“A goth anime woman with a symmetrical and attractive face in a black and white watercolor headshot art on ArtStation.”

MAR-B, ImageNet (\(R=8\))

Giant panda
Goldfish
Husky
Yellow bird

BibTeX

@article{erbach2026ponder,
  title   = {Learning to Generate in the Right Order},
  author  = {Erbach, Julius and Narnhofer, Dominik and Schiele, Bernt and Lenssen, Jan Eric and Schindler, Konrad},
  journal = {arXiv preprint arXiv:2610.23531},
  year    = {2026}
}