SmolThinker / README.md
sbussiso's picture
Model card for v2: dataset now matches, full training config, 3-run comparison
d39ac56 verified
|
Raw
History Blame Contribute Delete
6.24 kB
metadata
base_model: HuggingFaceTB/SmolLM2-1.7B-Instruct
datasets:
  - sbussiso/SmolThinker-Synthetic-Low-Reasoning
library_name: transformers
license: apache-2.0
language:
  - en
pipeline_tag: text-generation
tags:
  - gguf
  - llama.cpp
  - unsloth
  - lora
  - reasoning
  - chain-of-thought
  - think-tags
  - smollm2

SmolThinker

SmolLM2-1.7B-Instruct fine-tuned to emit its reasoning inside literal <think> ... </think> blocks, so chat UIs that render collapsible reasoning (Open WebUI, Ollama, LM Studio) display it as a proper thinking section rather than dumping it into the answer.

Reasoning is deliberately brief, around three short lines. The goal is reliable tag emission and visible working, not long deliberation.

Output format

<think>
I need to subtract 305 from 701.
Break 305 into 300 and 5.
701 - 300 = 401.
401 - 5 = 396.
</think>
701 - 305 = 396.

Usage

llama-cli -hf sbussiso/SmolThinker --jinja

The --jinja flag matters. It uses the embedded ChatML template, which is what the model was trained against.

For Ollama, ChatML turn format with both markers as stops:

PARAMETER stop "<|im_start|>"
PARAMETER stop "<|im_end|>"

Prompt format

ChatML, inherited from SmolLM2:

<|im_start|>system
You are a helpful AI assistant.<|im_end|>
<|im_start|>user
What is 47 + 68?<|im_end|>
<|im_start|>assistant

Works with or without a system prompt. Roughly 40% of training rows carried no system turn, so the template's injected default is in distribution; the rest used generic prompts naming no model.

Multi-turn works too. About 11% of training rows are 2 to 3 turn conversations where each follow-up depends on an earlier turn, so the model reads prior context rather than treating every message as fresh.

Training data

sbussiso/SmolThinker-Synthetic-Low-Reasoning, 2,593 rows.

Source Rows
Templated single-turn, 26 task families 1,800
Templated multi-turn 200
Hand-written single-turn 514
Hand-written multi-turn 79

593 rows are authored individually rather than generated. 100% of assistant turns carry a think block, including greetings, so there is no example anywhere of answering without one.

Training configuration

LoRA adapter on a 16-bit base, trained with Unsloth Studio on a single NVIDIA L4.

method:            LoRA (16-bit base)
num_epochs:        2
max_seq_length:    2048
learning_rate:     2e-4
lr_scheduler:      linear
warmup_steps:      50
batch_size:        2
grad_accumulation: 4          # effective batch 8
optimizer:         adamw_8bit
weight_decay:      0.001
packing:           false
train_on_completions: true    # loss on assistant turns only
random_seed:       3407

lora_r:            16
lora_alpha:        16
lora_dropout:      0
target_modules:    q_proj k_proj v_proj o_proj gate_proj up_proj down_proj

614 steps, 762,325 tokens, 11m45s. Final training loss 0.639, final evaluation loss approximately 0.600, final gradient norm 0.414.

Why two epochs

Three runs were compared. At three epochs the model overfits: evaluation loss bottoms around step 591 and then climbs while training loss keeps falling.

Run Config Final train loss Final eval loss Overfit
1 3 epochs, rank 32 0.452 ~0.645 yes, 0.050
2 3 epochs, rank 16 0.517 ~0.621 yes, 0.030
3 2 epochs, rank 16 0.639 ~0.600 none

Both three-epoch runs turned upward at the same step regardless of rank, so the cause was epoch count against a 2,453-row training split rather than adapter capacity. Run 3 is this release: higher training loss with the lowest evaluation loss, and a gradient norm that stays flat instead of climbing, which is what generalisation rather than memorisation looks like.

Design notes

The tags are ordinary text tokens, not special tokens. On the SmolLM2 tokenizer <think> is ['<', 'think', '>'] and </think> is ['</', 'think', '>'], tokenizing identically in every training row. This is deliberate: registering them via add_special_tokens() would give them untrained embeddings and, more importantly, skip_special_tokens=True on decode would strip them from the output, which is the usual reason a reasoning fine-tune produces correct reasoning with no visible tags. Qwen3 makes the same choice, adding them to the vocab but marking them special=False.

embedding_learning_rate was left unset for the same reason: the tags are ordinary tokens and the embedding layer does not need to move.

Evaluation

This release has not been evaluated yet. The numbers below are from the previous version, trained on v1 of the dataset, and are recorded here as the baseline this release is meant to beat rather than as a description of it.

Suite Previous version
Format compliance, well-formed 70.0%
Format compliance, usable 90.0%
Held-out accuracy 88.3%

The previous version emitted a spurious trailing </think> on 20% of open-ended prompts and no think block at all on a further 5%, traced to every training answer being a single short clause. The dataset was revised to address that. Whether it worked is not yet measured.

This section will be replaced with measured results.

Limitations

Training data is largely templated and synthetic, so phrasing diversity in that portion is bounded and the task set is deliberately narrow. This teaches the shape of reasoning and reliable tag emission, not general reasoning ability. Expect arithmetic to degrade outside the ranges seen in training, and expect confident-looking traces on problems the model gets wrong.

The 593 hand-written rows are a finite set, so some memorisation of them is possible.

Not evaluated on GSM8K or any public benchmark, so there is no measurement of whether fine-tuning helped or harmed general math ability relative to the base model.

If you consume the output programmatically, strip any stray </think> after the first closing tag rather than assuming exactly one.

Built with Unsloth.