Research log Small Model Experimentation
GitHub

Qwen Teacher-Distilled Slot Compiler

Pointing to where the numbers sit didn't help

The one idea you need

The model acts like a clerk working a 24-line arithmetic worksheet: each line, it lifts one number and one operation out of written wording and runs them in order. The extra training highlighted exactly where each number sat on the page. But the clerk already found them.

The question

If a model already knows which numbers to pull out of a written multi-step math problem, does training that points to exactly where each one sits make it more accurate?

What we found

No. A model trained to copy numbers and operations out of text and run a 24-step calculation got 27% of final answers exactly right; adding the pointing signal landed at 28%, a tie. Worse, agreement between two rewordings of the same problem fell from 73% to 56%. A lighter version of the signal was clearly worse, at 18%.

Why it matters

When a system copies structured values out of text and chains them, do not add supervision on where values sit once the model already locates them over 90% of the time. Spend effort catching and repairing the small copy slips that compound across steps.

Correct final answers: plain training vs pointing signal27% → 28%a tie on 24-step problems, not a win
Agreement between two rewordings of the same problem73% → 56%the pointing signal made consistency worse
How often the model already found the right number to copyabout 93-95%locating numbers was not the bottleneck
Weakest signal setting when the wording changed27% → 12%one setup collapses under rewording
On this page
  1. Results at a glance
  2. Overview
  3. Report
    1. Abstract
    2. Question
    3. Method
    4. Results
    5. Interpretation
    6. Conclusion
  4. Experiment log
  5. Figures
  6. Data files
  7. Reproduce
  8. Related

Results at a glance 3

Extra pointing hints do not beat plain training

How to read

Three clusters, one per training setup: plain training and two hint-added versions. In each cluster, one bar is how often the final answer is exactly right, the other how often two rewordings of the same problem agree. Taller is better.

0%20%40%60%80%no-teacher controlno-teacher control27.1%72.7%teacher slot distillteacher slot distill27.9%55.5%soft-position-only teachersoft-position-only teacher18.4%41%

Takeaway → The exact-answer bars for plain and full-hint training tie while the light-hint bar sits clearly lower, and plain training's agreement bar towers over both hint versions, so the hints added nothing and cost consistency.

Data table
training armexact executionpaired state consistency
no-teacher control27.1%72.7%
teacher slot distill27.9%55.5%
soft-position-only teacher18.4%41%

Numbers from analysis/selected_retest_metrics.csv (fresh_paired_len24 rows)

Technical framing

Teacher slot distillation does not beat the no-teacher control (fresh length-24 retest) — The teacher arms match or lose to the control on exact execution and are clearly worse on paraphrase-pair consistency.

Accuracy falls as problems get longer, for every setup

How to read

Horizontal axis is how many steps the problem has; vertical axis is how often the final answer comes out exactly right. Each line is one training setup; higher and flatter is better.

0%25%50%75%100%5101520no-teacher controlteacher slot distillteacher slot dist…soft-position-only teachersoft-position-onl…

Takeaway → All three lines drop steeply from short to long problems and sit almost on top of each other, so length, not missing hints, drives the failures.

Data table
program length (operations)no-teacher controlteacher slot distillsoft-position-only teacher
486.7%85.9%86.7%
861.7%62.5%62.5%
1259.4%60.2%60.2%
2423.4%22.7%18.8%

Numbers from analysis/summary.md final-metrics table (paired_len4/8/12/24 rows, executor_accuracy)

Technical framing

Exact execution degrades with program length in much the same way across arms — All three arms decay similarly as programs get longer (the soft-position arm dips most at length 24), so local slot imitation is not the bottleneck.

One hint version breaks when the problem is reworded

How to read

Two groups compare original wording against reworded wording. Inside each group, one bar per training setup shows how often the final answer is exactly right; a big drop from left to right means that setup is fragile to rewording.

0%10%20%30%40%standard wordingstandard wording30.5%30.5%27%paraphrased wordingparaphrased wording27.7%28.1%11.7%

Takeaway → The lighter-hint bar collapses from about a quarter correct to roughly one in nine when reworded, while the other two setups barely move.

Data table
prompt renderingno-teacher controlteacher slot distillsoft-position-only teacher
standard wording30.5%30.5%27%
paraphrased wording27.7%28.1%11.7%

Numbers from analysis/selected_retest_metrics.csv (fresh_standard_len24 and fresh_paraphrase_len24 rows)

