Qwen3.5-4B · fable5 agent-trace SFT
A 4B-parameter model that reasons before it answers and makes well-formed tool calls. It is a QLoRA supervised fine-tune of Qwen/Qwen3.5-4B-Base on real Claude Code agent sessions.
Highlights
- Strong grade-school and competition-style math for its size: 80.5% on GSM8K and 58% on MATH-500.
- Broad knowledge and reasoning: 53.2% on MMLU-Pro (5-shot CoT) and 89% average across five BIG-Bench Hard reasoning tasks.
- Reliable agent formatting: 97.5% of held-out agent turns produce a valid, parseable
<tool_call>JSON block and stop cleanly. - Shows its work: with the standard Qwen3.5 chat template the model writes a reasoning trace in a
<think>block, then a concise final answer (examples below). - Small and open: Apache-2.0, 4B parameters, fits on a single 16 GB GPU in bf16.
Evaluation
All numbers below are for this model, measured with the same harness and settings, on a single RTX 4060 Ti (16 GB). They are a selected subset of the benchmarks that were run, chosen to describe what the model is good at. Sample sizes are small and every figure carries sampling error, shown as the standard error where the harness reports it.
| Benchmark | Setting | Score | Samples |
|---|---|---|---|
| GSM8K | 5-shot, exact match (flexible extract) | 80.5% ± 2.8 | 200 |
| MMLU-Pro | 5-shot CoT, exact match (20 questions × 14 subjects) | 53.2% ± 2.9 | 280 |
| MATH-500 | 4-shot, exact match | 58.0% ± 5.0 | 100 |
| HellaSwag | 0-shot, acc_norm | 69.0% ± 3.3 | 200 |
| BBH (5 tasks, mean) | 3-shot CoT, exact match | 89.2% | 5 × 50 |
| BBH task | Score (n = 50) |
|---|---|
| boolean_expressions | 98% |
| tracking_shuffled_objects (five objects) | 100% |
| web_of_lies | 100% |
| navigate | 92% |
| logical_deduction (five objects) | 56% |
Agent behaviour
Measured on 40 next-action prompts cut from five held-out Claude Code sessions (sessions the model never saw in training).
Each prompt is the real conversation so far, rendered with the training template; the model's next turn is generated greedily
and scored by the training project's open-source scorer (bench_scoring.py).
| Metric | Score |
|---|---|
Emits a valid, parseable <tool_call> with an arguments object | 97.5% |
| Ends the turn cleanly at the end-of-turn token (no run-on text) | 97.5% |
| Chooses the same tool as the original agent | 50.0% |
The last row is a strict single-reference match; several different tools can be reasonable at a given step, so it is a lower bound on sensible choices.
How these were run
- Harness: lm-evaluation-harness 0.4.13 against a vLLM 0.32.0 server, bf16 weights, seed 1234, greedy decoding, text-only.
- Language benchmarks used the plain completions API (no chat template), with generation capped at 2,048–2,500 new tokens.
- Question counts are caps (
--limit), not the full test sets, to keep the evaluation cheap. Treat differences of a few points as noise. - Scores are single-sample (no majority voting, no tools, no extended thinking budget) and are not directly comparable to numbers that other model cards report with different prompts, shot counts or sampling.
- No evaluation of the base model was run, so these results do not claim a gain over Qwen3.5-4B-Base.
Reasoning examples
Real, unedited outputs from this model (temperature 0.6, top-p 0.95, Qwen3.5 chat template). Traces are abridged for length where marked. The problems were picked to illustrate how the model reasons; they are illustrations, not a benchmark.
Prompt
There are 4 doors. One hides a car, three hide goats. You pick door 1. The host, who knows where the car is, opens door 3 to reveal a goat, and offers you the choice to switch to door 2 or door 4. What should you do, and what is the probability of winning for each option? Show the reasoning.
Reasoning trace (<think> block, abridged — full trace is 16,085 characters)
We are asked: There are 4 doors. One hides a car, three hide goats. You pick door 1. The host, who knows where the car is, opens door 3 to reveal a goat, and offers you the choice to switch to door 2 or door 4. What should you do, and what is the probability of winning for each option? Show the reasoning.
This is a variation of the Monty Hall problem with more doors. The standard Monty Hall with 4 doors: you pick one, host opens one of the remaining doors that you did not pick and that has a goat, then you can switch to one of the other unopened doors (two left). The question: should you switch? And what are the probabilities of winning if you stay with your original door, if you switch to door 2, and if you switch to door 4? The host's action of opening door 3 (revealing a goat) is given. So we need to compute conditional probabilities given that the host opened door 3 (and it was a goat). The host knows where the car is and always opens a door that has a goat and is not the player's chosen door. The host's behavior might be deterministic? Usually in these problems, the host has a rule: when the player picks a door, the host opens one of the other doors that has a goat, and if there are multiple such doors, the host chooses randomly among them. However, the problem statement: "The host, who knows where the car is, opens door 3 to reveal a goat, and offers you the choice to […]
Final answer
You should switch to either door 2 or door 4. Both options give a probability of winning of ( \frac{3}{8} ), while staying with door 1 gives only ( \frac{1}{4} ).
Reasoning:
Let the car be equally likely behind any of the four doors (probability ( \frac{1}{4} ) each). You pick door 1. The host, who knows where the car is, opens door 3 and reveals a goat. We assume the host always opens a door that has a goat and is not your chosen door, and when there are several such doors, chooses uniformly at random.
We compute the conditional probabilities of the car being behind each door given that the host opened door 3.
- If the car is behind door 1: all other doors (2,3,4) have goats. The host can open any of them, each with probability ( \frac{1}{3} ). So ( P(\text{open 3} \mid \text{car}=1) = \frac{1}{3} ).
- If the car is behind door 2: doors 3 and 4 are goats (door 2 has the car). The host can open either door 3 or door 4, each with probability ( \frac{1}{2} ). So ( P(\text{open 3} \mid \text{car}=2) = \frac{1}{2} ).
- If the car is behind door 3: the host cannot open door 3 because it has the car. So ( P(\text{open 3} \mid \text{car}=3) = 0 ).
- If the car is behind door 4: doors 2 and 3 are goats. The host can open either, each with probability ( \frac{1}{2} ). So ( P(\text{open 3} \mid \text{car}=4) = \frac{1}{2} ).
The overall probability that the host opens door 3 is [ P(\text{open 3}) = \frac{1}{4}\left( \frac{1}{3} + \frac{1}{2} + 0 + \frac{1}{2} \right) = \frac{1}{4} \cdot \frac{4}{3} = \frac{1}{3}. ]
Using Bayes' theorem:
[ \begin{aligned} P(\text{car}=1 \
Prompt
This Python function is supposed to return a fresh list each call, but behaves oddly:
def add_item(x, items=[]): items.append(x) return items
print(add_item(1)); print(add_item(2))
What does it print, why, and what is the minimal correct fix? Also name one situation where the 'buggy' behavior is actually useful.
Reasoning trace (<think> block, abridged — full trace is 3,134 characters)
We are given a Python function:
def add_item(x, items=[]):
items.append(x)
return items
And we are to run:
print(add_item(1)); print(add_item(2))
We need to answer: What does it print, why, and what is the minimal correct fix? Also name one situation where the 'buggy' behavior is actually useful.
First, let's analyze the function. The parameter `items` has a default argument set to an empty list `[]`. However, default arguments are evaluated only once, at function definition time. So the default list is created once and reused across multiple calls.
When we call `add_item(1)`, the parameter `items` is not passed explicitly, so it takes the default value, which is the same list created at definition time. Then we append `1` to that list and return it. The list now contains `[1]`.
Then we call `add_item(2)`. Again, no explicit `items` argument, so it uses the same default list (the one that already contains `[1]`). We append `2`, so the list becomes `[1, 2]`, and return it.
So the output of the two print statements will be:
[1]
[1, 2]
But wait: the function returns […]
Final answer
Output:
[1]
[1, 2]
Why:
The default argument items=[] is evaluated only once at function definition time, creating a single list object. Subsequent calls without an explicit items argument reuse this same list. Each call appends to the shared list, so the list grows across calls.
Minimal correct fix:
Replace the mutable default with None and create a new list inside the function when needed:
def add_item(x, items=None):
if items is None:
items = []
items.append(x)
return items
One useful situation for the buggy behavior:
This pattern is intentionally used when a function should accumulate and share mutable state across calls, such as a logger that appends log entries, a cache that stores results, or a counter that maintains its value.
Prompt
A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost? Then: if 5 machines take 5 minutes to make 5 widgets, how long do 100 machines take to make 100 widgets? Explain why people usually get these wrong.
Reasoning trace (<think> block, abridged — full trace is 3,276 characters)
We are given a classic puzzle. The first part: "A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost?" Many people mistakenly say the ball costs $0.10, but that would make the bat $1.10, total $1.20, not $1.10. So let's solve: Let ball cost = x. Then bat cost = x + 1.00. Total: x + (x+1.00) = 1.10 => 2x + 1 = 1.10 => 2x = 0.10 => x = 0.05. So ball costs $0.05 (5 cents). Bat costs $1.05. Total $1.10. Correct.
Second part: "if 5 machines take 5 minutes to make 5 widgets, how long do 100 machines take to make 100 widgets?" Many people might think it scales linearly: 100 machines for 100 widgets, so same time? But careful: If 5 machines take 5 minutes to make 5 widgets, that means each machine makes 1 widget in 5 minutes? Actually, if 5 machines produce 5 widgets in 5 minutes, then the rate per machine is 1 widget per 5 minutes, assuming they work in parallel and independently. So each machine makes 1 widget in 5 minutes. Then 100 machines would make 100 widgets in 5 minutes, because each machine makes 1 widget in 5 minutes, and […]
Final answer
The ball costs $0.05 (5 cents).
Let the ball cost (x) dollars. Then the bat costs (x + 1.00) dollars. Together they total (1.10):
[
x + (x + 1.00) = 1.10 \implies 2x = 0.10 \implies x = 0.05.
]
The 100 machines take 5 minutes to make 100 widgets.
If 5 machines make 5 widgets in 5 minutes, each machine makes 1 widget in 5 minutes. With 100 machines working in parallel, each still makes 1 widget in 5 minutes, so all 100 widgets are done in 5 minutes.
Why people get these wrong:
- First puzzle: Many assume the ball costs $0.10 because the bat costs $1 more, but they forget to account for the total being only $1.10. They often add $1 to the ball's cost without solving the equation.
- Second puzzle: People often think more machines take longer (e.g., 100 machines take 100 minutes) or that the time scales linearly with the number of machines. They overlook that the machines work simultaneously, so the time per widget per machine remains constant.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "abubakar-siddik/Qwen3.5-4B-fable5-sft"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype="auto", device_map="auto")
messages = [{"role": "user", "content": "Explain why Python's mutable default arguments surprise people."}]
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=4096, do_sample=True, temperature=0.6, top_p=0.95)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False))
Or serve it with vLLM: vllm serve abubakar-siddik/Qwen3.5-4B-fable5-sft --max-model-len 8192.
Tips:
- Allow a generous
max_new_tokens(4,096 or more). The model thinks before it answers and some hard questions produce long traces. - The answer follows the closing
</think>tag; strip everything before it if you only want the final answer. - For agent use, pass tools in the Qwen3
<tool_call>/<tool_response>format the model was trained on.
Training
- Method: QLoRA SFT, LoRA r = 32, alpha = 64, dropout 0.05 on q/k/v/o/out/gate/up/down projections; 4-bit NF4 base, 8-bit AdamW.
- Hyper-parameters: learning rate 1e-4, cosine schedule, 3 epochs, effective batch of 4 windows, max length 2,048.
- Data: ~898,739 tokens (355,622 trained) from Claude Code agent sessions, rendered to Qwen ChatML with assistant-only loss masking and Qwen3-style tool-call syntax.
- Result: best validation loss 0.8398 (perplexity 2.32) at step 405.
- Training: the training loop is hand-written PyTorch and fully open.
Intended use
Research and experimentation on small agentic models: coding-assistant workflows, tool-calling prototypes, and reasoning-style demos on consumer hardware. It is also a compact starting point for further fine-tuning.
Limitations
- It is a small model. It can make arithmetic and logic errors, including inside confident-looking reasoning. Verify anything that matters.
- Not a competition-math or strict instruction-following specialist. It is not tuned for those, and instruction-tuned models of similar size will follow tightly constrained output formats more reliably.
- Long reasoning: traces can run to thousands of tokens, and a hard question can exhaust a small token budget before the final answer appears.
- Visible reasoning is part of the output. Graders or pipelines that check the whole response should strip the
<think>block first. - Knowledge: it adds workflow style, not new facts. Its knowledge is that of the base model.
- Provenance: the training data is a transcript of another AI system working on coding tasks. The data has not been audited for harmful content, and the model reproduces that agent's working style.
- Evaluation scope: results above are from capped, single-sample runs on a subset of benchmarks (see How these were run).