Research log Small Model Experimentation
GitHub

Qwen Typed Bytecode Expert Iteration

Self-checking helps, but worked examples win big

The one idea you need

The model turns a word problem into a short program a calculator runs exactly. It generates many programs and keeps any that reach the correct final answer to learn from — like a student trusting any scratch work that matches the answer key, even lucky shortcuts.

The question

If a small model can check whether the programs it writes reach the correct final answer, can learning from those wins match learning from full worked-out solutions?

What we found

It depends. Training the model only on its own attempts that landed on the correct final answer lifted unaided first-try accuracy from 62% to 73% on fresh problems — a real gain that sticks when it writes programs alone. But training on complete worked-out programs reached nearly 100%. Checking final answers helps for free, yet stalls far short of showing full solutions.

Why it matters

When you can score final answers but lack worked solutions, self-training on answer-verified attempts buys a real lift for free. But collect or synthesize complete worked solutions when you need near-perfect reliability, especially on longer multi-step problems.

Self-training lift on fresh problems62% → 73%unaided first-try accuracy, before vs after self-training rounds
Full worked-example ceiling~100%accuracy from training on complete worked-out programs (99.6%)
Same method on a real 4B model18% → 50%self-training on a frozen 4B model's readout, nearly tripling accuracy (17.6% to 50.4%)
Harder multi-step problems54% vs 81%self-training versus full worked solutions on longer compositional problems
On this page
  1. Results at a glance
  2. Overview
  3. Report
    1. Abstract
    2. Setup
    3. Main Results
    4. Expert-Iteration Curve
    5. Search Headroom
    6. Target Quality
    7. Frozen-Qwen Attached Pilot
    8. Interpretation
    9. Limitations
    10. Artifacts
  4. Experiment log
  5. Figures
  6. Data files
  7. Reproduce
  8. Related

Results at a glance 7

Self-checking lifts accuracy; full worked examples nearly max it out

How to read

Three groups left to right on fresh problems: starting point, after self-training, full worked examples. Each has two bars — the lighter is the model answering unaided, the darker is it allowed to guess-and-check toward the right answer. Taller is better.

0%25%50%75%100%seed (384 traces)seed (384 traces)61.5%81.6%expert iteration R4expert iteration R473%87.3%full supervised (4096 traces)full supervised (4096 traces)99.6%100%

Takeaway → The self-trained unaided bar climbs from 62% to 73%, but the full worked-example bars tower near 100%, dwarfing the self-training gain.

Data table
training regimedirect decodinganswer-verified search
seed (384 traces)61.5%81.6%
expert iteration R473%87.3%
full supervised (4096 traces)99.6%100%

Numbers from experiments/qwen_typed_bytecode_expert_iteration/analysis/final_metrics.csv

Technical framing

Expert iteration helps the deployable compiler, but dense traces nearly saturate — Answer-verified expert iteration lifts direct accuracy +11.5pp over the seed, but dense bytecode supervision reaches 99.6%.

Almost all the self-training gain arrives in the first round

How to read

Two rising lines track unaided accuracy across rounds of self-training, starting at round zero; higher is better. One line is ordinary fresh problems, the other is harder multi-step problems.

40%50%60%70%80%01234fresh pairedhard composition

Takeaway → Both lines jump at round one then flatten, and the harder-problems line stays well below, showing self-training stalls early and struggles with longer programs.

Data table
expert-iteration round (0 = seed)fresh pairedhard composition
061.5%45.9%
170.5%51.6%
270.5%52%
371.1%52.5%
473%53.9%

Numbers from experiments/qwen_typed_bytecode_expert_iteration/analysis/final_metrics.csv

Technical framing

Direct accuracy across expert-iteration rounds (same compiler, no search at test time) — Most of the gain arrives in round 1 and then plateaus; hard compositional prompts improve less than fresh paired ones.

Same pattern when the front end is a real 4B model

How to read

Three groups on fresh problems: starting point, self-trained, full worked examples. Each has two bars — the light bar is answering unaided, the dark bar is with guess-and-check. Taller is better.

0%25%50%75%100%Qwen seedQwen seed17.6%53.5%Qwen expert iteration R3Qwen expert iteration R350.4%74.2%Qwen full supervisedQwen full supervised94.5%99.2%

Takeaway → Self-training nearly triples unaided accuracy from 18% to 50%, but the full worked-example bar near 95% again far outreaches it.

Data table
training regime (bytecode head on frozen Qwen3-4B states)direct decodinganswer-verified search
Qwen seed17.6%53.5%
Qwen expert iteration R350.4%74.2%
Qwen full supervised94.5%99.2%

Numbers from experiments/qwen_typed_bytecode_expert_iteration/analysis/all_final_metrics.csv

Technical framing