Technical framing

The soft-position-only teacher is fragile under paraphrase (fresh length-24 retest) — Control and full-teacher arms lose only ~2-3 points to paraphrase; the soft-position-only arm collapses from 27% to 12%.

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

This experiment tests whether oracle slot-teacher losses improve a QLoRA-adapted Qwen/Qwen3-4B compiler on synthetic modular-arithmetic programs. The compiler reads the full prompt hidden sequence, predicts executable slots, copies numbers and operations, and executes the copied program modulo 97. The teacher variants add auxiliary supervision for slot localization, with one arm also matching oracle token representations. The result is negative. On fresh length-24 paired standard/paraphrase programs, the matched no-teacher control scored 27.1% exact execution with 72.7% paired compiler-state consistency. The heavier teacher arm scored 27.9% exact execution but only 55.5% consistency. … Read the full result →

Overview

Standalone experiment testing whether an oracle slot teacher improves a QLoRA-adapted Qwen/Qwen3-4B numeric-copy compiler on long modular-arithmetic programs.

The student compiler reads the full prompt hidden sequence, predicts ordered executable slots, copies numeric and operation symbols from token-level maps, and executes the copied program modulo 97. The teacher condition adds two auxiliary signals during training:

  • soft local position targets around the oracle slot span;
  • slot-representation matching between the student-attended slot vector and the oracle token vector.

Main Result

Teacher slot distillation did not beat the matched no-teacher control on fresh length-24 paired programs. The control scored 27.1% exact execution and 72.7% paired compiler-state consistency. The heavier teacher arm scored 27.9% exact execution but only 55.5% consistency. The low-weight soft-position-only teacher arm scored 18.4% exact execution and 41.0% consistency.

The practical takeaway is that local oracle slot imitation is not the current bottleneck; the next experiment should target execution-level repair or verifier-guided search.

Layout

src/qwen_teacher_distilled_slot_compiler_experiment.py  training and evaluation harness
src/analyze_qwen_teacher_distilled_slot_compiler.py     aggregation, selected checkpoint table, and plots
src/evaluate_selected_qwen_teacher_distilled_slot_compiler.py
                                                        fresh retest for selected checkpoints
runs/                                                   lightweight JSON and CSV outputs
analysis/                                               aggregate CSVs and generated figures
reports/                                                experiment log and standalone write-up
checkpoint_manifest.csv                                 generated list of large checkpoint files

Large checkpoints are stored outside the experiment directory:

large_artifacts/qwen_teacher_distilled_slot_compiler/checkpoints/

Main Metrics

  • executor_accuracy: exact final answer after copying and executing the compiled program.
  • program_exact: exact full compiled-program correctness.
  • arg_accuracy: per-argument copied value accuracy.
  • arg_pos_accuracy: per-argument slot localization accuracy.
  • compiler_pair_state_consistency: whether standard and paraphrased renderings compile to the same complete state trajectory.
  • selected_checkpoint: saved checkpoint chosen by paired_len24_executor_accuracy.

Reading Order

  1. reports/qwen_teacher_distilled_slot_compiler_experiment_log.md
  2. analysis/summary.md
  3. analysis/selected_checkpoints.csv
  4. analysis/selected_retest_metrics.csv
  5. analysis/final_metrics.csv
  6. reports/qwen_teacher_distilled_slot_compiler_paper.md

Report

Rendered from reports/qwen_teacher_distilled_slot_compiler_paper.md

Abstract

This experiment tests whether oracle slot-teacher losses improve a QLoRA-adapted Qwen/Qwen3-4B compiler on synthetic modular-arithmetic programs. The compiler reads the full prompt hidden sequence, predicts executable slots, copies numbers and operations, and executes the copied program modulo 97. The teacher variants add auxiliary supervision for slot localization, with one arm also matching oracle token representations.

The result is negative. On fresh length-24 paired standard/paraphrase programs, the matched no-teacher control scored 27.1% exact execution with 72.7% paired compiler-state consistency. The heavier teacher arm scored 27.9% exact execution but only 55.5% consistency. The lower-weight soft-position-only arm scored 18.4% exact execution and 41.0% consistency. Oracle slot imitation did not improve the selected checkpoint and often made paraphrase-invariant compilation worse.

Question

Can a Qwen-attached numeric compiler bind executable slots more reliably when ordinary trace and state supervision are augmented with oracle slot-teacher losses?

