HuggingFaceTB/SmolLM2-360M
134510k
1---2library_name: transformers3license: apache-2.04language:5- en6---7 8 9# SmolLM210 11 1213 14## Table of Contents15 161. [Model Summary](##model-summary)172. [Limitations](##limitations)183. [Training](##training)194. [License](##license)205. [Citation](##citation)21 22## Model Summary23 24SmolLM2 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.0273725 26SmolLM2 demonstrates significant advances over its predecessor SmolLM1, particularly in instruction following, knowledge, reasoning. The 360M model was trained on 4 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).27 28The instruct model additionally supports tasks such as text rewriting, summarization and function calling 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).29 30For more details refer to: https://github.com/huggingface/smollm. You will find pre-training, post-training, evaluation and local inference code.31 32### How to use33 34```bash35pip install transformers36```37 38#### Running the model on CPU/GPU/multi GPU39* _Using full precision_40```python41# pip install transformers42from transformers import AutoModelForCausalLM, AutoTokenizer43checkpoint = "HuggingFaceTB/SmolLM2-360M"44device = "cuda" # for GPU usage or "cpu" for CPU usage45tokenizer = AutoTokenizer.from_pretrained(checkpoint)46# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`47model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)48inputs = tokenizer.encode("Gravity is", return_tensors="pt").to(device)49outputs = model.generate(inputs)50print(tokenizer.decode(outputs[0]))51```52 53* _Using `torch.bfloat16`_54```python55# pip install accelerate56import torch57from transformers import AutoTokenizer, AutoModelForCausalLM58checkpoint = "HuggingFaceTB/SmolLM2-360M"59tokenizer = AutoTokenizer.from_pretrained(checkpoint)60# for fp16 use `torch_dtype=torch.float16` instead61model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)62inputs = tokenizer.encode("Gravity is", return_tensors="pt").to("cuda")63outputs = model.generate(inputs)64print(tokenizer.decode(outputs[0]))65```66```bash67>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")68Memory footprint: 723.56 MB69```70 71## Evaluation72 73In 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.74 75## Base Pre-Trained Model76 77| Metrics | SmolLM2-360M | Qwen2.5-0.5B | SmolLM-360M |78|:-------------------|:------------:|:------------:|:------------:|79| HellaSwag | **54.5** | 51.2 | 51.8 |80| ARC (Average) | **53.0** | 45.4 | 50.1 |81| PIQA | **71.7** | 69.9 | 71.6 |82| MMLU (cloze) | **35.8** | 33.7 | 34.4 |83| CommonsenseQA | **38.0** | 31.6 | 35.3 |84| TriviaQA | **16.9** | 4.3 | 9.1 |85| Winogrande | 52.5 | **54.1** | 52.8 |86| OpenBookQA | **37.4** | **37.4** | 37.2 |87| GSM8K (5-shot) | 3.2 | **33.4** | 1.6 |88 89 90## Instruction Model91 92| Metric | SmolLM2-360M-Instruct | Qwen2.5-0.5B-Instruct | SmolLM-360M-Instruct |93|:-----------------------------|:---------------------:|:---------------------:|:---------------------:|94| IFEval (Average prompt/inst) | **41.0** | 31.6 | 19.8 |95| MT-Bench | 3.66 | **4.16** | 3.37 |96| HellaSwag | **52.1** | 48.0 | 47.9 |97| ARC (Average) | **43.7** | 37.3 | 38.8 |98| PIQA | **70.8** | 67.2 | 69.4 |99| MMLU (cloze) | **32.8** | 31.7 | 30.6 |100| BBH (3-shot) | 27.3 | **30.7** | 24.4 |101| GSM8K (5-shot) | 7.43 | **26.8** | 1.36 |102 103 104## Limitations105 106SmolLM2 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.107 108## Training109 110### Model111 112- **Architecture:** Transformer decoder113- **Pretraining tokens:** 4T114- **Precision:** bfloat16115 116### Hardware117 118- **GPUs:** 128 H100119 120### Software121 122- **Training Framework:** [nanotron](https://github.com/huggingface/nanotron/tree/main)123 124## License125 126[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)127 128## Citation129```bash130@misc{allal2025smollm2smolgoesbig,131 title={SmolLM2: When Smol Goes Big -- Data-Centric Training of a Small Language Model}, 132 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},133 year={2025},134 eprint={2502.02737},135 archivePrefix={arXiv},136 primaryClass={cs.CL},137 url={https://arxiv.org/abs/2502.02737}, 138}139```