Research log Small Model Experimentation
GitHub

Qwen LoRA Parser Compiler

Small model shows its work but smudges the

The one idea you need

Picture tapping into a model's hidden scratchpad. A light, cheap retraining installs a reader that turns its internal states into a written arithmetic recipe: a starting number, each operation, and the number each step uses. The steps come through crisp; the numbers stay blurry.

The question

Can you cheaply retrain a small model so its internal states can be read as a trustworthy, step-by-step arithmetic program you could run yourself?

What we found

Partly. With step-by-step coaching, a small four-billion-parameter model's hidden states became a readable program: it named the starting number every time and picked the right operation about 98 percent of the time, while ordinary answer-only training stayed near zero. But the actual numbers came through only about 80 percent of the time per step, so exact recipes fell to zero by twelve steps.

Why it matters

If you want a small model's reasoning to be machine-readable, explicit per-step coaching really does install the interface, but audit each channel on its own. One noisy field compounds across steps and quietly kills exact multi-step execution.

Right operation chosenabout 98%which arithmetic step the model used, on four-step problems
Right number decoded per stepabout 80%the value each step uses — the bottleneck that sinks long chains
Fully correct four-step recipeabout 0% → 33-41%ordinary answer-only training versus step-by-step coaching
Fully correct twelve-step recipedrops to 0%per-step number errors compound as chains grow
On this page
  1. Results at a glance
  2. Overview
  3. Report
    1. Summary
    2. Setup
    3. Runs
    4. Main Result
    5. Interpretation
    6. Recommended Next Experiment
    7. Artifacts
  4. Experiment log
  5. Figures
  6. Data files
  7. Reproduce
  8. Related

Results at a glance 3

Short problems solved exactly: coached models versus plain-training controls

How to read

Bars show the share of four-step problems each training approach solves exactly; taller is better. Two colors mark standard versus reworded question wording. The two coached approaches on the left tower over the two plain-training controls on the right.

0%20%40%60%trace + executor (main)trace + executor (main)32.8%40.6%tagger pilottagger pilot17.2%32.8%answer-only compileranswer-only compiler0%0%direct final-answer QLoRAdirect final-answer QLoRA3.1%0%

Takeaway → Coached bars reach 33 to 41 percent while both controls sit near zero, so the readable recipe comes from the coaching, not from ordinary answer-fitting.

Data table
Training conditionstandard promptsparaphrase prompts
trace + executor (main)32.8%40.6%
tagger pilot17.2%32.8%
answer-only compiler0%0%
direct final-answer QLoRA3.1%0%

Numbers from experiments/qwen_lora_parser_compiler/analysis/final_metrics.csv

Technical framing

Exact-answer accuracy on length-4 programs: trace supervision vs controls — Explicit trace supervision makes hidden states compile to correct answers (33-41%); answer-only training stays near zero.

Exact-answer rate collapses as problems get longer

How to read

Each line tracks the share of problems solved exactly as length grows from four to twenty-four steps; higher is better. The two coached lines start well above the flat, near-floor answer-only control line, then slide down toward it.

0%20%40%60%5101520answer-only control, standardanswer-only contr…trace + executor, standardtrace + executor,…trace + executor, paraphrasetrace + executor,…

Takeaway → Both coached lines fall to near zero by twelve steps, showing tiny per-step errors pile up and wreck long problems even when short ones work.

Data table
Program length (steps)trace + executor, standardtrace + executor, paraphraseanswer-only control, standard
432.8%40.6%0%
810.9%6.2%1.6%
120%4.7%3.1%
240%0%3.1%

Numbers from experiments/qwen_lora_parser_compiler/analysis/final_metrics.csv

Technical framing

Executor accuracy collapses with program length — Per-step argument errors compound: exact execution is near zero by 12 steps even though the interface works at length 4.

Which parts of the recipe the model reads cleanly

How to read

Each line shows how accurately one piece of the recipe reads as problems lengthen; higher is better. The starting-number line stays pinned at the top, the operation line sits just below, and the step-number line trails lowest.

60%70%80%90%100%110%5101520initial valueoperationargument value

Takeaway → The step-number line sits near 80 percent and keeps sliding while the starting-number line holds perfect and the operation line stays high, pinpointing number-reading as the weak link.