Frozen-Qwen pilot: same pattern with a real 4B front end — With frozen Qwen hidden states, expert iteration nearly triples direct accuracy (+32.8pp) but dense traces still dominate.

The self-training loop runs out of fresh lessons

How to read

Two lines across rounds; higher means more. One is the share of training prompts where guess-and-check found a correct program, the other is the share of those that were genuinely new fixes rather than already-known answers.

0%50%100%150%1234answer-verified target found (of 4096 prompts)answer-verified t…target changed by search (of found targets)target changed by…

Takeaway → The found line climbs to 93% while the new-fix line collapses toward 5%, so later rounds mostly re-confirm what the model already knew.

Data table
expert-iteration roundanswer-verified target found (of 4096 prompts)target changed by search (of found targets)
183.1%26.3%
289%8.7%
391.3%6.1%
493.4%5.2%

Numbers from experiments/qwen_typed_bytecode_expert_iteration/analysis/expert_target_quality.csv

Technical framing

Expert-target quality over rounds (main run) — Search finds verified targets for 93% of prompts by round 4, but only 5% of found targets are new corrections - the loop runs out of fresh signal.

Guess-and-check stays ahead of unaided answering every round

How to read

Two lines across self-training rounds on fresh problems; higher is better. The lower line is the model answering unaided, the upper line is it allowed to guess-and-check toward the right answer.

50%60%70%80%90%01234Answer-verified searchAnswer-verified s…Direct decoding

Takeaway → The guess-and-check line starts about 20 points above the unaided line at the seed round, then settles into a 14-16 point lead through the later rounds, meaning fixable mistakes remain in the model's first answers.

Data table
Expert-iteration round (0 = seed)Direct decodingAnswer-verified search
061.5%81.6%
170.5%86.7%
270.5%85.5%
371.1%84.8%
473%87.3%

Numbers from experiments/qwen_typed_bytecode_expert_iteration/analysis/all_final_metrics.csv

Technical framing

Search keeps beating direct decoding through every round — A 14-16 point search-over-direct gap persists after four rounds, so the compiler still leaves repairable mistakes on the table.

Even full worked examples cannot fully crack harder problems

How to read

Four problem-type groups, each with two bars for the two model front ends after training on full worked examples; taller is better. The first three groups are ordinary problems, the last is harder multi-step ones.

0%25%50%75%100%Fresh standardFresh standard99.8%94.1%Fresh paraphraseFresh paraphrase99.6%96.1%Fresh pairedFresh paired99.6%94.5%Hard compositionHard composition80.7%75.8%

Takeaway → Both front ends near-max the first three groups but drop 15-20 points on the harder multi-step group, marking longer programs as the stubborn weak spot.

Data table
conditionCompact compiler (4,096 gold traces)Frozen-Qwen head (2,048 gold traces)
Fresh standard99.8%94.1%
Fresh paraphrase99.6%96.1%
Fresh paired99.6%94.5%
Hard composition80.7%75.8%

Numbers from experiments/qwen_typed_bytecode_expert_iteration/analysis/all_final_metrics.csv

Technical framing

Even dense supervision does not close the hard-composition split — Both front ends near-saturate fresh splits with dense traces, but longer compositional programs stay 15-20 points behind.

The 4B version finds fewer, messier self-taught lessons

How to read

Lines across rounds; higher means more. Two lines are the 4B version's share of prompts solved and share needing heavy rewriting; one line is the simpler main version's solved share for comparison.

20%40%60%80%100%1234Main compact run: target foundMain compact run:…Qwen head: target foundQwen head: target…Qwen head: target changed by searchQwen head: target…

Takeaway → The 4B version starts far lower and rewrites more heavily, but its solved line climbs toward the main version's, showing a slower version of the same trend.

Data table
Expert-iteration roundQwen head: target foundQwen head: target changed by searchMain compact run: target found
153.9%66.4%83.1%
266.7%50.5%89%
379.2%34.6%91.3%
493.4%

Numbers from experiments/qwen_typed_bytecode_expert_iteration/analysis/expert_target_quality.csv

Technical framing

Frozen-Qwen pilot finds fewer, noisier expert targets than the main run — The Qwen-attached head starts with far fewer verified targets and heavier search rewrites, but converges toward the main run's pattern.

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

On fresh paired prompts, the seed compiler reached 61.5%; expert iteration reached 73.0%; dense full supervision reached 99.6%.

Overview

Standalone experiment for a Qwen-oriented typed-bytecode training loop. The experiment tests whether exact execution and answer-verified program search can turn a weak text-to-bytecode compiler into a stronger deployable compiler.

Small artifacts live in this directory. Large checkpoints are stored under:

large_artifacts/qwen_typed_bytecode_expert_iteration/checkpoints/

Report

Rendered from reports/qwen_typed_bytecode_expert_iteration_paper.md

Abstract

