Model
ui-inference/ui-inference-smollm2-135m-instruct
- Task:Text Generation
- Libraries:transformerstransformers.js
- Formats:onnxsafetensors
- Languages:English
- License:apache-2.0
- arXiv:arXiv:2502.02737
Dedicated endpoint
Sign in to deployInference Providers
This model isn't deployed by any Inference Provider.
Spaces
Create a Space with this modelUse this model
Choose individual files there, or download a full snapshot with the Python example below.
Download with the whiteduck client
pip install https://provyd.xyz/clients/whiteduck-0.1.0-py3-none-any.whl
wd login --host 'https://api.provyd.xyz'
wd download 'ui-inference/ui-inference-smollm2-135m-instruct'Using the Hugging Face client instead
Install huggingface_hub with pip install huggingface_hub, then download this pinned snapshot. Set HF_TOKEN (the variable the Hugging Face client reads) to a whiteduck Read token for private repositories. Running the downloaded model requires software that supports its architecture.
Keep your whiteduck token away from calls that ignore HF_ENDPOINT, such as list_inference_endpoints: they send it to Hugging Face. See Docs.
from huggingface_hub import snapshot_download
import os
path = snapshot_download(
repo_id='ui-inference/ui-inference-smollm2-135m-instruct',
revision='df5600a4632cd86461b2adfd1a1473028ba69fd8',
endpoint='https://api.provyd.xyz',
token=os.environ.get("HF_TOKEN") or False,
)Load with transformers
import os
os.environ["HF_ENDPOINT"] = 'https://api.provyd.xyz'
from transformers import AutoModel, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('ui-inference/ui-inference-smollm2-135m-instruct')
model = AutoModel.from_pretrained('ui-inference/ui-inference-smollm2-135m-instruct')Use with local apps
This hub is self-hosted, so each command points the tool at it. Add a whiteduck access token as HF_TOKEN (the variable the Hugging Face client reads) for private repositories.
vLLM
# vLLM downloads through huggingface_hub, which honours HF_ENDPOINT; set HF_TOKEN for a private repository.
HF_ENDPOINT='https://api.provyd.xyz' vllm serve 'ui-inference/ui-inference-smollm2-135m-instruct'Clone with git
git clone 'https://api.provyd.xyz/ui-inference/ui-inference-smollm2-135m-instruct'Clone with git over SSH
git clone 'ssh://git@wd.provyd.xyz:2222/ui-inference/ui-inference-smollm2-135m-instruct'Needs an SSH key on your account. Add an SSH key
Use the API
Read repository metadata at this commit. Set HF_TOKEN (the variable the Hugging Face client reads) to a whiteduck Read token. Tokens grant account-level access, not access to just this model.
curl 'https://api.provyd.xyz/api/models/ui-inference/ui-inference-smollm2-135m-instruct/revision/df5600a4632cd86461b2adfd1a1473028ba69fd8' \
-H "Authorization: Bearer $HF_TOKEN"Inference is separate from file storage. The owner must configure and start a supported model using the inference controls. To call it you need a model API key (made on the model page), or a token of any scope (Read or stronger) from the model owner. Visitors can use the try box only when the owner allows it. A token cannot enable unavailable GPU hardware.
Blame for README.md at df5600a
| Line | Commit | Author | Date | Code |
|---|---|---|---|---|
| 1 | Initial commitc5f0634 | ui-inference | --- | |
| 2 | Mirror HuggingFaceTB/SmolLM2-135M-Instructdf5600a | ui-inference | library_name: transformers | |
| 3 | Initial commitc5f0634 | ui-inference | license: apache-2.0 | |
| 4 | Mirror HuggingFaceTB/SmolLM2-135M-Instructdf5600a | ui-inference | language: | |
| 5 | - en | |||
| 6 | pipeline_tag: text-generation | |||
| 7 | tags: | |||
| 8 | - safetensors | |||
| 9 | - onnx | |||
| 10 | - transformers.js | |||
| 11 | base_model: | |||
| 12 | - HuggingFaceTB/SmolLM2-135M | |||
| 13 | Initial commitc5f0634 | ui-inference | --- | |
| 14 | Mirror HuggingFaceTB/SmolLM2-135M-Instructdf5600a | ui-inference | ||
| 15 | ||||
| 16 | # SmolLM2 | |||
| 17 | ||||
| 18 |  | |||
| 19 | ||||
| 20 | ## Table of Contents | |||
| 21 | ||||
| 22 | 1. [Model Summary](##model-summary) | |||
| 23 | 2. [Limitations](##limitations) | |||
| 24 | 3. [Training](##training) | |||
| 25 | 4. [License](##license) | |||
| 26 | 5. [Citation](##citation) | |||
| 27 | ||||
| 28 | ## Model Summary | |||
| 29 | ||||
| 30 | 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 | |||
| 31 | ||||
| 32 | 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). | |||
| 33 | ||||
| 34 | 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). | |||
| 35 | 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 | |||
| 36 | ||||
| 37 | ### How to use | |||
| 38 | ||||
| 39 | ### Transformers | |||
| 40 | ```bash | |||
| 41 | pip install transformers | |||
| 42 | ``` | |||
| 43 | ||||
| 44 | ```python | |||
| 45 | from transformers import AutoModelForCausalLM, AutoTokenizer | |||
| 46 | checkpoint = "HuggingFaceTB/SmolLM2-135M-Instruct" | |||
| 47 | ||||
| 48 | device = "cuda" # for GPU usage or "cpu" for CPU usage | |||
| 49 | tokenizer = AutoTokenizer.from_pretrained(checkpoint) | |||
| 50 | # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")` | |||
| 51 | model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device) | |||
| 52 | ||||
| 53 | messages = [{"role": "user", "content": "What is gravity?"}] | |||
| 54 | input_text=tokenizer.apply_chat_template(messages, tokenize=False) | |||
| 55 | print(input_text) | |||
| 56 | inputs = tokenizer.encode(input_text, return_tensors="pt").to(device) | |||
| 57 | outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True) | |||
| 58 | print(tokenizer.decode(outputs[0])) | |||
| 59 | ``` | |||
| 60 | ||||
| 61 | ### Chat in TRL | |||
| 62 | You can also use the TRL CLI to chat with the model from the terminal: | |||
| 63 | ```bash | |||
| 64 | pip install trl | |||
| 65 | trl chat --model_name_or_path HuggingFaceTB/SmolLM2-135M-Instruct --device cpu | |||
| 66 | ``` | |||
| 67 | ||||
| 68 | ### Transformers.js | |||
| 69 | ||||
| 70 | ```bash | |||
| 71 | npm i @huggingface/transformers | |||
| 72 | ``` | |||
| 73 | ||||
| 74 | ```js | |||
| 75 | import { pipeline } from "@huggingface/transformers"; | |||
| 76 | ||||
| 77 | // Create a text generation pipeline | |||
| 78 | const generator = await pipeline( | |||
| 79 | "text-generation", | |||
| 80 | "HuggingFaceTB/SmolLM2-135M-Instruct", | |||
| 81 | ); | |||
| 82 | ||||
| 83 | // Define the list of messages | |||
| 84 | const messages = [ | |||
| 85 | { role: "system", content: "You are a helpful assistant." }, | |||
| 86 | { role: "user", content: "What is the capital of France?" }, | |||
| 87 | ]; | |||
| 88 | ||||
| 89 | // Generate a response | |||
| 90 | const output = await generator(messages, { max_new_tokens: 128 }); | |||
| 91 | console.log(output[0].generated_text.at(-1).content); | |||
| 92 | // "The capital of France is Paris." | |||
| 93 | ``` | |||
| 94 | ||||
| 95 | ||||
| 96 | ## Evaluation | |||
| 97 | ||||
| 98 | 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. | |||
| 99 | ||||
| 100 | ## Base pre-trained model | |||
| 101 | ||||
| 102 | | Metrics | SmolLM2-135M-8k | SmolLM-135M | | |||
| 103 | |:-------------------|:----------------:|:------------:| | |||
| 104 | | HellaSwag | **42.1** | 41.2 | | |||
| 105 | | ARC (Average) | **43.9** | 42.4 | | |||
| 106 | | PIQA | 68.4 | 68.4 | | |||
| 107 | | MMLU (cloze) | **31.5** | 30.2 | | |||
| 108 | | CommonsenseQA | **33.9** | 32.7 | | |||
| 109 | | TriviaQA | 4.1 | **4.3** | | |||
| 110 | | Winogrande | 51.3 | 51.3 | | |||
| 111 | | OpenBookQA | **34.6** | 34.0 | | |||
| 112 | | GSM8K (5-shot) | **1.4** | 1.0 | | |||
| 113 | ||||
| 114 | ||||
| 115 | ## Instruction model | |||
| 116 | ||||
| 117 | | Metric | SmolLM2-135M-Instruct | SmolLM-135M-Instruct | | |||
| 118 | |:-----------------------------|:---------------------:|:--------------------:| | |||
| 119 | | IFEval (Average prompt/inst) | **29.9** | 17.2 | | |||
| 120 | | MT-Bench | **19.8** | 16.8 | | |||
| 121 | | HellaSwag | **40.9** | 38.9 | | |||
| 122 | | ARC (Average) | **37.3** | 33.9 | | |||
| 123 | | PIQA | **66.3** | 64.0 | | |||
| 124 | | MMLU (cloze) | **29.3** | 28.3 | | |||
| 125 | | BBH (3-shot) | **28.2** | 25.2 | | |||
| 126 | | GSM8K (5-shot) | 1.4 | 1.4 | | |||
| 127 | ||||
| 128 | ||||
| 129 | ||||
| 130 | ## Limitations | |||
| 131 | ||||
| 132 | 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. | |||
| 133 | ||||
| 134 | ## Training | |||
| 135 | ||||
| 136 | ### Model | |||
| 137 | ||||
| 138 | - **Architecture:** Transformer decoder | |||
| 139 | - **Pretraining tokens:** 2T | |||
| 140 | - **Precision:** bfloat16 | |||
| 141 | ||||
| 142 | ### Hardware | |||
| 143 | ||||
| 144 | - **GPUs:** 64 H100 | |||
| 145 | ||||
| 146 | ### Software | |||
| 147 | ||||
| 148 | - **Training Framework:** [nanotron](https://github.com/huggingface/nanotron/tree/main) | |||
| 149 | ||||
| 150 | ## License | |||
| 151 | ||||
| 152 | [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) | |||
| 153 | ||||
| 154 | ## Citation | |||
| 155 | ```bash | |||
| 156 | @misc{allal2025smollm2smolgoesbig, | |||
| 157 | title={SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model}, | |||
| 158 | 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}, | |||
| 159 | year={2025}, | |||
| 160 | eprint={2502.02737}, | |||
| 161 | archivePrefix={arXiv}, | |||
| 162 | primaryClass={cs.CL}, | |||
| 163 | url={https://arxiv.org/abs/2502.02737}, | |||
| 164 | } | |||
| 165 | ``` |