Overthinking and Reasoning Efficiency › Worked Example: A Simulator With a Real Trade-off

Michael BrenndoerferNovember 29, 202618 min read
Language AI HandbookAll chapters
Part 40 of 67Reasoning Post-Training and Verifiable Rewards
Chapter 306Overthinking and Reasoning Efficiency › Worked Example: A Simulator With a Real Trade-off
Reading section 7 of 11 · Worked Example: A Simulator With a Real Trade-off · 18 minSection 7 of 11 · 18 min

Section 7 of 11 · 18 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

The simulator is small enough to run on a laptop. Closed forms give separate checks on clean-draft probability and stationary review accuracy. The finite-budget curves and selected costs come from the seeded simulation.

Compare stopping policies on the same simulated trajectories. That pairing removes variation due to independently drawing the two sets of problems. The difference is still an estimate with sampling uncertainty.

The setup is a caricature with exactly the ingredients from the previous sections.

  • A problem requires DD productive deductions.
  • Each attempt at a deduction is flawed with probability φ\varphi.
  • A flawed deduction is caught with probability pcatchp_{\text{catch}}. A caught flaw consumes an attempt and preserves the previous clean or poisoned state.
  • An uncaught flaw can advance the derivation when the attempt is productive. It leaves the draft poisoned.
  • Once the derivation is complete, the model keeps deliberating. Each further step it may break a correct answer (probability pbreakp_{\text{break}}) or repair an incorrect one (probability pfixp_{\text{fix}}).
  • If the budget runs out before the derivation completes, the model guesses, and guesses are right with probability 1/A1/A for an AA-way answer.

Two closed forms provide reference values for checking the simulation.

The probability that a completed derivation is clean depends on the injection rate and on how often a flaw is caught and retried:

P(clean derivation)=qD,q=1−φ(1−φ)+φ(1−pcatch)=1−φ1−φ pcatch.P(\text{clean derivation}) = q^{D}, \qquad q = \frac{1-\varphi}{(1-\varphi) + \varphi(1-p_{\text{catch}})} = \frac{1-\varphi}{1-\varphi\,p_{\text{catch}}} .

Here qq is the probability that an advancing thought is clean, conditional on positive probability of advancement. A flawed thought advances only if it goes uncaught, and redundancy has the same independent probability for clean and flawed attempts. For the fragile profile, no catching gives (1−0.06)12≈0.476(1-0.06)^{12}\approx0.476 clean completions. With pcatch=0.25p_{\text{catch}}=0.25 the result is q12≈0.571q^{12}\approx0.571.

The review channel is a two-state Markov chain on correctness with transition probabilities pbreakp_{\text{break}} and pfixp_{\text{fix}}, whose stationary accuracy is

π⋆=pfixpbreak+pfix.\pi^\star = \frac{p_{\text{fix}}}{p_{\text{break}} + p_{\text{fix}}}.

Let aka_k be the probability that the answer is correct after kk review steps. Then ak+1=pfix+(1−pbreak−pfix)aka_{k+1}=p_{\text{fix}}+(1-p_{\text{break}}-p_{\text{fix}})a_k. A review step improves expected accuracy when repair probability mass (1−ak)pfix(1-a_k)p_{\text{fix}} exceeds break probability mass akpbreaka_k p_{\text{break}}. The stationary ratio requires positive total transition probability, and convergence from any starting value requires the sum to be less than two. With both probabilities zero, the chain stays in its initial state.

The stationary fraction of correct answers balances the probability mass leaving and entering the correct state, so πpbreak=(1−π)pfix\pi p_{\text{break}}=(1-\pi)p_{\text{fix}}. If the conditional probability of repairing an incorrect answer is twice the conditional probability of breaking a correct answer, the stationary accuracy is two-thirds, assuming the transitions are nonzero and the chain converges.

Three regimes make the point.

Regimedrafter qDq^{D}stationary accuracy pfix/(pbreak+pfix)p_{\text{fix}}/(p_{\text{break}}+p_{\text{fix}})behavior
Fragile review0.5710.200strong inverted-U
Balanced review0.8200.400peak, then decay
Strong review0.3600.938deliberation is essential

