vonjack commited on
Commit
167cc5c
1 Parent(s): 01437f3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +133 -3
README.md CHANGED
@@ -1,3 +1,133 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ language:
5
+ - en
6
+ ---
7
+
8
+
9
+ # SmolLM2
10
+
11
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61c141342aac764ce1654e43/XtSR4NkriicR6fGiWGowZ.png)
12
+
13
+ ## Table of Contents
14
+
15
+ 1. [Model Summary](##model-summary)
16
+ 2. [Limitations](##limitations)
17
+ 3. [Training](##training)
18
+ 4. [License](##license)
19
+ 5. [Citation](##citation)
20
+
21
+ ## Model Summary
22
+
23
+ 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.
24
+
25
+ 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).
26
+
27
+ The 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).
28
+
29
+ ### How to use
30
+
31
+ ```bash
32
+ pip install transformers
33
+ ```
34
+
35
+ #### Running the model on CPU/GPU/multi GPU
36
+ * _Using full precision_
37
+ ```python
38
+ # pip install transformers
39
+ from transformers import AutoModelForCausalLM, AutoTokenizer
40
+ checkpoint = "HuggingFaceTB/SmolLM2-135M"
41
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
42
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
43
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
44
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
45
+ inputs = tokenizer.encode("Gravity is", return_tensors="pt").to(device)
46
+ outputs = model.generate(inputs)
47
+ print(tokenizer.decode(outputs[0]))
48
+ ```
49
+
50
+ * _Using `torch.bfloat16`_
51
+ ```python
52
+ # pip install accelerate
53
+ import torch
54
+ from transformers import AutoTokenizer, AutoModelForCausalLM
55
+ checkpoint = "HuggingFaceTB/SmolLM2-135M"
56
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
57
+ # for fp16 use `torch_dtype=torch.float16` instead
58
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
59
+ inputs = tokenizer.encode("Gravity is", return_tensors="pt").to("cuda")
60
+ outputs = model.generate(inputs)
61
+ print(tokenizer.decode(outputs[0]))
62
+ ```
63
+ ```bash
64
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
65
+ Memory footprint: 723.56 MB
66
+ ```
67
+
68
+ ## Evaluation
69
+
70
+ 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.
71
+
72
+ ## Base pre-trained model
73
+
74
+ | Metrics | SmolLM2-135M-8k | SmolLM-135M |
75
+ |:-------------------|:----------------:|:------------:|
76
+ | HellaSwag | **42.1** | 41.2 |
77
+ | ARC (Average) | **43.9** | 42.4 |
78
+ | PIQA | 68.4 | 68.4 |
79
+ | MMLU (cloze) | **31.5** | 30.2 |
80
+ | CommonsenseQA | **33.9** | 32.7 |
81
+ | TriviaQA | 4.1 | **4.3** |
82
+ | Winogrande | 51.3 | 51.3 |
83
+ | OpenBookQA | **34.6** | 34.0 |
84
+ | GSM8K (5-shot) | **1.4** | 1.0 |
85
+
86
+
87
+ ## Instruction model
88
+
89
+ | Metric | SmolLM2-135M-Instruct | SmolLM-135M-Instruct |
90
+ |:-----------------------------|:---------------------:|:--------------------:|
91
+ | IFEval (Average prompt/inst) | **29.9** | 17.2 |
92
+ | MT-Bench | **1.98** | 1.68 |
93
+ | HellaSwag | **40.9** | 38.9 |
94
+ | ARC (Average) | **37.3** | 33.9 |
95
+ | PIQA | **66.3** | 64.0 |
96
+ | MMLU (cloze) | **29.3** | 28.3 |
97
+ | BBH (3-shot) | **28.2** | 25.2 |
98
+ | GSM8K (5-shot) | 1.4 | 1.4 |
99
+
100
+
101
+
102
+ ## Limitations
103
+
104
+ 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.
105
+
106
+ ## Training
107
+
108
+ ### Model
109
+
110
+ - **Architecture:** Transformer decoder
111
+ - **Pretraining tokens:** 2T
112
+ - **Precision:** bfloat16
113
+
114
+ ### Hardware
115
+
116
+ - **GPUs:** 64 H100
117
+
118
+ ### Software
119
+
120
+ - **Training Framework:** [nanotron](https://github.com/huggingface/nanotron/tree/main)
121
+
122
+ ## License
123
+
124
+ [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
125
+
126
+ ## Citation
127
+ ```bash
128
+ @misc{allal2024SmolLM2,
129
+ title={SmolLM2 - with great data, comes great performance},
130
+ author={Loubna Ben Allal and Anton Lozhkov and Elie Bakouch and Gabriel Martín Blázquez and Lewis Tunstall and Agustín Piqueres and Andres Marafioti and Cyril Zakka and Leandro von Werra and Thomas Wolf},
131
+ year={2024},
132
+ }
133
+ ```