Model

ui-inference/ui-inference-smollm2-135m-instruct

Mirror HuggingFaceTB/SmolLM2-135M-Instruct

ui-inference committed on October 21, 2026

df5600a4632cd86461b2adfd1a1473028ba69fd8Parent c5f0634Browse files

9 files changed+394 -0

README.md

Modified+162 -0
Lines 1 to 3 become lines 1 to 165
@@ -1,3 +1,165 @@
11---
2Added: library_name: transformers
23license: apache-2.0
4Added: language:
5Added: - en
6Added: pipeline_tag: text-generation
7Added: tags:
8Added: - safetensors
9Added: - onnx
10Added: - transformers.js
11Added: base_model:
12Added: - HuggingFaceTB/SmolLM2-135M
313---
14Added:
15Added:
16Added: # SmolLM2
17Added:
18Added: ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61c141342aac764ce1654e43/3ntM63zkmxY2cNRhgY_Kl.png)
19Added:
20Added: ## Table of Contents
21Added:
22Added: 1. [Model Summary](##model-summary)
23Added: 2. [Limitations](##limitations)
24Added: 3. [Training](##training)
25Added: 4. [License](##license)
26Added: 5. [Citation](##citation)
27Added:
28Added: ## Model Summary
29Added:
30Added: SmolLM2 is a family of compact language models available in three size: 135M, 360M, and 1.7B parameters. They are capable of solving a wide range of tasks while being lightweight enough to run on-device. More details in our paper https://arxiv.org/abs/2502.02737
31Added:
32Added: SmolLM2 demonstrates significant advances over its predecessor SmolLM1, particularly in instruction following, knowledge, reasoning. The 135M model was trained on 2 trillion tokens using a diverse dataset combination: FineWeb-Edu, DCLM, The Stack, along with new filtered datasets we curated and will release soon. We developed the instruct version through supervised fine-tuning (SFT) using a combination of public datasets and our own curated datasets. We then applied Direct Preference Optimization (DPO) using [UltraFeedback](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized).
33Added:
34Added: The instruct model additionally supports tasks such as text rewriting, summarization and function calling (for the 1.7B) thanks to datasets developed by [Argilla](https://huggingface.co/argilla) such as [Synth-APIGen-v0.1](https://huggingface.co/datasets/argilla/Synth-APIGen-v0.1).
35Added: You can find the SFT dataset here: https://huggingface.co/datasets/HuggingFaceTB/smol-smoltalk and finetuning code at https://github.com/huggingface/alignment-handbook/tree/main/recipes/smollm2
36Added:
37Added: ### How to use
38Added:
39Added: ### Transformers
40Added: ```bash
41Added: pip install transformers
42Added: ```
43Added:
44Added: ```python
45Added: from transformers import AutoModelForCausalLM, AutoTokenizer
46Added: checkpoint = "HuggingFaceTB/SmolLM2-135M-Instruct"
47Added:
48Added: device = "cuda" # for GPU usage or "cpu" for CPU usage
49Added: tokenizer = AutoTokenizer.from_pretrained(checkpoint)
50Added: # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
51Added: model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
52Added:
53Added: messages = [{"role": "user", "content": "What is gravity?"}]
54Added: input_text=tokenizer.apply_chat_template(messages, tokenize=False)
55Added: print(input_text)
56Added: inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
57Added: outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
58Added: print(tokenizer.decode(outputs[0]))
59Added: ```
60Added:
61Added: ### Chat in TRL
62Added: You can also use the TRL CLI to chat with the model from the terminal:
63Added: ```bash
64Added: pip install trl
65Added: trl chat --model_name_or_path HuggingFaceTB/SmolLM2-135M-Instruct --device cpu
66Added: ```
67Added:
68Added: ### Transformers.js
69Added:
70Added: ```bash
71Added: npm i @huggingface/transformers
72Added: ```
73Added:
74Added: ```js
75Added: import { pipeline } from "@huggingface/transformers";
76Added:
77Added: // Create a text generation pipeline
78Added: const generator = await pipeline(
79Added: "text-generation",
80Added: "HuggingFaceTB/SmolLM2-135M-Instruct",
81Added: );
82Added:
83Added: // Define the list of messages
84Added: const messages = [
85Added: { role: "system", content: "You are a helpful assistant." },
86Added: { role: "user", content: "What is the capital of France?" },
87Added: ];
88Added:
89Added: // Generate a response
90Added: const output = await generator(messages, { max_new_tokens: 128 });
91Added: console.log(output[0].generated_text.at(-1).content);
92Added: // "The capital of France is Paris."
93Added: ```
94Added:
95Added:
96Added: ## Evaluation
97Added:
98Added: In this section, we report the evaluation results of SmolLM2. All evaluations are zero-shot unless stated otherwise, and we use [lighteval](https://github.com/huggingface/lighteval) to run them.
99Added:
100Added: ## Base pre-trained model
101Added:
102Added: | Metrics | SmolLM2-135M-8k | SmolLM-135M |
103Added: |:-------------------|:----------------:|:------------:|
104Added: | HellaSwag | **42.1** | 41.2 |
105Added: | ARC (Average) | **43.9** | 42.4 |
106Added: | PIQA | 68.4 | 68.4 |
107Added: | MMLU (cloze) | **31.5** | 30.2 |
108Added: | CommonsenseQA | **33.9** | 32.7 |
109Added: | TriviaQA | 4.1 | **4.3** |
110Added: | Winogrande | 51.3 | 51.3 |
111Added: | OpenBookQA | **34.6** | 34.0 |
112Added: | GSM8K (5-shot) | **1.4** | 1.0 |
113Added:
114Added:
115Added: ## Instruction model
116Added:
117Added: | Metric | SmolLM2-135M-Instruct | SmolLM-135M-Instruct |
118Added: |:-----------------------------|:---------------------:|:--------------------:|
119Added: | IFEval (Average prompt/inst) | **29.9** | 17.2 |
120Added: | MT-Bench | **19.8** | 16.8 |
121Added: | HellaSwag | **40.9** | 38.9 |
122Added: | ARC (Average) | **37.3** | 33.9 |
123Added: | PIQA | **66.3** | 64.0 |
124Added: | MMLU (cloze) | **29.3** | 28.3 |
125Added: | BBH (3-shot) | **28.2** | 25.2 |
126Added: | GSM8K (5-shot) | 1.4 | 1.4 |
127Added:
128Added:
129Added:
130Added: ## Limitations
131Added:
132Added: SmolLM2 models primarily understand and generate content in English. They can produce text on a variety of topics, but the generated content may not always be factually accurate, logically consistent, or free from biases present in the training data. These models should be used as assistive tools rather than definitive sources of information. Users should always verify important information and critically evaluate any generated content.
133Added:
134Added: ## Training
135Added:
136Added: ### Model
137Added:
138Added: - **Architecture:** Transformer decoder
139Added: - **Pretraining tokens:** 2T
140Added: - **Precision:** bfloat16
141Added:
142Added: ### Hardware
143Added:
144Added: - **GPUs:** 64 H100
145Added:
146Added: ### Software
147Added:
148Added: - **Training Framework:** [nanotron](https://github.com/huggingface/nanotron/tree/main)
149Added:
150Added: ## License
151Added:
152Added: [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
153Added:
154Added: ## Citation
155Added: ```bash
156Added: @misc{allal2025smollm2smolgoesbig,
157Added: title={SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model},
158Added: author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Gabriel Martín Blázquez and Guilherme Penedo and Lewis Tunstall and Andrés Marafioti and Hynek Kydlíček and Agustín Piqueres Lajarín and Vaibhav Srivastav and Joshua Lochner and Caleb Fahlgren and Xuan-Son Nguyen and Clémentine Fourrier and Ben Burtenshaw and Hugo Larcher and Haojun Zhao and Cyril Zakka and Mathieu Morlon and Colin Raffel and Leandro von Werra and Thomas Wolf},
159Added: year={2025},
160Added: eprint={2502.02737},
161Added: archivePrefix={arXiv},
162Added: primaryClass={cs.CL},
163Added: url={https://arxiv.org/abs/2502.02737},
164Added: }
165Added: ```(no newline at end of file)

config.json

Added+37 -0
Lines 0 to 0 become lines 1 to 37
@@ -0,0 +1,37 @@
1Added: {
2Added: "architectures": [
3Added: "LlamaForCausalLM"
4Added: ],
5Added: "attention_bias": false,
6Added: "attention_dropout": 0.0,
7Added: "bos_token_id": 1,
8Added: "eos_token_id": 2,
9Added: "hidden_act": "silu",
10Added: "hidden_size": 576,
11Added: "initializer_range": 0.041666666666666664,
12Added: "intermediate_size": 1536,
13Added: "is_llama_config": true,
14Added: "max_position_embeddings": 8192,
15Added: "mlp_bias": false,
16Added: "model_type": "llama",
17Added: "num_attention_heads": 9,
18Added: "num_hidden_layers": 30,
19Added: "num_key_value_heads": 3,
20Added: "pad_token_id": 2,
21Added: "pretraining_tp": 1,
22Added: "rms_norm_eps": 1e-05,
23Added: "rope_interleaved": false,
24Added: "rope_scaling": null,
25Added: "rope_theta": 100000,
26Added: "tie_word_embeddings": true,
27Added: "torch_dtype": "bfloat16",
28Added: "transformers_version": "4.42.3",
29Added: "transformers.js_config": {
30Added: "kv_cache_dtype": {
31Added: "q4f16": "float16",
32Added: "fp16": "float16"
33Added: }
34Added: },
35Added: "use_cache": true,
36Added: "vocab_size": 49152
37Added: }

generation_config.json

Added+7 -0
Lines 0 to 0 become lines 1 to 7
@@ -0,0 +1,7 @@
1Added: {
2Added: "_from_model_config": true,
3Added: "bos_token_id": 1,
4Added: "eos_token_id": 2,
5Added: "pad_token_id": 2,
6Added: "transformers_version": "4.42.3"
7Added: }

merges.txt

Added

This file is too large to display.

model.safetensors

Added

Large (LFS-tracked) file content changed — 257 MB

special_tokens_map.json

Added+34 -0
Lines 0 to 0 become lines 1 to 34
@@ -0,0 +1,34 @@
1Added: {
2Added: "additional_special_tokens": [
3Added: "<|im_start|>",
4Added: "<|im_end|>"
5Added: ],
6Added: "bos_token": {
7Added: "content": "<|im_start|>",
8Added: "lstrip": false,
9Added: "normalized": false,
10Added: "rstrip": false,
11Added: "single_word": false
12Added: },
13Added: "eos_token": {
14Added: "content": "<|im_end|>",
15Added: "lstrip": false,
16Added: "normalized": false,
17Added: "rstrip": false,
18Added: "single_word": false
19Added: },
20Added: "pad_token": {
21Added: "content": "<|im_end|>",
22Added: "lstrip": false,
23Added: "normalized": false,
24Added: "rstrip": false,
25Added: "single_word": false
26Added: },
27Added: "unk_token": {
28Added: "content": "<|endoftext|>",
29Added: "lstrip": false,
30Added: "normalized": false,
31Added: "rstrip": false,
32Added: "single_word": false
33Added: }
34Added: }

tokenizer.json

Added

Large (LFS-tracked) file content changed — 2.0 MB

tokenizer_config.json

Added+154 -0
Lines 0 to 0 become lines 1 to 154
@@ -0,0 +1,154 @@
1Added: {
2Added: "add_prefix_space": false,
3Added: "added_tokens_decoder": {
4Added: "0": {
5Added: "content": "<|endoftext|>",
6Added: "lstrip": false,
7Added: "normalized": false,
8Added: "rstrip": false,
9Added: "single_word": false,
10Added: "special": true
11Added: },
12Added: "1": {
13Added: "content": "<|im_start|>",
14Added: "lstrip": false,
15Added: "normalized": false,
16Added: "rstrip": false,
17Added: "single_word": false,
18Added: "special": true
19Added: },
20Added: "2": {
21Added: "content": "<|im_end|>",
22Added: "lstrip": false,
23Added: "normalized": false,
24Added: "rstrip": false,
25Added: "single_word": false,
26Added: "special": true
27Added: },
28Added: "3": {
29Added: "content": "<repo_name>",
30Added: "lstrip": false,
31Added: "normalized": false,
32Added: "rstrip": false,
33Added: "single_word": false,
34Added: "special": true
35Added: },
36Added: "4": {
37Added: "content": "<reponame>",
38Added: "lstrip": false,
39Added: "normalized": false,
40Added: "rstrip": false,
41Added: "single_word": false,
42Added: "special": true
43Added: },
44Added: "5": {
45Added: "content": "<file_sep>",
46Added: "lstrip": false,
47Added: "normalized": false,
48Added: "rstrip": false,
49Added: "single_word": false,
50Added: "special": true
51Added: },
52Added: "6": {
53Added: "content": "<filename>",
54Added: "lstrip": false,
55Added: "normalized": false,
56Added: "rstrip": false,
57Added: "single_word": false,
58Added: "special": true
59Added: },
60Added: "7": {
61Added: "content": "<gh_stars>",
62Added: "lstrip": false,
63Added: "normalized": false,
64Added: "rstrip": false,
65Added: "single_word": false,
66Added: "special": true
67Added: },
68Added: "8": {
69Added: "content": "<issue_start>",
70Added: "lstrip": false,
71Added: "normalized": false,
72Added: "rstrip": false,
73Added: "single_word": false,
74Added: "special": true
75Added: },
76Added: "9": {
77Added: "content": "<issue_comment>",
78Added: "lstrip": false,
79Added: "normalized": false,
80Added: "rstrip": false,
81Added: "single_word": false,
82Added: "special": true
83Added: },
84Added: "10": {
85Added: "content": "<issue_closed>",
86Added: "lstrip": false,
87Added: "normalized": false,
88Added: "rstrip": false,
89Added: "single_word": false,
90Added: "special": true
91Added: },
92Added: "11": {
93Added: "content": "<jupyter_start>",
94Added: "lstrip": false,
95Added: "normalized": false,
96Added: "rstrip": false,
97Added: "single_word": false,
98Added: "special": true
99Added: },
100Added: "12": {
101Added: "content": "<jupyter_text>",
102Added: "lstrip": false,
103Added: "normalized": false,
104Added: "rstrip": false,
105Added: "single_word": false,
106Added: "special": true
107Added: },
108Added: "13": {
109Added: "content": "<jupyter_code>",
110Added: "lstrip": false,
111Added: "normalized": false,
112Added: "rstrip": false,
113Added: "single_word": false,
114Added: "special": true
115Added: },
116Added: "14": {
117Added: "content": "<jupyter_output>",
118Added: "lstrip": false,
119Added: "normalized": false,
120Added: "rstrip": false,
121Added: "single_word": false,
122Added: "special": true
123Added: },
124Added: "15": {
125Added: "content": "<jupyter_script>",
126Added: "lstrip": false,
127Added: "normalized": false,
128Added: "rstrip": false,
129Added: "single_word": false,
130Added: "special": true
131Added: },
132Added: "16": {
133Added: "content": "<empty_output>",
134Added: "lstrip": false,
135Added: "normalized": false,
136Added: "rstrip": false,
137Added: "single_word": false,
138Added: "special": true
139Added: }
140Added: },
141Added: "additional_special_tokens": [
142Added: "<|im_start|>",
143Added: "<|im_end|>"
144Added: ],
145Added: "bos_token": "<|im_start|>",
146Added: "chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful AI assistant named SmolLM, trained by Hugging Face<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
147Added: "clean_up_tokenization_spaces": false,
148Added: "eos_token": "<|im_end|>",
149Added: "model_max_length": 8192,
150Added: "pad_token": "<|im_end|>",
151Added: "tokenizer_class": "GPT2Tokenizer",
152Added: "unk_token": "<|endoftext|>",
153Added: "vocab_size": 49152
154Added: }

vocab.json

Added

This file is too large to display.