The strong-review profile starts near 36% among completed drafts and approaches 94% under its simulated review rule. The fragile profile starts near 57% and approaches 20%. Both patterns are consequences of the chosen transition probabilities. The experiment illustrates how more revision can help or hurt even when the underlying problem is held fixed.

The strong profile has the lowest clean-draft accuracy and the highest stationary review accuracy. The fragile profile starts higher but settles lower. Whether one additional step helps depends on the current accuracy as well as the break and repair probabilities.

Now the code.

Setup

PythonIn [4]
CollapseExpand
TOKENS_PER_STEP = 40
N_PROBLEMS = 8000
N_STEPS = 120

Within a simulated profile, fixed budgets reuse the stored trajectories. The adaptive policies use the same balanced-profile trajectories and matched random confidence noise. Different profiles use different seeds, as shown in the runs loop.

The constants are worth a word. TOKENS_PER_STEP converts simulated steps into an interpretable cost unit, so that the x-axes below can be read as tokens rather than as abstract iterations. With 8,000 independent problems, the standard error of a single accuracy estimate is at most about 0.56 percentage points. At 120 steps, the expected accuracy for each shown profile is close to its stationary value. The final simulated values still vary with the sampled problems.

The three reasoner profiles

PythonIn [5]
CollapseExpand
REGIMES = {
    "Fragile review": dict(
        required_steps=12,
        p_flaw=0.06,
        p_catch=0.25,
        p_redundant=0.15,
        p_break=0.060,
        p_fix=0.015,
        n_choices=5,
    ),
    "Balanced review": dict(
        required_steps=12,
        p_flaw=0.04,
        p_catch=0.60,
        p_redundant=0.15,
        p_break=0.030,
        p_fix=0.020,
        n_choices=5,
    ),
    "Strong review": dict(
        required_steps=12,
        p_flaw=0.10,
        p_catch=0.20,
        p_redundant=0.15,
        p_break=0.008,
        p_fix=0.120,
        n_choices=5,
    ),
}

p_flaw controls how error-prone the drafter is, p_catch how often a mistake is noticed mid-derivation, p_redundant how often a step is a pure restatement, and p_break/p_fix govern the post-completion review channel. Only the last pair determines stationary review accuracy.

The table's ordering is easier to see as a pair of bars. The drafter's accuracy at completion and the chain's long-run stationary review accuracy are computed directly from the regime parameters.

PythonIn [6]
CollapseExpand
import numpy as np
import pandas as pd

regime_rows = []
for name, cfg in REGIMES.items():
    q_clean = (1.0 - cfg["p_flaw"]) / (1.0 - cfg["p_flaw"] * cfg["p_catch"])
    drafter = q_clean ** cfg["required_steps"]
    stationary_accuracy = cfg["p_fix"] / (cfg["p_break"] + cfg["p_fix"])
    regime_rows.append(
        {
            "regime": name,
            "drafter": drafter,
            "stationary_accuracy": stationary_accuracy,
        }
    )
regime_compare = pd.DataFrame(regime_rows)
regime_x = np.arange(len(regime_compare))
regime_width = 0.38
VisualizationOut [7]
CollapseExpand
Grouped bars compare drafter accuracy and stationary review accuracy for three reasoner profiles.
Accuracy at completion and long-run stationary review accuracy for three simulated profiles. The fragile and balanced profiles have higher accuracy at completion than in the stationary limit. The strong profile has lower initial accuracy and higher stationary accuracy. For these transition rates, the direction of review’s change depends on the current accuracy relative to the stationary value.

Drafting errors and retries affect completion time and accuracy at completion. Both can still affect the finite-budget curve after its peak because some problems remain unfinished. With positive advancement probability and 0<pbreak+pfix<20 < p_{\text{break}} + p_{\text{fix}} < 2, the long-run accuracy is pfix/(pbreak+pfix)p_{\text{fix}}/(p_{\text{break}}+p_{\text{fix}}).