The hypothesis was that a substantial part of the remaining error came from misbinding surface tokens to executable slots. If true, teacher losses should improve long-chain execution and standard/paraphrase consistency, especially on length-24 programs where one copied-step error usually corrupts the final answer.

Method

All main runs used Qwen/Qwen3-4B with 4-bit QLoRA adapters, a copied-symbol program compiler head, a deterministic modular executor, and the same synthetic program curriculum:

StageLength rangeSteps
short1-4200
medium1-8200
train1-12200
long8-24300

The model was trained with paired standard/paraphrase examples and selected by highest validation paired_len24_executor_accuracy. Large adapter and head checkpoints are stored outside the experiment directory under large_artifacts/qwen_teacher_distilled_slot_compiler/checkpoints/.

Three main arms were run:

RunTeacher position weightTeacher representation weightDescription
main_control_light_state_s9000.000.00Matched light-state compiler control
main_teacher_slot_distill_s9000.100.05Soft local position targets plus oracle slot-representation matching
main_teacher_softpos_low_s9000.030.00Lower-weight soft position targets only

The primary held-out retest used 256 fresh length-24 programs per single-rendering split and 256 paired programs rendered in both standard and paraphrased forms, giving 512 examples in the paired row.

Results

Selected Validation Checkpoints

RunSelected stepPaired L24 exactPaired state consistencyStandard L24 exactParaphrase L24 exact
Control80030.5%67.2%37.5%25.0%
Teacher position + representation80028.1%59.4%37.5%21.9%
Low soft-position only80023.4%32.8%29.7%15.6%

The matched control was the best validation-selected arm. Both teacher variants selected the same training step but had lower paired exact execution and lower paired compiler-state consistency.

Fresh Selected-Checkpoint Retest

RunFresh standard L24 exactFresh paraphrase L24 exactFresh paired L24 exactFresh paired state consistency
Control30.5%27.7%27.1%72.7%
Teacher position + representation30.5%28.1%27.9%55.5%
Low soft-position only27.0%11.7%18.4%41.0%

The heavier teacher arm had a tiny fresh paired exact-execution edge over the control, 27.9% versus 27.1%, but this is not a useful win: it came with a large consistency loss, and its selected validation metric was lower. The low-weight position-only arm was clearly worse on the fresh retest, especially on paraphrased prompts.

Interpretation

The teacher losses did not address the dominant bottleneck. The compiler already achieved near-perfect initialization and operation localization, and argument localization stayed around 93-95% at length 24 in the main arms. The remaining failure mode is therefore not simply "the model cannot find the right token." Small residual copy errors compound across 24 steps, and the paired consistency metrics show that the learned compiler is still sensitive to surface rendering.

The representation-matching teacher likely over-constrained the compiler to prompt-surface-specific hidden vectors. That explains why the heavier teacher arm tied answer accuracy but lost paired compiler-state consistency. The low-weight soft-position-only arm briefly improved mid-training transfer at step 600, but the effect did not survive checkpoint selection or fresh retesting.

Conclusion

Oracle slot imitation is not the highest-leverage next direction for this Qwen-attached compiler. It can provide a transient curriculum signal, but it does not improve the best selected checkpoint and can damage paraphrase-invariant compilation.

The most impactful next experiment should move from slot imitation to execution-level pressure:

  1. Train the compiler with verifier-guided self-correction or search over copied slots, so the model learns from execution failures rather than only from local token labels.
  2. Add a differentiable or sampled repair loop that proposes alternate arguments for low-confidence slots and backpropagates or reinforces the execution result.
  3. Use a short policy-gradient stage over compiled programs with a strong supervised anchor, rewarding exact final execution and paired standard/paraphrase program agreement.

The practical recommendation is to start with verifier-guided slot repair, because it directly targets the observed failure mode: high per-slot accuracy that still collapses under long-chain composition.

Experiment log 9

Show the running log (9 entries, 2026-06-22)

Objective

Test whether oracle slot-teacher losses improve a Qwen numeric-copy compiler's long-chain exact execution and paired paraphrase consistency.

Experiment Question

Can a text compiler bind executable slots more reliably when hard trace supervision is augmented with soft local oracle slot targets and slot-representation matching?

Planned Conditions

  1. Tiny-model smoke test for teacher losses and checkpoint snapshots.
  2. Qwen smoke test for 4-bit QLoRA teacher training.
  3. Matched light-state control with no teacher losses.
  4. Teacher-distilled light-state compiler with soft position and representation losses.
  5. Low-weight soft-position-only teacher arm.
  6. Fresh selected-checkpoint retest on length-24 programs.

