Research log Small Model Experimentation
GitHub

Qwen Context-Conditioned Trace Verifier

The right answer was there but unpickable

The one idea you need

A small model turns each question into a tiny step-by-step calculator program, then spawns about a hundred edited variants of it. A separate judge watches each one run and tries to pick the best, but never sees the correct answer, like a talent scout choosing without the scoreboard.

The question

If a model rewrites a question as a tiny program, can a separate judge pick the best version just by watching each one run, without ever seeing the answer?

What we found

Mostly no. A correct program was almost always sitting in the candidate pile, for 91 to 100 percent of questions, yet the judge barely helped: it nudged easy questions from about 69 to 70 percent and actually made the hardest ones worse, dropping them from 41 to 35 percent. The wall is choosing the right program, not finding one.

Why it matters

When dozens of candidate programs land on the same final answer, "is the answer right" is too weak a signal to train a picker. Supervise on the intermediate calculation steps, not just the final number.

How often a correct program was even available91-100%share of questions with a right answer somewhere in the candidate pile
Best-case gain on easy questions69% → 70%the judge's pick vs the model's own default program
What happened on the hardest questions41% → 35%the judge made accuracy worse, not better
Reachable ceiling vs what the judge captured~98% vs ~70%how much correct-program headroom went unused
On this page
  1. Results at a glance
  2. Overview
  3. Report
    1. Abstract
    2. Question
    3. Method
    4. Main Results
    5. Candidate Geometry
    6. Objective Pilots
    7. Domain Breakdown
    8. Interpretation
    9. Most Impactful Next Options
    10. Artifacts
  4. Experiment log
  5. Figures
  6. Data files
  7. Reproduce
  8. Related

Results at a glance 5

Judge barely beats the model, though a correct answer almost always existed

How to read

Bars grouped by difficulty, easier on the left to harder on the right. Height is the share of questions answered correctly, so taller is better. Three bars per group: the model's own first choice, the trained judge, and a best-possible bar showing what perfect selection would reach.

0%25%50%75%100%fresh standard L6fresh standard L668.8%70.3%98.4%fresh paraphrase L6fresh paraphrase L657.8%60.2%100%fresh paired L6fresh paired L657.3%55.2%98.4%hard standard L8hard standard L850%46.9%98.4%harder standard L10harder standard L1040.6%35.2%98.4%

Takeaway → The best-possible bar sits near 98 to 100 percent everywhere while the judge's bar hugs the model's own bar, so correct answers exist but the judge rarely selects them.

Data table
evaluation splitbase (frozen compiler)learned verifieroracle (any correct candidate)
fresh standard L668.8%70.3%98.4%
fresh paraphrase L657.8%60.2%100%
fresh paired L657.3%55.2%98.4%
hard standard L850%46.9%98.4%
harder standard L1040.6%35.2%98.4%

Numbers from report table (reports/qwen_context_trace_verifier_report.md), matches analysis/final_metrics.csv

Technical framing

Program selection accuracy: learned verifier barely moves the base compiler while oracle headroom stays near 100% — Answer-correct candidates exist for ~98% of prompts, but the learned verifier gains only 1-2 points in-distribution and loses on harder splits.

How much of the room to improve the judge actually captured

How to read

Each bar is one difficulty level. Height shows how much of the gap between the model's own accuracy and best-possible the judge captured; the zero line means no change, above zero is better, below zero means it made things worse.

-10%-5%0%5%10%val mixed L6val mixed L62%fresh standard L6fresh standard L65.3%fresh paraphrase L6fresh paraphrase L65.6%fresh paired L6fresh paired L6-5.1%hard standard L8hard standard L8-6.5%hard paraphrase L8hard paraphrase L8-4%harder standard L10harder standard L10-9.5%harder paraphrase L10harder paraphrase L10-4.2%

Takeaway → Bars are only slightly positive on easy questions and drop below zero on paired and longer questions, so the judge helps a little then backfires.