The simulator

A loop advances the simulator one step at a time. Each state array holds one value per problem. The saved correctness and completion histories have one row per problem and one column per simulated step.

PythonIn [8]
CollapseExpand
def simulate(cfg, n_problems, n_steps, seed):
    """Simulate a stop-anywhere reasoning process; return per-step state."""
    rng = np.random.default_rng(seed)
    n, T = n_problems, n_steps
    D = cfg["required_steps"]

    guess_ok = rng.random(n) < 1.0 / cfg["n_choices"]

    progress = np.zeros(n, dtype=np.int32)
    poisoned = np.zeros(n, dtype=bool)
    finished = np.zeros(n, dtype=bool)
    correct = np.zeros(n, dtype=bool)

    correct_hist = np.zeros((n, T), dtype=bool)
    done_hist = np.zeros((n, T), dtype=bool)

    for t in range(T):
        finished_before = finished
        drafting = ~finished

        flawed = rng.random(n) < cfg["p_flaw"]
        caught = flawed & (rng.random(n) < cfg["p_catch"])
        skip = rng.random(n) < cfg["p_redundant"]

        clean = drafting & ~flawed & ~skip
        poison = drafting & flawed & ~caught & ~skip
        progress += (clean | poison).astype(np.int32)
        poisoned |= poison

        newly_done = drafting & (progress >= D)
        finished = finished | newly_done
        correct = np.where(newly_done, ~poisoned, correct)

        breaks = finished_before & correct & (rng.random(n) < cfg["p_break"])
        repairs = finished_before & ~correct & (rng.random(n) < cfg["p_fix"])
        correct = (correct & ~breaks) | repairs

        correct_hist[:, t] = correct
        done_hist[:, t] = finished

    return {"correct": correct_hist, "done": done_hist, "guess": guess_ok}

Reading the loop in order: each step first decides whether the thought is flawed, whether that flaw is caught, and whether the thought is a pure restatement. Clean and poisoned thoughts both advance progress; caught flaws do not. When progress reaches DD the derivation is complete, the current answer becomes whatever the derivation produced, and from the next step onward the model is in review mode, where each step can break or repair.

Two details in the implementation carry indexing significance. The review update uses finished_before rather than finished, so a problem that completes on step tt does not also get a review step on the same iteration; without that, the model would get a free repair or a free break at the moment of completion, which is not what the model intends. And correct is set from ~poisoned only through np.where(newly_done, ...), so problems that were already finished keep their accumulated correctness rather than being reset.

PythonIn [9]
CollapseExpand
runs = {}
for i, (name, cfg) in enumerate(REGIMES.items()):
    runs[name] = simulate(
        cfg, n_problems=N_PROBLEMS, n_steps=N_STEPS, seed=100 + i
    )

Reading the curves at a fixed budget

The natural first question: what would happen if we always spent the same number of tokens? Because we stored the full trajectory, we can answer it for every budget at once, using the same underlying draws.

PythonIn [10]
CollapseExpand
def fixed_budget_curve(run, steps, tokens_per_step=TOKENS_PER_STEP):
    rows = []
    for b in steps:
        answered = np.where(
            run["done"][:, b - 1], run["correct"][:, b - 1], run["guess"]
        )
        rows.append(
            {
                "steps": int(b),
                "tokens": int(b * tokens_per_step),
                "accuracy": float(answered.mean()),
            }
        )
    return pd.DataFrame(rows)


fixed_curves = {
    name: fixed_budget_curve(run, np.arange(2, N_STEPS + 1))
    for name, run in runs.items()
}
VisualizationOut [11]
CollapseExpand
Three lines of simulated accuracy versus token budget with marked sample maxima. The strong profile rises and levels off while the other two decline after peaking.
Sample accuracy from a seeded simulator at different fixed token budgets. The fragile and balanced profiles fall after their sampled peaks. The strong profile rises toward its stationary value in expectation, while the sampled curve fluctuates near it. Markers mark each profile’s highest sampled accuracy in the plotted budget range.