Primary Selection Rule

Select the saved checkpoint with the highest paired_len24_executor_accuracy.

Primary Metrics

  • paired_len24_executor_accuracy
  • fresh_paired_len24_executor_accuracy
  • fresh_paired_len24_compiler_pair_state_consistency
  • arg_accuracy
  • arg_pos_accuracy
  • program_exact

Artifact Policy

Lightweight outputs stay in:

experiments/qwen_teacher_distilled_slot_compiler/runs/
experiments/qwen_teacher_distilled_slot_compiler/analysis/
experiments/qwen_teacher_distilled_slot_compiler/reports/

Large adapters and head checkpoints stay in:

large_artifacts/qwen_teacher_distilled_slot_compiler/checkpoints/

Log

2026-06-22

  • Created standalone experiment directory.
  • Forked the checkpoint-selected Qwen numeric-copy compiler harness into a teacher-distilled slot harness.
  • Added soft oracle position teacher losses.
  • Added oracle slot-representation matching losses.
  • Added standalone README and experiment log.
  • Ran smoke_tiny_teacher with a tiny frozen causal LM. The run completed, saved validation checkpoints, generated analysis outputs, and confirmed that teacher position and representation losses are present in the train log.
  • Ran smoke_qwen3_4b_teacher with Qwen/Qwen3-4B, 4-bit QLoRA, state loss weight 0.25, teacher position weight 0.1, and teacher representation weight 0.05. The run completed, saved real adapter checkpoints, and showed teacher losses in a reasonable scale relative to the total loss.
  • Ran main_control_light_state_s900, the matched light-state control with no teacher losses. The selected checkpoint is step 800 with 30.5% paired length-24 exact execution, 67.2% paired state consistency, 37.5% standard length-24 exact execution, and 25.0% paraphrase length-24 exact execution. The final checkpoint fell to 23.4% paired length-24.
  • Ran main_teacher_slot_distill_s900 with teacher position weight 0.1 and teacher representation weight 0.05. The selected checkpoint is step 800 with 28.1% paired length-24 exact execution, 59.4% paired state consistency, 37.5% standard length-24 exact execution, and 21.9% paraphrase length-24 exact execution. The final checkpoint fell to 22.7% paired length-24.
  • Ran a fresh selected-checkpoint retest for the matched control and heavier teacher arms at length 24 with eval_size=256 and eval_seed=92001. The control scored 27.1% paired exact execution and 72.7% paired state consistency. The heavier teacher arm scored 27.9% paired exact execution and 55.5% paired state consistency. The answer accuracy difference was tiny, but the teacher arm lost substantial paired compiler consistency.
  • Added and ran main_teacher_softpos_low_s900 after inspecting the heavier teacher result. This arm removes representation matching and uses only a low soft-position teacher weight of 0.03. It briefly improved mid-training length-24 transfer at step 600: 13.3% paired length-24 exact execution versus 1.6% for the matched control at the same step. The selected checkpoint was still step 800 and underperformed the control: 23.4% paired length-24 exact execution, 32.8% paired state consistency, 29.7% standard length-24 exact execution, and 15.6% paraphrase length-24 exact execution.
  • Ran the same fresh selected-checkpoint retest for main_teacher_softpos_low_s900. It scored 18.4% paired length-24 exact execution and 41.0% paired state consistency. This confirms that low-weight soft slot supervision did not improve the selected checkpoint and damaged paraphrase robustness.

Result

Oracle slot-teacher losses did not beat the matched no-teacher light-state compiler. The best fresh paired length-24 exact execution was effectively tied between the control and the heavier teacher arm, 27.1% versus 27.9%, while paired state consistency dropped from 72.7% to 55.5%. The low-weight soft-position-only variant was worse at 18.4% paired exact execution and 41.0% paired state consistency.

The most useful observation is negative: the compiler already localizes symbols well enough that extra oracle slot imitation is not the current bottleneck. The next experiment should move the training signal closer to execution correctness or search, rather than adding more slot-position supervision.

Figures 5

direct accuracy
direct accuracy · analysis/figures/
executor accuracy
executor accuracy · analysis/figures/
program exact
program exact · analysis/figures/
state all exact
state all exact · analysis/figures/
state prefix fraction
state prefix fraction · analysis/figures/

Data files 9

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 ↗