Data table
Program length (steps)initial valueoperationargument value
4100%97.7%79.7%
8100%97.7%77.9%
12100%94%70.7%
24100%81.4%67.4%

Numbers from experiments/qwen_lora_parser_compiler/analysis/final_metrics.csv

Technical framing

Which program symbols the parser decodes (main condition, standard prompts) — Initial values and operations decode almost perfectly; noisy argument-value decoding (~80% and falling) is the bottleneck.

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

The full trace+executor condition reached 32.8% standard length-4 executor accuracy and 40.6% paraphrase length-4 accuracy, while direct final-answer QLoRA and answer-only compiler training stayed near chance. The failure mode is also clear: argument value decoding is not accurate enough. It remains near 80% on length-4 programs and falls with length, which compounds into near-zero exact programs by length 12. The experiment supports a narrow claim: explicit parser supervision can make a small QLoRA-adapted model expose a partial symbolic program in hidden states. It does not support a broad claim of large universal intelligence improvement from this recipe.

Overview

Standalone QLoRA-attached parser/compiler experiment.

The experiment tests whether live LoRA updates on a small causal language model can make its hidden states readable as a symbolic modular-arithmetic program. The pilot gate is a token-role and symbol tagger trained through the model; the full condition adds a differentiable executor that compiles predicted program symbols into the final answer.

Layout

src/qwen_lora_parser_compiler_experiment.py     training and evaluation harness
src/analyze_qwen_lora_parser_compiler.py        run aggregation and plots
runs/                                           lightweight JSON and CSV outputs
reports/                                        experiment log and standalone write-up
analysis/                                       aggregate tables and figures

Large checkpoints are stored outside the experiment directory:

large_artifacts/qwen_lora_parser_compiler/checkpoints/

Reading Order

  1. reports/qwen_lora_parser_compiler_paper.md
  2. analysis/summary.md
  3. analysis/final_metrics.csv
  4. reports/qwen_lora_parser_compiler_experiment_log.md

Large Artifacts

You only need the large artifact directory to load adapters or resume/evaluate a checkpoint. The main trained condition is:

large_artifacts/qwen_lora_parser_compiler/checkpoints/main_qwen3_4b_qlora_trace_argstrong_mixed_l12/

The checkpoint manifest is:

experiments/qwen_lora_parser_compiler/checkpoint_manifest.csv

Report

Rendered from reports/qwen_lora_parser_compiler_paper.md

Summary

This experiment tested whether QLoRA posttraining can install a small symbolic interface on top of Qwen/Qwen3-4B. The model was trained live with LoRA adapters while a parser read the final hidden sequence and emitted a modular-arithmetic program: an initial value, ordered operations, and ordered arguments. A differentiable executor then ran the predicted program modulo 97.

The result is mixed. Trace supervision created a real, measurable program interface that ordinary final-answer training did not discover. The full trace+executor condition reached 32.8% standard length-4 executor accuracy and 40.6% paraphrase length-4 accuracy, while direct final-answer QLoRA and answer-only compiler training stayed near chance. The failure mode is also clear: argument value decoding is not accurate enough. It remains near 80% on length-4 programs and falls with length, which compounds into near-zero exact programs by length 12.

The experiment supports a narrow claim: explicit parser supervision can make a small QLoRA-adapted model expose a partial symbolic program in hidden states. It does not support a broad claim of large universal intelligence improvement from this recipe.

Setup

  • Base model: Qwen/Qwen3-4B
  • Loading: 4-bit NF4 quantization
  • Trainable model update: LoRA rank 8, alpha 16, dropout 0.05, target all-linear
  • Task: synthetic text instructions for arithmetic modulo 97
  • Train lengths: 1-12 steps
  • Evaluation lengths: 4, 8, 12, 24 steps
  • Evaluation templates: standard and paraphrase
  • Evaluation size: 64 examples per split
  • Large checkpoint storage: large_artifacts/qwen_lora_parser_compiler/checkpoints/

The parser predicts:

  • token positions for the initial value, each operation, and each argument;
  • symbols for the initial value, operation class, and argument value;
  • an answer distribution through exact differentiable modular execution.

Runs

