A smart-home tool-calling model made from ibm-granite/granite-4.0-350m by direct, closed-form weight editing — no gradient training, no training loop. 2,097,152 weights (0.60% of the model) in the MLP output projections of layers 18, 20, 22 and 24 were changed.
It turns smart-home requests (multi-turn) into calls to six tools: toggle_lights, set_thermostat, lock_door, get_device_status, set_scene and intent_unclear. The task definition and tool schema come from distil-labs/distil-home-assistant-qwen3 (Apache-2.0); see that model card for the full schema and system prompt, which this model uses unchanged.
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "aitos-io/Granite-4.0-350M-SmartHome-WeightEdit"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo)
SYSTEM = "..." # the system prompt from the distil-labs/distil-home-assistant-qwen3 model card, unchanged
TOOLS = [...] # the six tool definitions from the same model card, unchanged
messages = [{"role": "system", "content": SYSTEM}, {"role": "user", "content": "Is the front door locked?"}]
text = tok.apply_chat_template(messages, tools=TOOLS, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tok(text, return_tensors="pt")
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
All numbers below were measured on the files in this repository, after merging and saving in the released precision.
| Tool-call accuracy (95% CI) | This model | ibm-granite/granite-4.0-350m (unedited) | distil-labs/distil-home-assistant-qwen3 (fine-tuned, reference) |
|---|---|---|---|
Official test set (distil-smart-home test.jsonl, n=50) |
80.0% (67.0%–88.8%) | 58.0% (44.2%–70.6%) | 92.0% (81.2%–96.8%) |
Official seed set (distil-smart-home train.jsonl, n=50) |
92.0% (81.2%–96.8%) | 72.0% (58.3%–82.5%) | 98.0% (89.5%–99.6%) |
| Independent held-out set C (n=120) | 85.0% (77.5%–90.3%) | 53.3% (44.4%–62.0%) | 91.7% (85.3%–95.4%) |
| Practice set B (n=120) | 91.7% (85.3%–95.4%) | 59.2% (50.2%–67.5%) | 98.3% (94.1%–99.5%) |
| General ability | This model | ibm-granite/granite-4.0-350m (unedited) | distil-labs/distil-home-assistant-qwen3 (fine-tuned, reference) |
|---|---|---|---|
| ARC-Easy (200 test questions, letter answer) | 45.5% | 46.5% | 36.5% |
| WikiText-2 perplexity (40 paragraphs) | 39.93 | 40.03 | 48.25 |
The official test set was not used for any decision during editing; it was evaluated once, on the final model. Set C was written by an independent agent that could not see the editing code or the practice data. Intervals are Wilson 95% intervals; the official sets are small (50 items), so differences of a few points are within noise.
Honest comparison. The fine-tuned reference was trained (with gradients) on synthetic data for this exact task and is still more accurate. This model shows how far editing alone can take a general model, without any training.
lock_door instead of get_device_status), refusals (intent_unclear) and output format. Linear probes show the user's intent is 100% decodable from middle layers while the output is right only 61% of the time on practice data — an obstacle, not a missing capability.residual_multiplier, logits_scaling) were taken into account when computing the edit; the edited matrices are the shared MLP output projections (shared_mlp.output_linear).Apache-2.0, same as the base model. Base model: ibm-granite/granite-4.0-350m.
ibm-granite/granite-4.0-350m