Data table
evaluation splitgap recovered
val mixed L62%
fresh standard L65.3%
fresh paraphrase L65.6%
fresh paired L6-5.1%
hard standard L8-6.5%
hard paraphrase L8-4%
harder standard L10-9.5%
harder paraphrase L10-4.2%

Numbers from report table (reports/qwen_context_trace_verifier_report.md), matches analysis/final_metrics.csv learned_oracle_gap_recovered

Technical framing

Fraction of the base-to-oracle gap the verifier recovers, by split — The verifier recovers at most 5.6% of available headroom in-distribution and goes negative on paired and longer-chain splits.

By task type: small gains everywhere except one, which got worse

How to read

Bars grouped by task type, from math and dates to true-or-false. Height is the share answered correctly, taller is better, with bars for the model's own choice, the trained judge, and best-possible selection.

0%25%50%75%100%arithmeticcalendarunitlistbooleanlookup

Takeaway → The judge's bar edges above the model for most tasks but drops sharply on true-or-false, where few possible answers make competing programs hard to tell apart.

Data table
task domainbase (frozen compiler)learned verifieroracle (any correct candidate)
arithmetic31.2%34.4%96.9%
calendar37.5%40.6%100%
unit40.6%43.8%96.9%
list81.2%84.4%100%
boolean87.5%78.1%100%
lookup65.6%65.6%100%

Numbers from report table (reports/qwen_context_trace_verifier_report.md), matches analysis/final_metrics.csv domain_* columns

Technical framing

Per-domain accuracy on length-6 prompts: modest gains except boolean, which the verifier hurts — Boolean drops 9.4 points: many candidates share the few possible boolean answers, so answer-only labels give little trace-identifying signal.

Which training signal actually changed the judge's choices

How to read

Bars grouped by the rule used to teach the judge what counts as a good program. Height is the share of mixed questions answered correctly, taller is better, with the model's own choice next to the trained judge.

0%20%40%60%80%Answer labels (pilot, 96 prompts)Answer labels (pilot, 96 prompts)60.4%64.6%State-exact labels (pilot)State-exact labels (pilot)60.4%60.4%Single-oracle labels (pilot)Single-oracle labels (pilot)60.4%60.4%Repair-focused labels (pilot)Repair-focused labels (pilot)60.4%60.4%Answer labels (main, 384 prompts)Answer labels (main, 384 prompts)59.4%60.2%

Takeaway → Three of five training rules leave the judge identical to the model; only rewarding a correct final answer nudged it above, and only slightly.

Data table
Training label objectiveFrozen compiler (base)Learned verifier
Answer labels (pilot, 96 prompts)60.4%64.6%
State-exact labels (pilot)60.4%60.4%
Single-oracle labels (pilot)60.4%60.4%
Repair-focused labels (pilot)60.4%60.4%
Answer labels (main, 384 prompts)59.4%60.2%

Numbers from experiments/qwen_context_trace_verifier/analysis/all_final_metrics.csv

Technical framing

Label-objective ablation: only answer-correct labels move the verifier at all — State-exact, single-oracle, and repair-focused labels all collapse to copying the base program; only answer labels change selections.

A rule-based scorer trails the model at every program length

How to read

The horizontal axis is how many steps the program takes, longer to the right. Height is the share answered correctly, taller is better. Three lines track a rule-based scorer, the model's own choice, and the trained judge.