The markers mark the largest sample accuracy on each plotted curve. For the strong profile the underlying post-completion process improves toward a higher stationary value in expectation, although successive finite-sample points can drop.

The horizontal axis is logarithmic. An equal distance corresponds to an equal ratio of token budgets, so inspect the tick labels when reading absolute cost differences.

Checking the simulator against the closed forms

Before trusting any of this, verify the two analytic predictions. The first says the probability of a clean derivation at draft completion is exactly qDq^{D} with q=(1−φ)/(1−φpcatch)q = (1-\varphi)/(1-\varphi p_{\text{catch}}). The second gives the long-run accuracy pfix/(pbreak+pfix)p_{\text{fix}}/(p_{\text{break}}+p_{\text{fix}}) for the displayed profiles, whose transition probabilities satisfy the convergence condition.

PythonIn [12]
CollapseExpand
rows = []
for name, run in runs.items():
    cfg = REGIMES[name]
    ever_done = run["done"].any(axis=1)
    first_done = run["done"].argmax(axis=1)
    n = len(first_done)
    at_completion = run["correct"][np.arange(n), first_done][ever_done]

    late_mask = run["done"][:, -1]
    late = run["correct"][:, -1][late_mask]

    rows.append(
        {
            "regime": name,
            "drafter q^D": (
                (1 - cfg["p_flaw"]) / (1 - cfg["p_flaw"] * cfg["p_catch"])
            )
            ** cfg["required_steps"],
            "measured at completion": float(at_completion.mean()),
            "stationary p_fix/(p_break+p_fix)": cfg["p_fix"]
            / (cfg["p_break"] + cfg["p_fix"]),
            "measured at final step": float(late.mean()),
        }
    )

check_table = pd.DataFrame(rows)
Out[13]:
regime drafter q^D measured at completion stationary p_fix/(p_break+p_fix) measured at final step
0 Fragile review 0.571 0.571 0.200 0.194
1 Balanced review 0.820 0.829 0.400 0.386
2 Strong review 0.360 0.352 0.938 0.936

The simulated completion values can be compared with the analytic clean-draft probabilities. The last sampled step can be compared with the stationary value, but a finite budget need not reach that value exactly. Small differences also arise from Monte Carlo sampling.

These checks distinguish accuracy immediately at completion from accuracy after review. Comparing the two against separate analytic predictions helps identify whether a mismatch originates in drafting or in the transition rule.

Three policies, one accuracy axis

The policy stops the first time its score reaches θ\theta. It uses the final step if the score never reaches the threshold. If the policy stops before a draft is complete, it emits the fallback guess.

The strength parameter controls the score’s association with draft correctness in the simulator. Positive strength tends to rank correct drafts higher, and negative strength tends to rank them lower. With zero strength the correctness flag has no effect on the score distribution.

PythonIn [14]
CollapseExpand
def confidence_trace(
    run, strength, sigma=0.8, base=0.4, separation=1.5, seed=7
):
    """Map a correctness-dependent noisy logit to a stopping score."""
    rng = np.random.default_rng(seed)
    state = 2.0 * run["correct"].astype(np.float64) - 1.0
    logits = (
        base
        + separation * strength * state
        + sigma * rng.standard_normal(state.shape)
    )
    return 1.0 / (1.0 + np.exp(-logits))


def stopping_curve(run, conf, thresholds, tokens_per_step=TOKENS_PER_STEP):
    """Sweep the stop threshold; report accuracy and cost of the induced policy."""
    n, T = conf.shape
    rows = []
    for tau in thresholds:
        fired = conf >= tau
        any_fire = fired.any(axis=1)
        idx = np.where(any_fire, fired.argmax(axis=1), T - 1)
        answered = np.where(
            run["done"][np.arange(n), idx],
            run["correct"][np.arange(n), idx],
            run["guess"],
        )
        steps_used = (idx + 1).astype(np.float64)
        rows.append(
            {
                "tau": float(tau),
                "accuracy": float(answered.mean()),
                "mean_steps": float(steps_used.mean()),
                "tokens": float(steps_used.mean()) * tokens_per_step,
            }
        )
    return pd.DataFrame(rows)
