Instructions to use Ma7ee7/SmolLM2-135M-Reasoning-5K with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ma7ee7/SmolLM2-135M-Reasoning-5K with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ma7ee7/SmolLM2-135M-Reasoning-5K") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Ma7ee7/SmolLM2-135M-Reasoning-5K") model = AutoModelForCausalLM.from_pretrained("Ma7ee7/SmolLM2-135M-Reasoning-5K") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Ma7ee7/SmolLM2-135M-Reasoning-5K with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ma7ee7/SmolLM2-135M-Reasoning-5K" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ma7ee7/SmolLM2-135M-Reasoning-5K", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Ma7ee7/SmolLM2-135M-Reasoning-5K
- SGLang
How to use Ma7ee7/SmolLM2-135M-Reasoning-5K with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Ma7ee7/SmolLM2-135M-Reasoning-5K" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ma7ee7/SmolLM2-135M-Reasoning-5K", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Ma7ee7/SmolLM2-135M-Reasoning-5K" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ma7ee7/SmolLM2-135M-Reasoning-5K", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Ma7ee7/SmolLM2-135M-Reasoning-5K with Docker Model Runner:
docker model run hf.co/Ma7ee7/SmolLM2-135M-Reasoning-5K
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
| 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
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:
<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.
- Downloads last month
- 238