CoolFace
Modelpublic

Ma7ee7/SmolLM2-135M-Reasoning-5K

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
5likes130downloads
Model Card

SmolLM2-135M Reasoning-5K

A full-parameter reasoning fine-tune of `HuggingFaceTB/SmolLM2-135M-Instruct` using 5,000 examples sampled from `SupraLabs/reasoning-corpus-4K-5M-v1`.

The model was trained to place its reasoning trace inside <think> and </think> tags, followed by a separate final answer.

Training summary

SettingValue
Training examples5,000
Evaluation examples128
Epochs2
Maximum sequence length4,096 tokens
Learning rate3e-05
Training objectiveAssistant-only causal cross-entropy
Parameter trainingFull model
Precisionbfloat16/float16 depending on training GPU

The system and user portions were masked from the loss. Samples exceeding the maximum context length were rejected instead of being cut through the middle of a reasoning trace.

Usage

python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "YOUR_USERNAME/SmolLM2-135M-Reasoning-5K"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype="auto",
    device_map="auto",
)

messages = [
    {
        "role": "system",
        "content": 'You are a helpful AI assistant. For difficult problems, reason carefully inside <think> and </think> tags, then provide a clear final answer.',
    },
    {
        "role": "user",
        "content": "A farmer has 17 sheep. All but 9 run away. How many remain?",
    },
]

inputs = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt",
    return_dict=True,
).to(model.device)

with torch.inference_mode():
    output = model.generate(
        **inputs,
        max_new_tokens=256,
        do_sample=False,
        repetition_penalty=1.05,
    )

new_tokens = output[0, inputs["input_ids"].shape[1]:]
print(tokenizer.decode(new_tokens, skip_special_tokens=False))

Reasoning format

The expected assistant format is:

text
<think>
Internal reasoning trace
</think>

Final answer

This small model is experimental. It should not be assumed to produce correct reasoning merely because it emits a structured reasoning trace.

Files

training_info.json records the training configuration, any metrics found in the local output directory, and SHA-256 hashes of the uploaded weight files.

License

The model follows the Apache 2.0 license used by the base SmolLM2 model. Review the base model repository and source dataset for their complete terms.