115 lines
2.9 KiB
Markdown
115 lines
2.9 KiB
Markdown
---
|
|
base_model: HuggingFaceTB/SmolLM2-135M-Instruct
|
|
datasets:
|
|
- SupraLabs/reasoning-corpus-4K-5M-v1
|
|
library_name: transformers
|
|
pipeline_tag: text-generation
|
|
license: apache-2.0
|
|
language:
|
|
- en
|
|
tags:
|
|
- smollm2
|
|
- reasoning
|
|
- supervised-fine-tuning
|
|
- chat
|
|
- transformers
|
|
- safetensors
|
|
---
|
|
|
|
# SmolLM2-135M Reasoning-5K
|
|
|
|
A full-parameter reasoning fine-tune of
|
|
[`HuggingFaceTB/SmolLM2-135M-Instruct`](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) using 5,000 examples
|
|
sampled from [`SupraLabs/reasoning-corpus-4K-5M-v1`](https://huggingface.co/datasets/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
|
|
|
|
| Setting | Value |
|
|
|---|---:|
|
|
| Training examples | 5,000 |
|
|
| Evaluation examples | 128 |
|
|
| Epochs | 2 |
|
|
| Maximum sequence length | 4,096 tokens |
|
|
| Learning rate | 3e-05 |
|
|
| Training objective | Assistant-only causal cross-entropy |
|
|
| Parameter training | Full model |
|
|
| Precision | bfloat16/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.
|