This experiment tests a typed-bytecode posttraining recipe in a controlled text-to-program compiler. A compact transformer reads natural-language prompts and emits a fixed-length typed stack-machine program. The bytecode is validated and executed by an exact interpreter. The main question is whether answer-verified local search can create useful expert-iteration targets, and how that compares with dense supervised bytecode traces.

The primary run trained a seed compiler on 384 gold bytecode traces, then ran four rounds of answer-verified expert iteration over 4,096 generated training prompts. A separate full-supervised ceiling trained on 4,096 gold traces. On fresh paired prompts, the seed compiler reached 61.5%; expert iteration reached 73.0%; dense full supervision reached 99.6%.

Setup

  • Runtime: exact typed stack-machine bytecode over bounded i32 values modulo 97.
  • Opcodes: PUSH, arithmetic, comparisons, min/max, two lookup host calls, END, and PAD.
  • Domains: modular arithmetic, calendar offsets, unit scaling, list aggregation, boolean thresholds, and table lookup.
  • Compiler: compact transformer encoder/decoder over tokenized prompts and fixed program slots.
  • Qwen-attached pilot: frozen Qwen/Qwen3-4B hidden states with a trainable bytecode compiler head.
  • Expert iteration: local candidates are generated from compiler logits, executed, and accepted as training targets when their final answer matches the task answer.
  • Primary run: main_typed_bytecode_ei_s384_u4096.

Main Results

Training regimeSplitDirectSearchProgram exactTarget found
Seed supervisedFresh standard63.7%83.0%49.8%83.0%
Seed supervisedFresh paraphrase63.9%83.4%50.4%83.4%
Seed supervisedFresh paired61.5%81.6%43.4%81.6%
Seed supervisedHard composition45.9%72.9%35.5%72.9%
Expert iteration R4Fresh standard74.4%88.7%56.2%88.7%
Expert iteration R4Fresh paraphrase71.9%87.1%56.1%87.1%
Expert iteration R4Fresh paired73.0%87.3%51.0%87.3%
Expert iteration R4Hard composition53.9%76.2%39.5%76.2%
Full supervisedFresh standard99.8%100.0%99.6%100.0%
Full supervisedFresh paraphrase99.6%100.0%99.6%100.0%
Full supervisedFresh paired99.6%100.0%99.6%100.0%
Full supervisedHard composition80.7%91.2%72.3%91.2%

Direct regime bars

Expert-Iteration Curve

Answer-verified expert iteration produced a real deployable improvement, not just a search-time improvement. The same trained compiler is evaluated directly after each round.

Fresh paired progress

Direct phase lines

Search Headroom

Local answer-verified search remained substantially stronger than direct decoding through the expert-iteration rounds, which means the compiler still leaves repairable mistakes on the table.

Search phase lines

Target Quality

RoundTargetsFoundChangedCandidatesValid candidates
1340483.1%26.3%241.063.4%
2364789.0%8.7%241.063.8%
3374191.3%6.1%240.963.5%
4382493.4%5.2%240.963.8%

Expert target quality

Frozen-Qwen Attached Pilot

A companion pilot attached the same bytecode head to frozen Qwen/Qwen3-4B token hidden states. Only the bytecode head was trained; Qwen itself was not LoRA-tuned in this run. This checks whether the method still has signal when the text front end is a real 4B model representation.

Training regimeSplitDirectSearchProgram exactTarget found
Qwen seedFresh standard21.9%56.2%6.6%56.2%
Qwen seedFresh paraphrase16.0%53.1%3.5%53.1%
Qwen seedFresh paired17.6%53.5%4.3%53.5%
Qwen seedHard composition16.4%57.4%5.5%57.4%
Qwen expert iteration R3Fresh standard48.8%77.7%30.9%77.7%
Qwen expert iteration R3Fresh paraphrase43.8%76.2%27.7%76.2%
Qwen expert iteration R3Fresh paired50.4%74.2%34.4%74.2%
Qwen expert iteration R3Hard composition40.6%75.4%26.6%75.4%
Qwen full supervisedFresh standard94.1%98.0%92.2%98.0%
Qwen full supervisedFresh paraphrase96.1%99.6%94.5%99.6%
Qwen full supervisedFresh paired94.5%99.2%92.6%99.2%
Qwen full supervisedHard composition75.8%91.4%63.7%91.4%

Frozen-Qwen head progress

Qwen-head target quality:

RoundTargetsFoundChangedCandidatesValid candidates
1110353.9%66.4%241.064.0%
2136566.7%50.5%241.063.9%
3162179.2%34.6%241.064.4%

Interpretation