PythonIn [15]
CollapseExpand
SIGNALS = {
    "Adaptive (strong signal)": 1.0,
    "Adaptive (weak signal)": 0.3,
    "Adaptive (inverted signal)": -1.0,
}
POLICY_COLOR_KEYS = {
    "Fixed budget": "ink",
    "Adaptive (strong signal)": "amber",
    "Adaptive (weak signal)": "teal",
    "Adaptive (inverted signal)": "rose",
}
THRESHOLDS = np.linspace(0.55, 0.99, 60)

stop_curves = {}
for name, s in SIGNALS.items():
    conf = confidence_trace(runs["Balanced review"], s, seed=7)
    stop_curves[name] = stopping_curve(
        runs["Balanced review"], conf, THRESHOLDS
    )
VisualizationOut [16]
CollapseExpand
Accuracy versus mean token cost for four policies. The strong signal reaches the highest accuracy, while the inverted signal stays low across the sweep.
Accuracy against mean simulated token cost for fixed budgets and three threshold-based policies on the balanced profile. A score strongly associated with tracked correctness can stop on correct drafts and give others longer. The inverted scoring policy does not reach the common accuracy target in this sweep.

There are two separable results in that figure, and they should be read separately.

At the common accuracy target established below, the cheapest tested strong-signal threshold uses fewer tokens than the cheapest tested fixed budget. The attained accuracies differ because both settings need only reach the target. The simulator counts generation tokens alone. Include the cost of computing the stop score in a deployed comparison.

The strong-signal sweep also reaches a higher sample peak than the fixed sweep, at a higher mean token cost. It stops early on some already-correct drafts and waits longer on some wrong or incomplete trajectories that can still improve. This comparison uses a synthetic score derived from the latent correctness indicator.

With the sign inverted, high scores favor trajectories without a tracked correct draft. That includes unfinished trajectories that can still get the fallback answer right. None of the tested inverted settings reaches the common accuracy target.

All three adaptive curves use the same rule and threshold range. The scores differ in how well they rank draft states. Ranking quality and calibration are separate properties. The test measures policy outcomes using the scores directly.

The ROC calculation pools simulated draft states from the balanced profile. Before completion, the stored correctness flag is false, even when emitting the fallback guess would have earned a correct outcome. The ROC measures ranking of this draft flag while stopping accuracy grades the emitted answer. Each ROC point admits all items tied at its score threshold. Both classes must occur to calculate AUC.

PythonIn [17]
CollapseExpand
import numpy as np


def roc_points(y, score):
    """Return ROC coordinates at distinct score thresholds."""
    positive = int(y.sum())
    negative = len(y) - positive
    if positive == 0 or negative == 0:
        raise ValueError("ROC requires both classes")

    order = np.argsort(-score)
    sorted_labels = y[order]
    sorted_scores = score[order]
    # Include each group of tied scores together.
    group_ends = np.r_[
        np.flatnonzero(sorted_scores[1:] != sorted_scores[:-1]), len(y) - 1
    ]
    true_positives = np.cumsum(sorted_labels)[group_ends]
    false_positives = np.cumsum(1 - sorted_labels)[group_ends]
    tpr = np.r_[0.0, true_positives / positive]
    fpr = np.r_[0.0, false_positives / negative]
    return fpr, tpr


roc_curves = {}
for name, strength in SIGNALS.items():
    conf = confidence_trace(runs["Balanced review"], strength, seed=7)
    y = runs["Balanced review"]["correct"].ravel().astype(int)
    fpr, tpr = roc_points(y, conf.ravel())
    auc_val = float(np.sum(np.diff(fpr) * (tpr[1:] + tpr[:-1]) / 2.0))
    take = np.linspace(0, len(fpr) - 1, 400).astype(int)
    roc_curves[name] = {"fpr": fpr[take], "tpr": tpr[take], "auc": auc_val}
