Qwen3.5-0.8B-toolpatch-g23v3
Qwen/Qwen3.5-0.8B (revision 2fc06364715b967f1860aea9cf38778875588b17) with one closed-form weight edit: two near-dead neurons of the last MLP (model.language_model.layers.23.mlp, neurons 3468 and 3421) are re-purposed as a gated readout that makes the model answer NO_TOOL on explanation requests and NEED_CLARIFICATION when a required argument is explicitly missing, instead of emitting a <tool_call> with an invented argument. 6,142 BF16 entries changed (0.00082 % of the 752 M text-model parameters), in three tensors, with zero gradient steps: every number was computed from captured activations by difference of means, orthogonalization and least squares.
Everything else in this checkpoint, including the vision tower, tokenizer and chat template, is byte-identical to the base revision. Code, data, the hash-chained experiment ledger and the full write-up are at github.com/scasella/qwen3.5-toolpatch.
Scope. The edit was evaluated only on a synthetic, campaign-generated tool benchmark (inert tool families, two confusable functions per prompt, distractor notes) under one protocol: official chat template with a native
<tools>block, one fixed system prompt that instructs the literalsNO_TOOL/NEED_CLARIFICATION,enable_thinking=False, greedy decoding, ≤ 128 new tokens, Apple-Silicon MLX (BF16). It has not been evaluated on BFCL or other public tool benchmarks, multi-turn tool use, other system prompts (beyond one "concise" variant), other decoding settings, or vision inputs. Treat it as a mechanistic-interpretability artifact with a measured effect under that protocol, not as a general-purpose improvement.
What changed (exact)
tensor (model.language_model.layers.23.mlp.*) | shape | dtype | changed entries | SHA-256 base | SHA-256 this repo |
|---|---|---|---|---|---|
gate_proj.weight | 3584 × 1024 | BF16 | 2,047 (row 3468, row 3421) | 57e66633224761ad56da16da7cc0f476e42decd9df64a64ded4a343b8e87487b | cd759ae8a60c6cc2b5b7cbf397a03968464589f5490e11002028c6953d5c8429 |
up_proj.weight | 3584 × 1024 | BF16 | 2,047 (row 3468, row 3421) | cb3830f5121ca0cb4b974b7904a382f9555975c2e84c71863e868e434e86aa6f | b40609ff4db37fa3f97d3eeb8a7ffd1ab75bb2dc01eac36c2afa0ef9dcaad196 |
down_proj.weight | 1024 × 3584 | BF16 | 2,048 (column 3468, column 3421) | 1866748ce87d32cfee34891d2fa393fdfeee77447935f6a31d036e4b80332a48 | e4e9f7ead2e43fc920f9e91e44ef90a3f5ead92ca7d89f8a5c3774965abe9180 |
Whole-file SHA-256 of model.safetensors-00001-of-00001.safetensors: base 04b1c301231dd422b8860db31311ab2721511346a32cb1e079c4c4e5f1fe4696 → this repo 886b4952cc74601ad69bed4488c9f4e5621e7dbb8a51287db2e6a4af60f2927e (export_manifest.json). Every tensor other than the three above is byte-identical to the base (checked at export time).
Equations. With x the layer-23 MLP input (post-attention RMSNorm output, d = 1024), J1 = 3468, J2 = 3421, k = 2, k_r = 1, a₁ = a₂ = 1, λ = 0.3, λ₂ = 0.5:
gate_proj[J1,:] = k·(s − λ·c − λ₂·c₂) up_proj[J1,:] = k·s down_proj[:,J1] = a₁·u_AB
gate_proj[J2,:] = k·(s − λ·c − λ₂·c₂) up_proj[J2,:] = k_r·r down_proj[:,J2] = a₂·(u_NE − u_NO)
act_J1 = SiLU(k·(s − λc − λ₂c₂)·x) · (k·s·x) ≈ k²(s·x)² at a tool-context decision position with s·x > 0, ≈ 0 elsewhere
act_J2 = SiLU(k·(s − λc − λ₂c₂)·x) · (k_r·r·x) signed NEED_CLARIFICATION-vs-NO_TOOL route, same gate
- s — "explanation request" feature: unit difference of class means (abstain − call) at residual layer 18, orthogonalized against the literal-continuation signatures and against the call/abstain midpoint (d′ ≈ 10–14 at layers 12–16 in the base model, readable at layer 23, never used by the base model's output).
- r — "clarify vs explain" feature: unit difference of means (clarify − answer) at residual layer 14, midpoint-orthogonalized (d′ ≈ 10 at layers 8–13).
- c, c₂ — gate terms that close the SiLU gate at the first token of prompts without tools and at every generated position (literal continuations, inside tool calls, prose), so the readout fires only at the decision token of a tool-context prompt.
- u_AB, u_NE − u_NO — minimum-norm least-squares output directions in pre-final-norm residual space with unit logit effect on
NO/NE/<tool_call>(and −0.5 on the prose startersI,To,The) and zero effect on 39 competitor tokens.
The vectors (g23v3.vectors.npz, 38 KB) and scalars (g23v3.spec.json) are in this repo together with g23v3.npz (the BF16 bits of the three edited tensors) and apply_g23v3.py, a numpy-only script that rebuilds the edit from the vectors, applies it to a base checkpoint and verifies the hashes above:
BASE=$(hf download Qwen/Qwen3.5-0.8B --revision 2fc06364715b967f1860aea9cf38778875588b17)
python apply_g23v3.py --base "$BASE" --out Qwen3.5-0.8B-toolpatch-g23v3 --full-hash --vectors g23v3.vectors.npz --spec g23v3.spec.json
Why this edit (mechanism in two sentences)
Direct logit attribution over all 86,016 MLP neurons of the base model finds no neuron that selectively pushes <tool_call> on non-call requests (none above ≈ 0.2 logits): the push is a distributed, class-independent prior, so the flaw is a missing inhibition, not something to ablate. The residual stream nevertheless carries clean "this is an explanation request" and "a required value is missing" features that nothing reads out at the decision token; the edit installs that readout in the last layer, where the write is scaled once by the final RMSNorm and, because the KV cache is built from the layer input, affects only its own position.
Results (paired, greedy, identical prompts for base and edited weights)
| set | n | correct, lenient (base → edited) | strict | wrong→right / right→wrong | calls token-identical |
|---|---|---|---|---|---|
| practice (18 families, half with opaque names) | 64 | 24 → 52 | 7 → 35 | 28 / 0 | 24/24 |
| selection (6 unseen families) | 32 | 12 → 27 | 4 → 19 | 15 / 0 | 12/12 |
| renamed functions and arguments, A / B | 32 + 32 | 8 → 23, 12 → 26 | 6 → 21, 10 → 25 | 15 / 0, 14 / 0 | 23/24 (one drops an explicit optional default, still correct) |
| final-split family proxy (12 families never used in localization) | 32 | 12 → 27 | 3 → 18 | 15 / 0 | 12/12 |
| all tool-context items | 192 | 68 → 155 | 30 → 118 | 87 / 0 | 71/72 |
| non-tool short answers (fresh seed) | 32 | 28 → 28 | 28 → 28 | 0 / 0 | 32/32 token-identical |
| non-tool prose questions, 128 tokens (16 derivation + 16 fresh) | 32 | all intact | all intact | 0 / 0 | 20/32 token-identical, mean length 127.9 → 128.0 |
Per class over the 192 tool-context items: required calls 68/72 → 68/72; NO_TOOL on explanation requests 0/60 → 59/60; NEED_CLARIFICATION when a value is explicitly missing 0/30 → 28/30; NEED_CLARIFICATION on ambiguous "either X or Y" requests 0/30 → 0/30. Lenient treats an omitted optional argument as equivalent to its explicit default; strict also forbids extra arguments (the base model's habit of adding the optional detail=brief is untouched by the edit).
Controls on the same two neurons (64 practice items): zero edit 64/64 token-identical to base; half / double dose 52 / 53 correct (monotone); reversed sign 24 → 24 with 0 repairs; three norm-matched random direction sets give 0 repairs (two neutral, one breaks 12 of 24 calls). A fresh stock mlx_lm process loading this checkpoint reproduced the in-process token streams exactly (32/32 base, 32/32 edited). Two earlier candidates (v1: no gate terms; v2: tool-context gate term only) repaired tool-context items equally well but corrupted free-form prose answers to non-tool questions (v1: 0/16 intact, NONENENE…; v2: 1/16 token-identical); the generated-position gate term c₂ in g23v3 fixes this (32/32 intact).
Limitations
- Ambiguous requests (
either "X" or "Y", with no preference specified) still produce a call that picks one value (0/30). The base network has no linear feature for "two candidate values" at any probed layer; a readout edit cannot create one. - Weak-cue explanation requests mostly still call; explicit-missing repair is phrasing-dependent (
not provided-style phrasings are repaired). - Free-form prose answers are not bit-identical to the base (20/32): rare near-tied word choices flip and the text diverges benignly.
- Inside tool calls the readout is not perfectly silent at near-tied positions (one renamed call drops an explicit optional default); no call changed correctness in 72 paired calls, and the four calls the base model gets wrong (function choice under renamed tools) stay wrong.
- Validated only under the protocol described above, on MLX. Other backends (e.g. PyTorch) differ slightly in BF16 accumulation; near-tied decisions may differ.
- Transfer to BFCL (
experiments/transfer_bfcl/): on the BFCL v4 single-turn categories (3,491 items, tools the edit never saw), with the system prompt above, the abstention transfers (live_irrelevance30.5% → 57.2%,irrelevance39.6% → 48.3%, almost entirely wrong call →NEED_CLARIFICATION/NO_TOOL) at a cost in recall on terse but answerable requests (pooled over the AST categories: 6 items won, 39 lost). g23v3 and g23v4 are indistinguishable on this benchmark. Without the system prompt accuracy is unchanged, but 23% of the edited model's prose answers open with a shouted fragment of a literal (NO,,NEITHER,NEED …), because the readout promotes the literals' first tokens whether or not the prompt defines them: the edit is prompt-conditioned, not prompt-independent, and "calls stay token-identical" holds for 96 to 98% of the items where both models call, not all.
Usage
mlx-lm (the backend the edit was validated on):
from mlx_lm import load, generate
from mlx_lm.sample_utils import make_sampler
model, tok = load("scasella91/Qwen3.5-0.8B-toolpatch-g23v3")
SYSTEM = ("Use the available tools when needed. For a request requiring no tool, reply exactly NO_TOOL. If required information "
"is missing or ambiguous, reply exactly NEED_CLARIFICATION. Otherwise make exactly one native tool call. No other text.")
tools = [{"type": "function", "function": {"name": "uppercase_text", "description": "Change stored text to uppercase.",
"parameters": {"type": "object", "properties": {"text": {"type": "string", "description": "Stored text identifier"}}, "required": ["text"]}}}]
messages = [{"role": "system", "content": SYSTEM},
{"role": "user", "content": "Carry out this request: change stored text to uppercase.\nStored text identifier: not provided."}]
prompt = tok.apply_chat_template(messages, tools=tools, add_generation_prompt=True, enable_thinking=False)
print(generate(model, tok, prompt, max_tokens=128, sampler=make_sampler(0))) # NEED_CLARIFICATION (base model: a <tool_call> with text="not provided")
transformers (not executed by the authors; the campaign machine has no PyTorch):
import torch
from transformers import AutoTokenizer, AutoModelForImageTextToText
repo = "scasella91/Qwen3.5-0.8B-toolpatch-g23v3"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForImageTextToText.from_pretrained(repo, dtype=torch.bfloat16).eval()
ids = tok.apply_chat_template(messages, tools=tools, add_generation_prompt=True, enable_thinking=False, return_tensors="pt")
out = model.generate(ids, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
Files
| file | purpose |
|---|---|
model.safetensors-00001-of-00001.safetensors, config.json, tokenizer and template files | full checkpoint; byte-identical to the base except the three tensors above |
g23v3.npz | uint16 BF16 bits of the three edited tensors (22 MB) |
g23v3.vectors.npz, g23v3.spec.json | the closed-form vectors (s, r, c, c₂, u_AB, u_route, gate_dir) and every scalar, receipt and simulation result |
apply_g23v3.py | numpy-only patcher: rebuilds the tensors from the vectors, applies them to a base checkpoint, verifies the hashes |
export_manifest.json | edited tensor names, base and edited whole-file SHA-256 |
BASE_MODEL_README.md, LICENSE | the original Qwen3.5-0.8B model card and Apache-2.0 license |
Provenance
Built on 2026-11-04 in 47 budgeted forward passes (every one logged with a hypothesis and prediction before it ran, in a hash-chained ledger), MLX 0.32.4 / mlx-lm 0.32.2 / transformers 5.22.1 on an Apple M4 Pro. No gradients, optimizers, LoRA, distillation or output-fitting regression; prompts, template, decoding and post-processing identical for base and edited weights in every comparison. Full report, notebook, ledger, per-pass outputs and reproduction commands: github.com/scasella/qwen3.5-toolpatch.
License and attribution
Apache-2.0, as the base model. Base model © Alibaba Cloud (Qwen3.5-0.8B); the original model card is kept as BASE_MODEL_README.md.