0%20%40%60%80%678910Frozen compiler (base)Frozen compiler (…Learned verifierSoft-trace heuristicSoft-trace heuris…

Takeaway → The rule-based scorer line sits well below the other two at every length, ruling it out as a standalone way to pick the best program.

Data table
Program length (VM steps)Soft-trace heuristicFrozen compiler (base)Learned verifier
646.1%68.8%70.3%
832%50%46.9%
1023.4%40.6%35.2%

Numbers from experiments/qwen_context_trace_verifier/analysis/all_final_metrics.csv

Technical framing

Soft-trace executor heuristic underperforms even the base compiler at every program length — The differentiable-executor scoring baseline trails the base by 17-23 points everywhere, ruling it out as a selection signal on its own.

In the author’s words from the Report · “Abstract”

The candidate search contains answer-correct programs for 91.4% to 100.0% of the main evaluation prompts, so the executable candidate set has substantial reachable headroom. The learned verifier captures only small in-distribution gains and loses accuracy on paired and longer-chain splits. The bottleneck is therefore candidate selection and credit assignment, not candidate availability.

Overview

This standalone experiment tests whether a learned verifier can better select hidden-VM candidate traces when it receives prompt-conditioned Qwen hidden-state context in addition to candidate execution features.

Large checkpoints are stored outside this directory:

Local structure:

  • src/qwen_context_trace_verifier_experiment.py: run generator, training, and evaluation
  • src/analyze_qwen_context_trace_verifier.py: regenerate aggregate CSVs, figures, reports, and checkpoint manifest
  • runs/: per-run logs and metrics
  • analysis/: aggregate metrics and figures
  • reports/: standalone Markdown and HTML report
  • checkpoint_manifest.csv: checkpoint and artifact index

Regenerate analysis artifacts from completed runs:

python experiments/qwen_context_trace_verifier/src/analyze_qwen_context_trace_verifier.py

Report

Rendered from reports/qwen_context_trace_verifier_report.md

Abstract

This experiment tests a complete-program posttraining route for improving a frozen local Qwen compiler. A Qwen3-4B hidden-state adapter emits a compact virtual-machine program. Around that program, the system enumerates local executable edits and trains a small context-conditioned verifier to select the best candidate using only prompt hidden-state context, candidate features, and execution traces. The verifier never sees the target answer at inference time.

The result is diagnostic rather than successful. The candidate search contains answer-correct programs for 91.4% to 100.0% of the main evaluation prompts, so the executable candidate set has substantial reachable headroom. The learned verifier captures only small in-distribution gains and loses accuracy on paired and longer-chain splits. The bottleneck is therefore candidate selection and credit assignment, not candidate availability.

Question

Can a small posttraining module make a frozen Qwen-attached compiler select better complete programs by inspecting executable traces, without forcing the model to generate every intermediate reasoning step as text?

Method

  • Base model: Qwen/Qwen3-4B.
  • Value space: arithmetic over modulus 97 with up to 10 VM steps.
  • Frozen compiler: Qwen hidden states feed a trained hidden-VM compiler checkpoint.
  • Candidate generator: local edits around the compiler argmax program, with top-k alternatives and up to 2 edits.
  • Verifier input: candidate execution trace, scalar candidate features, and compact prompt hidden-state summaries.
  • Main verifier: 3 trace-transformer layers, width 128, 4 heads.
  • Main training set: 384 prompts, length range 1 to 6, positive label answer.
  • Main checkpoint selection: best validation learned accuracy; selected epoch 14.

The key baselines are:

  • base: the frozen compiler argmax program.
  • soft trace: a differentiable executor scoring heuristic.
  • learned: the trained verifier top-1 selection.
  • pair rerank: pair-level consistency reranking for paraphrase pairs.
  • oracle: any answer-correct candidate in the generated local neighborhood.

Main Results

splitbasesoft tracelearnedpair rerankoraclelearned gap recoveredavg candidatesanswer positives
validation mixed L659.4%43.0%60.2%n/a98.4%2.0%111.030.4
fresh standard L668.8%46.1%70.3%n/a98.4%5.3%111.030.3
fresh paraphrase L657.8%35.2%60.2%n/a100.0%5.6%111.027.9
fresh paired L657.3%43.2%55.2%54.7%98.4%-5.1%111.030.2
hard standard L850.0%32.0%46.9%n/a98.4%-6.5%179.044.7
hard paraphrase L838.3%27.3%35.9%n/a96.9%-4.0%179.043.2
harder standard L1040.6%23.4%35.2%n/a98.4%-9.5%263.047.6
harder paraphrase L1017.2%23.4%14.1%n/a91.4%-4.2%263.036.2

Main accuracy by split

Oracle gap recovered

Fresh length-6 standard prompts improved from 68.8% to 70.3%, a 1.6% absolute gain. Fresh length-6 paraphrase prompts improved from 57.8% to 60.2%. These gains are real but small relative to the oracle.

The same selector did not extrapolate. Fresh paired length-6 accuracy moved from 57.3% to 55.2%, a -2.1% absolute change. Harder standard length-10 moved from 40.6% to 35.2%, a -5.5% absolute change. The oracle stayed high on these splits, so the selector failed to locate available correct candidates.

Candidate Geometry

Candidate density

The candidate generator is broad. On length-6 fresh splits it produces about 111 candidates per prompt, with roughly 28 to 30 answer-correct candidates. On length-10 splits it produces 263 candidates per prompt, with many answer-correct candidates but far fewer state-exact or program-exact candidates. This explains why answer-only labels are easy to satisfy but weakly identify the best computational trace.

Objective Pilots

Pilot objective comparison

Several label objectives were tested before the main run:

  • Answer-correct labels learned a nontrivial selector on validation but were noisy because many candidates share the final answer.
  • State-exact labels were too conservative and mostly preserved the base program.
  • Single-oracle labels were sharper but still mostly preserved the base program.
  • Repair-focused weighting did not overcome the base-preservation tendency.

Validation curves

The main run eventually recovered the best validation learned accuracy at epoch 14, but validation gains were small while train accuracy rose strongly. That is the signature of a selector that can fit candidate artifacts without learning a robust preference rule for unseen prompts.

Domain Breakdown

domainbaselearnedoraclelearned delta
arithmetic31.2%34.4%96.9%3.1%
calendar37.5%40.6%100.0%3.1%
unit40.6%43.8%96.9%3.1%
list81.2%84.4%100.0%3.1%
boolean87.5%78.1%100.0%-9.4%
lookup65.6%65.6%100.0%0.0%

Domain breakdown

The verifier helped arithmetic, calendar, unit, and list prompts modestly, left lookup unchanged, and hurt boolean prompts. Boolean has many answer-correct candidates but relatively little trace-identifying signal because final answers collapse to few values.

Interpretation

This experiment answers one useful subquestion: local executable candidate search is not the limiting factor. The oracle remains high even when the base compiler is weak. The limiting factor is how to train a verifier that identifies the right complete program from a dense equivalence class of answer-correct candidates.

The current learned verifier is too passive. It sees traces and context, but its supervision says many different programs are equally good whenever they hit the final answer. Sharper labels alone did not fix this because the base program dominates many training groups and the correct non-base candidates are sparse. The result argues against scaling this exact reranker unchanged.

Most Impactful Next Options

  1. Train the selector from executable teacher traces, not just final answers. Use the oracle candidate to produce dense supervision over every intermediate state and operation, then train the verifier or compiler with a margin that explicitly ranks state-consistent candidates above answer-only candidates. This directly targets the observed dense-label failure.

  2. Convert reranking into preference learning on repairable failures. Filter training to groups where the base program is wrong and at least one non-base candidate is right, then train pairwise preferences with hard negatives that share the answer but diverge in state. This removes the base-preservation shortcut.

  3. Let Qwen read serialized candidate traces. Instead of only a small verifier, serialize a small shortlist of candidate programs and traces back into Qwen hidden states or text tokens, then train a LoRA selector head. This tests whether the frozen model already has the semantic machinery needed to choose among executable candidates when the candidates are made legible.

  4. Train a differentiable interpreter objective upstream. Backpropagate through the soft executor into the adapter with auxiliary losses on intermediate states, then use the discrete candidate oracle only for evaluation. This attacks the compiler's crystallized program quality rather than relying on post-hoc selection.

The first option is the cleanest next experiment because it directly matches the failure mode found here: answer-correct candidate availability is high, but answer-only selection is underdetermined.

Artifacts

Experiment log 1

Show the running log (1 entry, 2026-06-23)

2026-06-23

Objective: train and evaluate a context-conditioned learned verifier for local candidate traces emitted by a frozen Qwen-attached hidden VM compiler. The verifier uses candidate execution traces, compiler-local features, and compact Qwen hidden-state summaries from the prompt. Reports must be standalone.

Initial setup:

  • Created standalone experiment directory.
  • Copied the frozen mixed-domain trace compiler into this experiment's own large-artifact area: /workspace/large_artifacts/qwen_context_trace_verifier/checkpoints/fixed_mixed_vm_trace_compiler_s512.
  • Seeded local source from the mixed-domain verifier implementation and prepared to add context features, hard-negative contrastive loss, and optional paired training.
  • Patched the context-conditioned reranker path so context normalization statistics are returned, saved, and used during evaluation.
  • Switched the primary positive label from full trajectory exactness to final answer correctness, keeping state-exact and program-exact metrics as diagnostics. This aligns the experiment with complete-program candidate selection from executable answer labels.
  • Ran smoke_context_trace_reranker, a tiny Qwen-backed end-to-end smoke test. It loaded the fixed Qwen/Qwen3-4B hidden-VM compiler checkpoint, generated candidate groups, trained the reranker for two epochs, wrote run artifacts, and saved a small verifier checkpoint. Fresh paired length-3 base, learned, and pair-rerank accuracy were all 66.7%; oracle was 100.0%. This validates the pipeline and confirms there is answer-correct candidate headroom even at smoke scale.
  • Ran pilot_context_trace_reranker_s96 with answer-correct positives, length-6 fresh splits, length-8/10 hard splits, top-k 3, and two-edit candidate neighborhoods. Validation improved from 60.4% base to 64.6% learned, and hard standard improved from 54.2% to 56.2%, but fresh paired fell from 65.6% base to 57.8% learned; pair reranking recovered to 64.1%. Interpretation: answer-correct labels are dense, averaging 29.4 positives per 111 candidates on fresh paired, and are not sharp enough by themselves for robust top-1 selection.
  • Ran matched state-exact and oracle-selector pilots. State-exact training and single-oracle training mostly selected the base program everywhere, matching base accuracy on fresh and hard splits. Interpretation: sharper labels alone are insufficient when base-correct groups dominate the training signal.
  • Ran pilot_context_trace_reranker_s96_repairfocus, which used single-oracle positives with base-positive groups downweighted and repairable groups upweighted. This also mostly selected the base program. Interpretation: weighting alone did not expose a strong repair preference under the current feature and trace representation.
  • Ran main_context_trace_reranker_s384_answer, the main answer-label run with 384 training prompts, 128 validation prompts, 128 fresh/hard evaluation prompts, 96 paraphrase pairs, length-6 in-distribution evaluation, and length-8/10 extrapolation. Best validation epoch was 14. The learned selector improved validation from 59.4% to 60.2%, fresh standard length-6 from 68.8% to 70.3%, and fresh paraphrase length-6 from 57.8% to 60.2%. It degraded fresh paired length-6 from 57.3% to 55.2%, hard standard length-8 from 50.0% to 46.9%, hard paraphrase length-8 from 38.3% to 35.9%, harder standard length-10 from 40.6% to 35.2%, and harder paraphrase length-10 from 17.2% to 14.1%. Oracle answer-correct candidate availability stayed high, ranging from 91.4% to 100.0% across the main evaluation splits.
  • Generated aggregate CSVs, six figures, a standalone Markdown report, and a standalone HTML report with src/analyze_qwen_context_trace_verifier.py. The core conclusion is diagnostic: local executable candidate search has enough headroom, but answer-only verifier training is underdetermined and does not learn robust program selection for paired or longer-chain prompts.

Figures 6

accuracy by split
accuracy by split · analysis/figures/
candidate density
candidate density · analysis/figures/
domain breakdown
domain breakdown · analysis/figures/
oracle gap recovered
oracle gap recovered · analysis/figures/
pilot comparison
pilot comparison · analysis/figures/
validation curves
validation curves · analysis/figures/

Data files 14

Result tables and metrics copied from the experiment folder — preview inline or open the raw file.

Reproduce

The run commands are documented inside the experiment folder (see the README).

Browse the experiment folder on GitHub ↗