Text Generation
Transformers
Safetensors
llama
Generated from Trainer
sft
hf_jobs
trl
conversational
text-generation-inference
Instructions to use lewtun/SmolLM2-360M-OpenMathReasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lewtun/SmolLM2-360M-OpenMathReasoning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lewtun/SmolLM2-360M-OpenMathReasoning") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lewtun/SmolLM2-360M-OpenMathReasoning") model = AutoModelForCausalLM.from_pretrained("lewtun/SmolLM2-360M-OpenMathReasoning") 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 lewtun/SmolLM2-360M-OpenMathReasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lewtun/SmolLM2-360M-OpenMathReasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lewtun/SmolLM2-360M-OpenMathReasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lewtun/SmolLM2-360M-OpenMathReasoning
- SGLang
How to use lewtun/SmolLM2-360M-OpenMathReasoning 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 "lewtun/SmolLM2-360M-OpenMathReasoning" \ --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": "lewtun/SmolLM2-360M-OpenMathReasoning", "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 "lewtun/SmolLM2-360M-OpenMathReasoning" \ --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": "lewtun/SmolLM2-360M-OpenMathReasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lewtun/SmolLM2-360M-OpenMathReasoning with Docker Model Runner:
docker model run hf.co/lewtun/SmolLM2-360M-OpenMathReasoning
Training in progress, step 500
Browse files- README.md +49 -15
- chat_template.jinja +6 -0
- config.json +40 -0
- generation_config.json +9 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +19 -0
- training_args.bin +3 -0
README.md
CHANGED
|
@@ -1,26 +1,60 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
tags:
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
- Try ML Intern: https://smolagents-ml-intern.hf.space
|
| 14 |
-
- Source code: https://github.com/huggingface/ml-intern
|
| 15 |
-
|
| 16 |
-
## Usage
|
| 17 |
|
| 18 |
```python
|
| 19 |
-
from transformers import
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
```
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: HuggingFaceTB/SmolLM2-360M-Instruct
|
| 3 |
+
library_name: transformers
|
| 4 |
+
model_name: SmolLM2-360M-OpenMathReasoning
|
| 5 |
tags:
|
| 6 |
+
- generated_from_trainer
|
| 7 |
+
- sft
|
| 8 |
+
- hf_jobs
|
| 9 |
+
- trackio:https://lewtun-mlintern-omr360m1.hf.space?project=huggingface&runs=smollm2-360m-openmath-cot-lr2e5-bs16&sidebar=collapsed
|
| 10 |
+
- trl
|
| 11 |
+
licence: license
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Model Card for SmolLM2-360M-OpenMathReasoning
|
| 15 |
|
| 16 |
+
This model is a fine-tuned version of [HuggingFaceTB/SmolLM2-360M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-360M-Instruct).
|
| 17 |
+
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 18 |
|
| 19 |
+
## Quick start
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
```python
|
| 22 |
+
from transformers import pipeline
|
| 23 |
|
| 24 |
+
question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
|
| 25 |
+
generator = pipeline("text-generation", model="lewtun/SmolLM2-360M-OpenMathReasoning", device="cuda")
|
| 26 |
+
output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
|
| 27 |
+
print(output["generated_text"])
|
| 28 |
```
|
| 29 |
|
| 30 |
+
## Training procedure
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/trackio/refs/heads/main/trackio/assets/badge.png" alt="Visualize in Trackio" title="Visualize in Trackio" width="150" height="24"/>](https://lewtun-mlintern-omr360m1.hf.space?project=huggingface&runs=smollm2-360m-openmath-cot-lr2e5-bs16&sidebar=collapsed)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
This model was trained with SFT.
|
| 37 |
+
|
| 38 |
+
### Framework versions
|
| 39 |
+
|
| 40 |
+
- TRL: 1.4.0
|
| 41 |
+
- Transformers: 5.8.0
|
| 42 |
+
- Pytorch: 2.11.0
|
| 43 |
+
- Datasets: 4.8.5
|
| 44 |
+
- Tokenizers: 0.22.2
|
| 45 |
+
|
| 46 |
+
## Citations
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
Cite TRL as:
|
| 51 |
+
|
| 52 |
+
```bibtex
|
| 53 |
+
@software{vonwerra2020trl,
|
| 54 |
+
title = {{TRL: Transformers Reinforcement Learning}},
|
| 55 |
+
author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
|
| 56 |
+
license = {Apache-2.0},
|
| 57 |
+
url = {https://github.com/huggingface/trl},
|
| 58 |
+
year = {2020}
|
| 59 |
+
}
|
| 60 |
+
```
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system
|
| 2 |
+
You are a helpful AI assistant named SmolLM, trained by Hugging Face<|im_end|>
|
| 3 |
+
' }}{% endif %}{{'<|im_start|>' + message['role'] + '
|
| 4 |
+
' + message['content'] + '<|im_end|>' + '
|
| 5 |
+
'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant
|
| 6 |
+
' }}{% endif %}
|
config.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 1,
|
| 8 |
+
"dtype": "bfloat16",
|
| 9 |
+
"eos_token_id": 2,
|
| 10 |
+
"head_dim": 64,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 960,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 2560,
|
| 15 |
+
"is_llama_config": true,
|
| 16 |
+
"max_position_embeddings": 8192,
|
| 17 |
+
"mlp_bias": false,
|
| 18 |
+
"model_type": "llama",
|
| 19 |
+
"num_attention_heads": 15,
|
| 20 |
+
"num_hidden_layers": 32,
|
| 21 |
+
"num_key_value_heads": 5,
|
| 22 |
+
"pad_token_id": 2,
|
| 23 |
+
"pretraining_tp": 1,
|
| 24 |
+
"rms_norm_eps": 1e-05,
|
| 25 |
+
"rope_interleaved": false,
|
| 26 |
+
"rope_parameters": {
|
| 27 |
+
"rope_theta": 100000,
|
| 28 |
+
"rope_type": "default"
|
| 29 |
+
},
|
| 30 |
+
"tie_word_embeddings": true,
|
| 31 |
+
"transformers.js_config": {
|
| 32 |
+
"kv_cache_dtype": {
|
| 33 |
+
"fp16": "float16",
|
| 34 |
+
"q4f16": "float16"
|
| 35 |
+
}
|
| 36 |
+
},
|
| 37 |
+
"transformers_version": "5.8.0",
|
| 38 |
+
"use_cache": false,
|
| 39 |
+
"vocab_size": 49152
|
| 40 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
2
|
| 6 |
+
],
|
| 7 |
+
"pad_token_id": 2,
|
| 8 |
+
"transformers_version": "5.8.0"
|
| 9 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82d2fe61d64fdca0334c0b8eb4645c9e68a2b0e28b1bed3eef7032c91846068d
|
| 3 |
+
size 723674912
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<|im_start|>",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|im_end|>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"extra_special_tokens": [
|
| 9 |
+
"<|im_start|>",
|
| 10 |
+
"<|im_end|>"
|
| 11 |
+
],
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": false,
|
| 14 |
+
"model_max_length": 8192,
|
| 15 |
+
"pad_token": "<|im_end|>",
|
| 16 |
+
"tokenizer_class": "GPT2Tokenizer",
|
| 17 |
+
"unk_token": "<|endoftext|>",
|
| 18 |
+
"vocab_size": 49152
|
| 19 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5d9eff9abe4f0515194c4c9bff4e7bddb18cad113c2bca46ffde9ac33914e38c
|
| 3 |
+
size 5841
|