RunVariantPurpose
pilot_qwen3_4b_qlora_tagger_mixed_l12qlora_taggerPilot gate: learn token roles and program symbols with trace supervision only.
main_qwen3_4b_qlora_trace_argstrong_mixed_l12qlora_traceFull condition: trace supervision plus differentiable executor loss, with stronger argument supervision.
control_qwen3_4b_direct_mixed_l12directOrdinary final-answer QLoRA control using an answer-marker hidden-state classifier.
control_qwen3_4b_qlora_answer_only_mixed_l12qlora_answer_onlyCompiler/executor trained from final-answer loss only, without trace supervision.

Smoke runs are present only to verify the harness and checkpoint path.

Main Result

Full Trace+Executor Condition

SplitExecutorInitOpArgProgram Exact
Standard L432.8%100.0%97.7%79.7%32.8%
Standard L810.9%100.0%97.7%77.9%9.4%
Standard L120.0%100.0%94.0%70.7%0.0%
Standard L240.0%100.0%81.4%67.4%0.0%
Paraphrase L440.6%100.0%96.9%82.4%40.6%
Paraphrase L86.2%100.0%97.7%75.8%6.2%
Paraphrase L124.7%100.0%90.5%69.3%0.0%
Paraphrase L240.0%100.0%75.5%53.1%0.0%

The parser learned initial values and operations well. It also usually located argument tokens. The blocker is argument value decoding. A per-step argument error rate around 20-45% makes exact execution collapse as program length grows.

Token-Tagger Pilot

SplitExecutorInitOpArgOp PosArg PosProgram Exact
Standard L417.2%96.9%98.0%76.2%100.0%89.5%17.2%
Standard L83.1%98.4%94.9%73.8%100.0%85.2%0.0%
Standard L120.0%96.9%95.6%68.8%100.0%82.4%0.0%
Standard L241.6%100.0%88.2%65.4%90.2%77.4%0.0%
Paraphrase L432.8%98.4%99.2%77.7%100.0%94.5%32.8%
Paraphrase L817.2%95.3%99.0%77.5%100.0%93.0%15.6%
Paraphrase L120.0%100.0%99.2%71.6%100.0%91.7%0.0%
Paraphrase L241.6%93.8%97.0%71.2%99.4%87.3%0.0%

This pilot passed the narrow gate: QLoRA plus trace heads can make Qwen hidden states parseable. It did not pass the stronger gate needed for long exact execution.

Controls

RunStandard L4Standard L8Standard L12Standard L24Paraphrase L4Paraphrase L8Paraphrase L12Paraphrase L24
Direct final-answer QLoRA3.1%0.0%0.0%1.6%0.0%0.0%1.6%0.0%
Answer-only compiler0.0%1.6%3.1%3.1%0.0%1.6%0.0%0.0%

The controls stayed at chance. The learned structure in the trace-supervised runs is therefore not explained by ordinary answer fitting, and the compiler interface was not discovered from final-answer loss alone.

Interpretation

The useful signal is not the final executor score by itself. The useful signal is that explicit trace supervision made internal hidden states reliably expose parts of a program:

  • Initial value decoding reached 100.0% in the full condition.
  • Operation decoding stayed high through length 12 and degraded at length 24.
  • Argument token localization was usually high.
  • Argument value decoding was the unresolved bottleneck.

This is an important distinction. The experiment did not fail because the parser could not find the computation. It failed because the numeric argument channel was too noisy for exact multi-step execution. With 8 or 12 steps, even a good but imperfect per-step argument classifier produces very few exact programs.

The result suggests the next experiment should not add more recurrence or a larger executor first. The highest-leverage change is to replace the weak argument-value readout with a stronger numeric interface.

Run a numeric-copy compiler variant:

  1. Keep the same QLoRA parser and role supervision.
  2. Add an auxiliary numeric-token decoder for argument values, separate from the semantic hidden-state classifier.
  3. Add a constrained value head that only predicts valid generated argument ranges for each operation class.
  4. Evaluate whether argument accuracy can exceed 95% at length 8 before running longer chains.

Success criterion:

  • argument value accuracy above 95% at L8;
  • program exact above 50% at L8;
  • direct and answer-only controls still near chance.

This is the shortest path to determining whether the symbolic interface is fundamentally useful or merely limited by the current numeric readout.