The result is positive for the typed-bytecode substrate and mixed for answer-only expert iteration. Dense bytecode traces are extremely effective: full supervision nearly saturates fresh standard, paraphrase, and paired splits. Expert iteration also helps, moving the seed compiler upward on every fresh split, but it does not approach the dense-trace ceiling. The frozen-Qwen pilot shows the same qualitative pattern: expert iteration improves the trainable Qwen-attached head, while dense bytecode supervision remains much stronger. This suggests that the next method improvement should focus on stronger process verification, multi-input consistency, or prefix-level search targets rather than merely increasing the number of final-answer-verified candidates.

The hard-composition split is the useful warning. Full supervision reached high but not saturated hard accuracy, while expert iteration improved less. This means the bytecode ABI is learnable, but longer or more compositional programs still need either more trace coverage or a better search/value loop.

Limitations

  • The primary controlled run uses a compact transformer compiler; the separate Qwen-attached pilot trains only a head on frozen Qwen hidden states, not Qwen LoRA weights.
  • The tasks are generated and bounded; they are not open-ended natural language reasoning tasks.
  • Answer verification uses known task answers during training-target construction.
  • Local search is slot-neighborhood search, not full program synthesis.
  • Final-answer verification can accept accidental programs that compute the right scalar answer without matching the intended program.

Artifacts

Small files:

Large files:

Experiment log 9

Show the running log (9 entries)

Setup

  • Created a standalone typed-bytecode expert-iteration experiment directory.
  • Required artifact layout: src/, runs/, analysis/, analysis/figures/, reports/, checkpoint_manifest.csv, and large checkpoints under large_artifacts/qwen_typed_bytecode_expert_iteration/checkpoints/.

Iterations

Smoke: smoke_typed_bytecode_ei

  • Purpose: validate the end-to-end script, logging, checkpoint layout, and typed VM execution.
  • Result: unconstrained slot decoding emitted invalid bytecode, so candidate search had no useful foothold.
  • Decision: add stack-depth-constrained bytecode decoding instead of training longer.

Smoke: smoke_typed_bytecode_ei_v2

  • Purpose: retest after typed/stack-constrained decoding.
  • Result: direct programs became valid often enough to measure, but the model was too small and undertrained for answer-verified search to collect useful targets.
  • Decision: move to a real pilot with more warm-start supervision.

Pilot: pilot_typed_bytecode_ei_s128

  • Purpose: test seed supervision, answer-verified expert iteration, and dense full supervision on a modest run.
  • Result: full supervision reached about 60% fresh paired direct accuracy and about 80% search accuracy; expert iteration was positive but weak.
  • Decision: isolate the dense supervised ceiling with larger trace coverage.

Pilot: pilot_supervised_ceiling_s2048

  • Purpose: determine whether the typed-bytecode target is learnable with enough dense traces.
  • Result: full supervision reached about 93-95% direct accuracy on fresh splits and about 98% with local search.
  • Decision: the bytecode ABI is learnable; focus the final run on whether answer-verified expert iteration compounds.

Pilot: pilot_expert_iteration_r3_s256

  • Purpose: run a larger answer-verified self-training loop with three rounds.
  • Result: fresh paired direct accuracy improved from 32.8% to 56.2%, while search improved from 66.8% to 79.7%.
  • Decision: run a larger main configuration combining four expert rounds and a dense supervised ceiling under the same evaluation splits.

Main: main_typed_bytecode_ei_s384_u4096

  • Purpose: final standalone measurement.
  • Result: fresh paired direct accuracy moved from 61.5% under the seed compiler to 73.0% after four expert-iteration rounds; dense full supervision reached 99.6%. Hard-composition direct accuracy moved from 45.9% to 53.9% under expert iteration and reached 80.7% under full supervision.
  • Decision: write up as a positive result for typed-bytecode supervision and a partial result for answer-only expert iteration. The next bottleneck is process verification or prefix-level search, not the bytecode ABI itself.

Frozen-Qwen Pilot: qwen_head_pilot_s384_u2048

  • Purpose: attach the typed-bytecode compiler head to frozen Qwen/Qwen3-4B hidden states rather than only using the compact controlled compiler.
  • Result: fresh paired direct accuracy improved from 17.6% under the seed Qwen-head compiler to 50.4% after three expert-iteration rounds. Dense full-supervised Qwen-head training reached 94.5% fresh paired direct accuracy.
  • Decision: include this as a Qwen-attached pilot in the standalone paper. The next step should train Qwen adapters or improve process verification; the frozen-head result shows signal but still leaves a large gap to dense traces.

Figures 6

direct accuracy by phase
direct accuracy by phase · analysis/figures/
direct regime bars
direct regime bars · analysis/figures/
expert target quality
expert target quality · analysis/figures/
fresh paired progress
fresh paired progress · analysis/figures/
qwen head fresh paired progress
qwen head fresh paired progress · analysis/figures/
search accuracy by phase
search accuracy by phase · analysis/figures/

Data files 18

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

Reproduce

This entry is source code or analysis only — there is no separate run to reproduce.

Browse the experiment folder on GitHub ↗