Qwen2.5-0.5B Layer-Grow — Data Science Assistant
A depth-expanded fine-tune of Qwen/Qwen2.5-0.5B-Instruct: 6 new transformer blocks appended after the base model's 24 layers, for a 30-layer stack whose grown blocks are not the same width (1536d, 3072d and 6144d). It answers data-science questions and writes runnable pandas / matplotlib / scikit-learn / statistics / SQL code. Its last two versions are aimed at the jobs two agent consoles give a small model: ml_agent (route a problem to a problem type, gate on requirements, plan with real tools, write up their real results) and — this version — feature-store-agent (call its feature-engineering tools with exactly the right path and target, repair a failed call, turn an analyzer's findings into the next call).
This version trains 1,984,828,416 new parameters on top of a 494,000,000-parameter frozen base — the shipped model has 2,478,828,416 total parameters, of which the grown blocks are 80.1%.
Trained with the llm_with_tiny_lora project.
What's new in this version
This version is the previous one (commit d0fd60e13a, trained on ds-assistant-v6 … v10) fine-tuned for one more pass:
layers 24–29, each on ds-assistant-v11 … v15. v11–v15 were generated from the benchmark test of
feature-store-agent, in the same way v6–v10 were generated from the
ml_agent benchmark: the model is run inside an agent console, the benchmark shows where it fails, and a corpus is built to target
those failures from the console's own strings and real tool output.
The feature-store-agent test. feature-store-agent is a console of agents (a data reader, feature-engineering stages, a quality
check, a selection step, a requirements gate) that call feature-store tools, with a benchmark of 18 cases that plant traps such
as leaks, placeholders and numbers written as text. Its 16–17 Oct 2026 runs (benchmarks/RESULTS.md) used this repo's model
Caglana/qwen0.5b-tinylora-ds-assistant — as its LoRA-adapter builds main and v6-layer-lora-14250-tools, not this layer_grow
stack — and found:
- Given the agents' own 2,500–3,500-token method prompts, the model called a tool in 0 of 36 turns. It described calling one
and filled in what the tool would have said: a file that does not exist, or
"delimiter": ";", "has_header": falsefor a comma-separated table with a header. - Given one sentence and each tool cut to a line, it called a tool in 122 of 126 turns and picked the expected tool in 125 of 126 — but only 76 of the 122 calls had arguments that were valid as written: 37 named a path that is not a file, 5 a column that is not in the table, 8 an argument the tool does not take. It made no call for the quality check (once) and the selection step (three times).
- The requirements gate: 15 of 18 verdicts parsed, and only 4 of 18 named the data file the message gave (it answers
"data_details": "Not specified."about a message holding the path). - On its own calls only, it reached 88 of 120 checks and a better table than the raw columns in 13 of 18 cases (the same console with its fixed playbook: 116 and 17). It caught 17 of 29 planted leaks and built 4 of 11 needed signals (playbook: 26 and 10), and tools told to use every numeric column folded the target into the features, which scored one case at AUC 1.000 until an audit for that existed.
The v11–v15 corpus (build script data_generate_v6.sh, twelve families — see Training data) targets exactly these: about two
thirds of its written bytes are a tool call the model has to get exactly right.
The earlier ml_agent test (v6–v10, the previous version). ml_agent is a console that runs the model through the jobs of a
machine-learning project, with a 13-problem benchmark (benchmarks/RESULTS.md, 13 Oct 2026). Alone, the model chose the expected sub
agent in 0 of 13 cases (it kept writing unsupervised/ in front of every answer); with the console's own router and executor added
in code, all 13 were routed and 66 of 66 steps ran, but in 10 of 13 cases the model's decider gave no usable plan and all 13 of its
write-ups failed the report check.
What this card does not show:
- This version has not been evaluated. The only scores below (
evals/eval-v6.json) are the previous version's, onds-assistant-v6. - Neither benchmark was re-run with this checkpoint, so the card does not claim any failure listed above is fixed.
- The benchmark runs described above were of the LoRA-adapter builds of this repo, not of this layer_grow stack.
How it was trained: the previous version (commit d0fd60e13a, 30 layers, 42 sidecar rounds) was
fine-tuned further, one layer at a time, on the five new datasets in turn. Layers 24–29 (every
grown block) were each trained on all five, so the sidecar now records 72 rounds: the earlier 42 plus
30 layer_grow_refine passes. No new block was added; the architecture and parameter count are unchanged, only the weights
of the six grown blocks moved.
Training process
Run by layer_grow_multiple_run.sh (scripts/layer_grow_multi.py does the bookkeeping), twice in succession:
first over ds-assistant-v6 … v10 (the previous version), then, starting from that model, over v11 … v15 (this version).
- The previous version was downloaded once and kept as the working copy.
- For each grown layer in turn — 24, 25, 26, 27, 28, 29 (0-based; layers 0–23
are the frozen base) — and, inside that, for each dataset in order, one
layer_grow sftrun trained only that layer (layer_grow.train_only_listed_layers; every other block, grown or base, stayed frozen). The result was pasted back into the working copy (the script's default is to check first that no tensor outside that layer changed) and the next run started from it. - That is 6 layers × 5 datasets = 30 runs per pass, each recorded as one refine round in
layer_grow.json(refine_layersis the layer that run trained). By the end of a pass every grown block had been trained on every dataset of it.
| layer | shape | block parameters | parameters in the weights | refine runs, v6–v10 | refine runs, v11–v15 (this version) |
|---|---|---|---|---|---|
| 24 | 1536d / 8320 MLP | 46,207,744 | 46,207,744 | 5 | 5 |
| 25 | 3072d / 16640 MLP | 178,529,536 | 178,529,536 | 5 | 5 |
| 26 | 3072d / 16640 MLP | 178,529,536 | 178,529,536 | 5 | 5 |
| 27 | 3072d / 16640 MLP | 178,529,536 | 178,529,536 | 5 | 5 |
| 28 | 6144d / 33280 MLP | 701,516,032 | 701,516,032 | 5 | 5 |
| 29 | 6144d / 33280 MLP | 701,516,032 | 701,516,032 | 5 | 5 |
Training settings. The v6–v10 pass's per-iteration overrides (step cap, learning rate, sequence length,
batch size, sample cap) and the loss curves of both passes were not recorded in the repo, so they are not reported
here. The v11–v15 pass was launched with max_seq_length=6144 and a per-device batch of 1 × 32 gradient accumulation (the
records are long: up to 6,144 tokens); its step cap and evaluation batch size are not recorded. For reference, these are the
values of configs/sft_layer.yaml, the base config every run was derived from
(the script writes per-run copies and never edits it):
| Optimizer | AdamW, lr=5e-05, cosine schedule, 200 warmup steps |
| Weight decay | 0.02 |
| Batch size | 32 effective (per_device=8 × grad_accum=4) |
| Precision | bf16 |
| NEFTune noise alpha | 5 |
| Early stopping | on eval_loss, patience 1, threshold 0.05 |
| Max steps cap | 20000 |
| Max sequence length | 1536 (the v6–v10 records run to ~6k tokens; see below) |
Training data
v6–v10 (the previous version). ds-assistant-v6 … ds-assistant-v10 are the five 10 GB folders written by the project's
data_generate_v5.sh: synthetic records built from the real prompts and the real tool output of the ml_agent console, aimed at
where its benchmark showed the small model failing. Eight families (shares are the build script's default mix):
| family | share of bytes | job |
|---|---|---|
route | ~26% | choose ONE problem type from the user's words and the data file's facts |
plan | ~25% | a JSON plan of real tools on real columns — no repeats, at most 8 steps, then stop |
toolcall | ~18% | call the planned tools (<tool_call>), repair a call after an error, write the grounded report |
report | ~15% | write up real tool results using only their numbers |
gate | ~5% | is there a problem and a data source on the record? one JSON object |
chat | ~4% | one short question for what is missing; plain answers about the project |
review | ~4% | data-science judgement (leakage, drift, censoring, position bias, selection bias, …) with numbers computed from the table in the question |
condense | ~3% | shrink an over-long text, keeping paths, columns and numbers word for word |
v11–v15 (this version). ds-assistant-v11 … ds-assistant-v15 are written by data_generate_v6.sh, aimed at the
feature-store-agent console and at what its 18-case benchmark measured the model doing. Twelve families, each rendered with the
console's real strings (exported by feature-store-agent) and answered from a benchmark case or from real tool output; about two
thirds of the written bytes are a tool call the model has to get exactly right:
| family | job |
|---|---|
toolturn | the console's tool turn: one sentence plus tools cut to a line → ONE call, path and target copied exactly |
longprompt | the agent's own method prompt and full tool schemas → still exactly one correct call, not prose |
noskip | the two agents it would not call for: the quality check and the selection step |
notarget | a build tool with its full schema → the call passes target, so the column being predicted is set aside |
repair | a call that came back with an error, read and fixed (bad path / bad column / unknown argument) |
analysis | a real analyzer result → the selection call it implies: exclude the leaks, keep_columns the keys |
derive | a case whose signal has to be built before it exists → the build call that makes it |
gate | the requirements gate: one JSON object whose data_details names the file the message gave |
review | the fourteen kinds of planted trap, judged: what to do with the column and why |
report | write up real tool results using only their numbers, naming only the tools that ran |
chat | one short question for whatever is missing |
condense | an over-long stage output cut down, with paths, columns and numbers kept word for word |
Records run up to 6,144 tokens after chat templating (the longprompt ones to about 5k), and each folder holds its own held-out
sft_eval.jsonl. Records scoring above 10% n-gram overlap with the earlier corpora (v1–v3, code-base, GRPO, tool-use and, for
v11–v15, v6–v10) were dropped. Whether a given run read the whole folder or only a capped prefix of it was not recorded.
The weights underneath were trained on the project's earlier synthetic data-science corpus (concept Q&A,
runnable pandas / matplotlib / scikit-learn / statistics / SQL tasks, Kaggle-grounded code tasks, and tool-use
conversations with a seven-tool dataset workspace), through outputs/sft-ds-assistant/adapter and
outputs/sft-layer-lora/checkpoint-16000 merged into the base, then the growth rounds listed below.
Method — layer growth (multi-round block expansion)
Unlike LoRA or TinyLoRA, which adapt existing weight matrices with a low-rank update, this method adds brand new transformer blocks to the stack and trains them densely — every one of their 1,984,828,416 combined parameters is a real, independently-learned weight, not a rank-decomposed delta.
Growth history, oldest first:
- Layer 24 — 1536d/8320-MLP, 46,207,744 params,
init=identity, built bylayer_expand - Layer 25 — 3072d/16640-MLP, 178,529,536 params,
init=identity, built bylayer_grow - Layer 26 — 3072d/16640-MLP, 178,529,536 params,
init=identity, built bylayer_grow - Layer 27 — 3072d/16640-MLP, 178,529,536 params,
init=identity, built bylayer_grow - Layer 28 — 6144d/33280-MLP, 701,516,032 params,
init=identity, built bylayer_grow - Layer 29 — 6144d/33280-MLP, 701,516,032 params,
init=identity, built bylayer_grow - 66
layer_grow_refinepasses in total (6 before the multi-runs, 30 on v6–v10, 30 on v11–v15): continued training of the grown blocks, no new block added
The frozen base underneath (layers 0-23) is not the stock checkpoint
either: outputs/sft-ds-assistant/adapter, then outputs/sft-layer-lora/checkpoint-16000 were merged into the base weights, in that order, before any block was added.
This checkpoint is not loadable by a stock AutoModelForCausalLM.from_pretrained — at least one grown
block is wider than the rest of the stack, which Qwen2Config cannot describe, so config.json is
deliberately retyped model_type: layer_grow to fail loudly instead of silently reinitialising the
block(s) and returning a model that loads fine and produces garbage.
Results
Every earlier benchmark, and this one
Each row scores one checkpoint against the stock Qwen2.5-0.5B-Instruct on the same split, so its stock column is
its own yardstick. The project's eval split was rebuilt between some runs and the newest rows are scored on a different
corpus altogether, so absolute losses are not comparable between rows; the bold column — the checkpoint's perplexity
as a fraction of the stock model's on that row's own split (lower is better) — is the one to compare across. The earlier
rows are copied unchanged from the project's outputs/eval_results.json; the newest rows are not in that file.
Two rows cannot be compared with the rest. The previous version's row has no stock figure (the stock model has not been scored on ds-assistant-v6), and its numbers are on a different split from every row above it. This version has not been evaluated at all (last row).
A low perplexity ratio means the model fits its split's text well, not that its answers are good: the previous version's row has the
lower loss next to generated answers that are mostly wrong (see below), and the layer_expand row's own note flags overfitting.
| run | method | eval split | rows | eval loss (stock → ckpt) | perplexity (stock → ckpt) | ppl ÷ stock ppl | ROUGE-L F1 (stock → ckpt) | token F1 (stock → ckpt) | valid Python (stock → ckpt) |
|---|---|---|---|---|---|---|---|---|---|
| tiny_lora checkpoint-5750 (run 1) | tiny_lora | dataset/sft_eval.jsonl | — | 2.582 → 1.852 | 13.23 → 6.37 | 0.48× | 0.109 → 0.099 | 0.216 → 0.163 | 4% → 23% |
| tiny_lora checkpoint-5750 (run 2) | tiny_lora | dataset/sft_eval.jsonl | — | 2.582 → 1.811 | 13.23 → 6.12 | 0.46× | 0.109 → 0.118 | 0.216 → 0.200 | 4% → 65% |
| layer_lora checkpoint-2750 | layer_lora | dataset/sft_eval.jsonl | — | 2.582 → 1.261 | 13.23 → 3.53 | 0.27× | 0.109 → 0.116 | 0.216 → 0.228 | 4% → 15% |
| layer_lora checkpoint-3200 | layer_lora | dataset/sft_eval.jsonl | 500 | 2.427 → 1.407 | 11.32 → 4.09 | 0.36× | 0.076 → 0.077 | 0.178 → 0.180 | 27% → 3% |
| layer_lora checkpoint-7500 | layer_lora | dataset/sft_eval.jsonl | — | 2.614 → 1.307 | 13.66 → 3.69 | 0.27× | 0.111 → 0.118 | 0.223 → 0.236 | 12% → 19% |
| layer_expand checkpoint-16000 | layer_expand | dataset/sft_eval.jsonl | — | 2.745 → 0.062 | 15.57 → 1.06 | 0.07× | 0.087 → 0.493 | 0.209 → 0.539 | 7% → 7% |
| layer_grow checkpoint-1500 (the 12-round ancestor of both multi-run versions, training-time eval) | layer_grow | data/synthetic/dataset/sft_eval.jsonl | 500 | — → 0.192 | — → 1.21 | not scored | — | — | — |
| layer_grow multi-run (layers 24-29 x v6-v10), the previous version of this repo | layer_grow | ds-assistant-v6 | 40 | — → 0.151 | — → 1.16 | not scored | — → 0.216 | — → 0.297 | — |
| layer_grow multi-run (layers 24-29 x v11-v15), this version | layer_grow | — | — | — | — | not evaluated | — | — | — |
layer_lora checkpoint-3200. Scored against a newer generated dataset version weighted toward code-generation tasks -- not the same eval split as runs 1-3, so its base row is not comparable to theirs.
layer_lora checkpoint-7500. A later, longer run's checkpoint (step 7500, epoch 4.80), based on checkpoint-3200 and scored on a rebuilt eval split -- the base row moved from 2.4269 to 2.6143, which is only possible if the data changed, since the base model is frozen. Both the weights and the split differ from the checkpoint-3200 entry, so the two compare only through their base-relative deltas and neither variable can be isolated. Its own trainer_state records best_metric 1.1515 at this same step with the early-stopping counter at 0, so the run (max_steps 232000) had not plateaued when the checkpoint was written; the 1.3067 here is from a separate eval pass over a different sample, not that in-training number. code_valid_rate denominators are 26 (3/26 base, 5/26 checkpoint), derived from the reported rates.
layer_expand checkpoint-16000. Later checkpoint of the same run as README's 'layer_expand checkpoint-11200' (run 7, not itself recorded here since it was only ever captured as a printed eval.sh table) -- same outputs/sft-layer-expand-wide run, same configs/sft_layer_expand.yaml (max_steps 20000), 4800 more steps. eval_loss/perplexity are essentially flat versus checkpoint-11200 (0.0484/1.0496 -> 0.0617/1.0636) despite the extra training, and rouge_l_f1/token_f1 fell (0.6948/0.7014 -> 0.4933/0.5394) even though the base row's own eval_loss/perplexity barely moved (2.7433/15.5388 -> 2.7452/15.5682); its rouge_l_f1/token_f1 did move somewhat (0.0974/0.2323 -> 0.0867/0.2094), most likely from a different random subset of generated examples rather than a split change, since the split-independent loss numbers held steady. Read together: this checkpoint is not an improvement over checkpoint-11200 -- flat teacher-forced loss plus falling free-generation metrics after more training is the signature of a run that has already overfit past its useful point, on top of the leakage/train-eval-overlap check already flagged for checkpoint-11200 given its own near-1.0 perplexity. code_valid_rate and the newly-added repetition_loop_rate both tie exactly with their own base row here, so neither is informative at this sample size.
layer_grow checkpoint-1500. The loss the Trainer logged on the held-out split at step 1500 (epoch 0.96) of the run both multi-run versions were trained from, read from its trainer_state.json. It is not a stock-versus-checkpoint benchmark, so it has no stock figure. The same run's best eval loss was 0.0395 at step 500; the loss rose after that.
The previous version (v6–v10), in detail
These are the scores of the previous version, not of this one. Scored on ds-assistant-v6 only: the first 40 rows of its held-out sft_eval.jsonl for loss, and a greedy
reply (repetition_penalty=1.2, no_repeat_ngram_size=3, up to 256 new tokens) to the first 5 of those rows,
compared with the reference answer by the same ROUGE-L / token-F1 / repetition-loop functions as tiny-lora eval.
Loss is teacher-forced and token-weighted, over the final assistant turn (what the data teaches) and over the
whole conversation (what SFTTrainer's eval_loss measures). Scores were computed on an Apple M1 in bf16 with
scripts/eval_layer_grow_multi.py; the per-row results are in evals/.
| measure | previous version (v6–v10) |
|---|---|
| Loss, final assistant turn | 0.1553 |
| Perplexity, final assistant turn | 1.17 |
| Loss, whole conversation | 0.1510 |
| Perplexity, whole conversation | 1.16 |
| ROUGE-L F1 (5 generations) | 0.2157 |
| Token F1 (5 generations) | 0.2970 |
| Repetition-loop rate | 0% |
| Empty replies | 0% |
| Mean reply length | 123 words |
| Rows cut at 4096 tokens | 0 of 40 |
What the previous version's generations look like. The loss is very low, but the generated answers are not good, and the loss should not be read as answer quality. I read all 5 replies against their references:
- The three
reportrows reproduce the console's report layout (N of N planned step(s) ran with results: …), but the tool names and numbers that follow are not the ones that ran: they are invented or garbled (one reply names a toolconsistencyRegularizationSimulateLabelSaruncikov_tool; one says 2 steps ran where the reference has 3). - The
reviewrow is incoherent text. - The
gaterow is well-formed JSON with the wrong key casing (Problem,DataDetailsforproblem,data_details), the wrong verdict (requirements: falsewhere the reference saystrue) and an invented file path. - So none of the 5 replies is a usable answer. The ROUGE-L / token-F1 values mostly measure the shared template, not correct content.
Why loss and answer quality disagree: the data is templated, so given the reference's earlier tokens the next token is easy to predict (teacher forcing), while free generation has to get every tool name and number right unaided and compounds its first mistake.
Limits of this evaluation:
- Not this version. The weights scored here are the 42-round checkpoint trained on v6–v10; this version has not been evaluated on this or any split.
- One split.
ds-assistant-v7…v10(and v11 … v15) were not scored. They come from the same generator with the same family mix and similar lengths (median conversation ≈ 920 tokens on all five), but that is not a measurement of this model on them. - No baseline. The stock Qwen2.5-0.5B-Instruct and the 12-round ancestor were not scored on this split, so these numbers do not show that the previous version is better than either.
- Small and in-distribution. 40 rows for loss and 5 generations are a small sample, drawn from the same synthetic generator as the training data. Nothing here tests the model on real user requests, or on the ml_agent or feature-store-agent benchmarks.
Usage
This repo needs the project's own layer_grow loader, not a bare transformers install — see the note
above on why a stock AutoModelForCausalLM cannot rebuild this stack.
pip install "git+https://github.com/caglanakpinar/llm_with_tiny_lora"
from huggingface_hub import snapshot_download
from layer_grow.model import load_grown_model
from transformers import AutoTokenizer
local_path = snapshot_download("Caglana/qwen0.5b-tinylora-ds-assistant")
model = load_grown_model(local_path)
tokenizer = AutoTokenizer.from_pretrained(local_path)
messages = [{"role": "user", "content": "How do I compute a rolling 7-day average in pandas?"}]
inputs = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
)
output = model.generate(**inputs, max_new_tokens=256, do_sample=False, repetition_penalty=1.2, no_repeat_ngram_size=3)
print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Or, from a checkout of the project itself: tiny-lora chat --adapter <local checkpoint dir> — it detects
the layer_grow.json sidecar and loads through this same path automatically.
Tool use
The model was trained to call tools in Qwen2.5's native tool format: the offered tools arrive in the
system prompt inside <tools> tags (pass them through tokenizer.apply_chat_template(..., tools=TOOLS)), and the model answers with
one <tool_call> block per call:
<tool_call>
{"name": "describe_dataset", "arguments": {"dataset": "titanic"}}
</tool_call>
Parse the <tool_call> blocks out of the reply, run them yourself, and hand the results back as tool
messages. The earlier rounds trained a seven-tool dataset workspace (list_datasets, describe_dataset,
column_stats, run_sql, run_python, cross_validate, search_knowledge_base); the v6–v10 toolcall
family trains on the ml_agent console's tools, and the v11–v15 toolturn, longprompt, notarget and repair families on
feature-store-agent's. Neither tool-calling behaviour was re-measured for this
version — the scores above are loss and answer-overlap on the held-out splits, not a tool-call benchmark — and a
0.5B model's carry-over to a toolbox it was not trained on is unproven. The training conversations sat under a
fixed data-science system prompt; keep one in place.
Limitations
- Not loadable by a stock
transformers.AutoModelForCausalLM— requires this project'slayer_growpackage to rebuild the stack fromlayer_grow.json. - 0.5B-class base model: capable of short, focused answers but not competitive with larger models on complex multi-step reasoning.
- Narrow domain: tuned for data-science Q&A, code generation and the ml_agent and feature-store-agent consoles' jobs; general-purpose chat quality is not a training objective.
- This version has not been evaluated. The only scores in this card are the previous version's, on one split
(
ds-assistant-v6, 40 rows for loss, a handful of generations), and the answers it generated were poor (see Results). Neither the ml_agent nor the feature-store-agent benchmark was re-run with this checkpoint, and the training-time loss curves of both passes are not available. - The trainable capacity (≈2B parameters in the grown blocks) is large relative to the data of any one run; the earlier version's own eval loss was lowest at its step 500 and rose afterwards, so treat headline loss numbers as measures of fit to the synthetic distribution.
- The generated code is written to be runnable, but it is generated — read it before running it against anything that matters.
- Identity/safety guardrails (e.g. not identifying as "Qwen"/"Alibaba") are implemented at the application
layer in the project's
chat.pywrapper, not baked into the weights — rawgenerate()calls against this checkpoint may surface the base model's own identity.
License
Base model (Qwen/Qwen2.5-0.5B-Instruct) is Apache 2.0. This checkpoint is released under the same terms.