Artifacts

Small files:

Large files:

  • Pilot adapter and heads: large_artifacts/qwen_lora_parser_compiler/checkpoints/pilot_qwen3_4b_qlora_tagger_mixed_l12/
  • Full trace+executor adapter and heads: large_artifacts/qwen_lora_parser_compiler/checkpoints/main_qwen3_4b_qlora_trace_argstrong_mixed_l12/
  • Direct control adapter and heads: large_artifacts/qwen_lora_parser_compiler/checkpoints/control_qwen3_4b_direct_mixed_l12/
  • Answer-only compiler control adapter and heads: large_artifacts/qwen_lora_parser_compiler/checkpoints/control_qwen3_4b_qlora_answer_only_mixed_l12/

Experiment log 7

Show the running log (7 entries, 2026-06-21)

Objective

Test whether live QLoRA updates can make a small causal language model expose a clean modular-arithmetic program in its hidden states, and whether a learned compiler/executor can use that program to answer longer arithmetic chains.

Experiment Question

Can a LoRA-adapted model learn token-level roles and program symbols for synthetic arithmetic instructions well enough to support a compiled executor, including on paraphrased prompts and longer held-out chains?

Planned Gates

  1. Token-tagger pilot: train QLoRA plus parser heads on init, operation, argument, and token-position supervision.
  2. Parser/executor condition: add differentiable execution loss on the predicted modular program.
  3. Answer-only control: train the same QLoRA substrate without trace supervision.

Primary Metrics

  • init_pos_accuracy, op_pos_accuracy, arg_pos_accuracy: whether the parser attends to the intended source tokens.
  • init_accuracy, op_accuracy, arg_accuracy: whether those tokens are decoded into correct program symbols.
  • program_exact: whether the whole predicted program is exact.
  • executor_accuracy: whether compiled execution returns the correct answer.
  • Standard and paraphrase splits are evaluated separately at multiple chain lengths.

Artifact Policy

Lightweight outputs stay in experiments/qwen_lora_parser_compiler/runs/.

Large adapter and head checkpoints stay in large_artifacts/qwen_lora_parser_compiler/checkpoints/.

Log

2026-06-21

  • Created standalone experiment directory and large-artifact checkpoint path.
  • Added a live QLoRA training harness with a token-tagger pilot variant and parser/executor variants.
  • Tightened the synthetic generator so operation-position labels point at the operation token rather than the end of the surrounding phrase.
  • Tiny random LoRA smoke test passed and wrote runs/smoke_tiny_tagger/results.json.
  • Qwen 3 4B 4-bit LoRA micro-smoke passed and wrote runs/smoke_qwen3_4b_qlora_tagger/results.json.
  • Qwen QLoRA token-tagger pilot completed as runs/pilot_qwen3_4b_qlora_tagger_mixed_l12/.

    • Operation symbols were mostly solved: 88.2-99.2% across final splits.
    • Argument positions were mostly found: 77.4-94.5%.
    • Argument values remained the limiting error: 65.4-77.7%.
  • Qwen QLoRA trace+executor condition completed as runs/main_qwen3_4b_qlora_trace_argstrong_mixed_l12/.

    • Short-chain executor accuracy improved over the tagger-only pilot.
    • Standard length-4 reached 32.8%; paraphrase length-4 reached 40.6%.
    • Length-8 remained weak and length-12/24 remained near zero.
    • Argument value accuracy remained the main bottleneck.
  • Direct final-answer QLoRA control completed as runs/control_qwen3_4b_direct_mixed_l12/.

    • Final accuracy stayed near chance on every split.
  • Answer-only compiler control completed as runs/control_qwen3_4b_qlora_answer_only_mixed_l12/.

    • Final executor accuracy stayed near chance and the parser did not discover useful symbols.
  • Regenerated aggregate analysis and checkpoint manifest.
  • Wrote standalone Markdown and HTML reports.
  • Recommended next step: a numeric-copy compiler variant that directly targets the argument-value bottleneck.

Figures 3

direct accuracy
direct accuracy · analysis/figures/
executor accuracy
executor accuracy · analysis/figures/
program exact
program exact · analysis/figures/

Data files 7

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 ↗