VisualizationOut [18]
CollapseExpand
ROC curves for strong, weak, and inverted confidence signals; diagonal marks chance.
ROC curves for three synthetic confidence scores against the draft-correctness flag. Approximate areas are 1.00 for the strong score, 0.79 for the weak score, and 0.00 for the inverted score. The dotted chance diagonal is a reference for ranking.

Tokens at matched accuracy

For the final comparison, hold the accuracy target fixed and measure what each policy spends to reach it.

PythonIn [19]
CollapseExpand
target = 0.97 * fixed_curves["Balanced review"]["accuracy"].max()

iso_rows = []
fixed_hits = fixed_curves["Balanced review"].loc[
    fixed_curves["Balanced review"]["accuracy"] >= target, "tokens"
]
iso_rows.append(
    {
        "policy": "Fixed budget",
        "tokens": float(fixed_hits.min()) if len(fixed_hits) else np.nan,
    }
)

for name, df in stop_curves.items():
    hits = df.loc[df["accuracy"] >= target, "tokens"]
    iso_rows.append(
        {
            "policy": name,
            "tokens": float(hits.min()) if len(hits) else np.nan,
        }
    )

iso_table = pd.DataFrame(iso_rows)
iso_reached = iso_table.dropna(subset=["tokens"]).sort_values("tokens")
iso_missing = iso_table[iso_table["tokens"].isna()]["policy"].tolist()
VisualizationOut [20]
CollapseExpand
Bar chart of tokens needed to reach a target accuracy for fixed and adaptive stopping policies.
Thinking tokens required to reach a common accuracy target (97% of the highest fixed-budget accuracy) on the balanced profile. For each policy, the same simulated data supply both the settings and their measured accuracy. Use held-out requests to compare selected settings in deployment. Policies that cannot reach the target at any setting are omitted from the bars and reported in the printed output.
Policies that never reached the target accuracy:
  - Adaptive (inverted signal)
Out[21]:
Target accuracy (97% of the highest fixed-budget accuracy): 0.728
policy tokens
0 Adaptive (strong signal) 614.3
1 Fixed budget 680.0
2 Adaptive (weak signal) 950.1

Setting the target at 97% of the highest sampled fixed-budget accuracy avoids requiring the policies to attain that exact maximum. The result still depends on the selected fixed-budget sweep. Try several accuracy targets. At each target, find the cheapest setting in each policy’s existing sweep and check whether the cost ranking changes.

What overthinking costs, in one table

Finally, the direct question a budget owner asks: if I scale the thinking budget up from the peak, what do I get for it?

PythonIn [22]
CollapseExpand
bal = fixed_curves["Balanced review"]
peak_steps = int(bal.loc[bal["accuracy"].idxmax(), "steps"])
done_history = runs["Balanced review"]["done"]
first_done = np.where(
    done_history.any(axis=1), done_history.argmax(axis=1), N_STEPS
)

overhead_rows = []
for b in sorted(
    {
        peak_steps,
        min(2 * peak_steps, N_STEPS),
        min(4 * peak_steps, N_STEPS),
        N_STEPS,
    }
):
    acc = float(bal.loc[bal["steps"] == b, "accuracy"].iloc[0])
    spent_drafting = np.minimum(first_done + 1, b)
    overhead_rows.append(
        {
            "budget (steps)": int(b),
            "tokens": int(b * TOKENS_PER_STEP),
            "accuracy": acc,
            "post-completion share of tokens": float(
                ((b - spent_drafting) / b).mean()
            ),
        }
    )

overhead_table = pd.DataFrame(overhead_rows)
Out[23]:
budget (steps) tokens accuracy post-completion share of tokens
0 18 720 0.751 0.200
1 36 1440 0.542 0.599
2 72 2880 0.419 0.800
3 120 4800 0.386 0.880

After the balanced profile’s sampled peak, a larger share of its tokens goes to review and measured accuracy falls. After a draft becomes correct, review is the only simulated stage that can make that completed draft incorrect.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy