Hjgugugjhuhjggg commited on
Commit
434719b
·
verified ·
1 Parent(s): 73c4195

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ language:
5
+ - en
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - safetensors
9
+ - onnx
10
+ - transformers.js
11
+ - autoquant
12
+ - gptq
13
+ base_model:
14
+ - HuggingFaceTB/SmolLM2-135M
15
+ ---
16
+
17
+
18
+ # SmolLM2
19
+
20
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61c141342aac764ce1654e43/3ntM63zkmxY2cNRhgY_Kl.png)
21
+
22
+ ## Table of Contents
23
+
24
+ 1. [Model Summary](##model-summary)
25
+ 2. [Limitations](##limitations)
26
+ 3. [Training](##training)
27
+ 4. [License](##license)
28
+ 5. [Citation](##citation)
29
+
30
+ ## Model Summary
31
+
32
+ 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.
33
+
34
+ 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).
35
+
36
+ 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).
37
+ 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
38
+
39
+ ### How to use
40
+
41
+ ### Transformers
42
+ ```bash
43
+ pip install transformers
44
+ ```
45
+
46
+ ```python
47
+ from transformers import AutoModelForCausalLM, AutoTokenizer
48
+ checkpoint = "HuggingFaceTB/SmolLM2-135M-Instruct"
49
+
50
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
51
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
52
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
53
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
54
+
55
+ messages = [{"role": "user", "content": "What is gravity?"}]
56
+ input_text=tokenizer.apply_chat_template(messages, tokenize=False)
57
+ print(input_text)
58
+ inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
59
+ outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
60
+ print(tokenizer.decode(outputs[0]))
61
+ ```
62
+
63
+ ### Chat in TRL
64
+ You can also use the TRL CLI to chat with the model from the terminal:
65
+ ```bash
66
+ pip install trl
67
+ trl chat --model_name_or_path HuggingFaceTB/SmolLM2-135M-Instruct --device cpu
68
+ ```
69
+
70
+ ## Evaluation
71
+
72
+ 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.
73
+
74
+ ## Base pre-trained model
75
+
76
+ | Metrics | SmolLM2-135M-8k | SmolLM-135M |
77
+ |:-------------------|:----------------:|:------------:|
78
+ | HellaSwag | **42.1** | 41.2 |
79
+ | ARC (Average) | **43.9** | 42.4 |
80
+ | PIQA | 68.4 | 68.4 |
81
+ | MMLU (cloze) | **31.5** | 30.2 |
82
+ | CommonsenseQA | **33.9** | 32.7 |
83
+ | TriviaQA | 4.1 | **4.3** |
84
+ | Winogrande | 51.3 | 51.3 |
85
+ | OpenBookQA | **34.6** | 34.0 |
86
+ | GSM8K (5-shot) | **1.4** | 1.0 |
87
+
88
+
89
+ ## Instruction model
90
+
91
+ | Metric | SmolLM2-135M-Instruct | SmolLM-135M-Instruct |
92
+ |:-----------------------------|:---------------------:|:--------------------:|
93
+ | IFEval (Average prompt/inst) | **29.9** | 17.2 |
94
+ | MT-Bench | **19.8** | 16.8 |
95
+ | HellaSwag | **40.9** | 38.9 |
96
+ | ARC (Average) | **37.3** | 33.9 |
97
+ | PIQA | **66.3** | 64.0 |
98
+ | MMLU (cloze) | **29.3** | 28.3 |
99
+ | BBH (3-shot) | **28.2** | 25.2 |
100
+ | GSM8K (5-shot) | 1.4 | 1.4 |
101
+
102
+
103
+
104
+ ## Limitations
105
+
106
+ 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.
107
+
108
+ ## Training
109
+
110
+ ### Model
111
+
112
+ - **Architecture:** Transformer decoder
113
+ - **Pretraining tokens:** 2T
114
+ - **Precision:** bfloat16
115
+
116
+ ### Hardware
117
+
118
+ - **GPUs:** 64 H100
119
+
120
+ ### Software
121
+
122
+ - **Training Framework:** [nanotron](https://github.com/huggingface/nanotron/tree/main)
123
+
124
+ ## License
125
+
126
+ [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
127
+
128
+ ## Citation
129
+ ```bash
130
+ @misc{allal2024SmolLM2,
131
+ title={SmolLM2 - with great data, comes great performance},
132
+ 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},
133
+ year={2024},
134
+ }
135
+ ```
config.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "HuggingFaceTB/SmolLM2-135M-Instruct",
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "bos_token_id": 1,
9
+ "eos_token_id": 2,
10
+ "head_dim": 64,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 576,
13
+ "initializer_range": 0.041666666666666664,
14
+ "intermediate_size": 1536,
15
+ "is_llama_config": true,
16
+ "max_position_embeddings": 8192,
17
+ "mlp_bias": false,
18
+ "model_type": "llama",
19
+ "num_attention_heads": 9,
20
+ "num_hidden_layers": 30,
21
+ "num_key_value_heads": 3,
22
+ "pad_token_id": 2,
23
+ "pretraining_tp": 1,
24
+ "quantization_config": {
25
+ "batch_size": 1,
26
+ "bits": 2,
27
+ "block_name_to_quantize": null,
28
+ "cache_block_outputs": true,
29
+ "damp_percent": 0.1,
30
+ "dataset": "c4",
31
+ "desc_act": false,
32
+ "exllama_config": {
33
+ "version": 1
34
+ },
35
+ "group_size": 128,
36
+ "max_input_length": null,
37
+ "model_seqlen": null,
38
+ "module_name_preceding_first_block": null,
39
+ "modules_in_block_to_quantize": null,
40
+ "pad_token_id": null,
41
+ "quant_method": "gptq",
42
+ "sym": true,
43
+ "tokenizer": null,
44
+ "true_sequential": true,
45
+ "use_cuda_fp16": false,
46
+ "use_exllama": true
47
+ },
48
+ "rms_norm_eps": 1e-05,
49
+ "rope_interleaved": false,
50
+ "rope_scaling": null,
51
+ "rope_theta": 100000,
52
+ "tie_word_embeddings": true,
53
+ "torch_dtype": "float16",
54
+ "transformers.js_config": {
55
+ "kv_cache_dtype": {
56
+ "fp16": "float16",
57
+ "q4f16": "float16"
58
+ }
59
+ },
60
+ "transformers_version": "4.48.0",
61
+ "use_cache": true,
62
+ "vocab_size": 49152
63
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 2,
6
+ "transformers_version": "4.48.0"
7
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bcf1f516ecea356aef30361e9ddb9170d9c7457d278ee7eae353391dec8c541c
3
+ size 85952336
special_tokens_map.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>"
5
+ ],
6
+ "bos_token": {
7
+ "content": "<|im_start|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false
12
+ },
13
+ "eos_token": {
14
+ "content": "<|im_end|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ },
20
+ "pad_token": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false
26
+ },
27
+ "unk_token": {
28
+ "content": "<|endoftext|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false
33
+ }
34
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<repo_name>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "4": {
37
+ "content": "<reponame>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "5": {
45
+ "content": "<file_sep>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "6": {
53
+ "content": "<filename>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "7": {
61
+ "content": "<gh_stars>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "8": {
69
+ "content": "<issue_start>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "9": {
77
+ "content": "<issue_comment>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "10": {
85
+ "content": "<issue_closed>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "11": {
93
+ "content": "<jupyter_start>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "12": {
101
+ "content": "<jupyter_text>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "13": {
109
+ "content": "<jupyter_code>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "14": {
117
+ "content": "<jupyter_output>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": true
123
+ },
124
+ "15": {
125
+ "content": "<jupyter_script>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": true
131
+ },
132
+ "16": {
133
+ "content": "<empty_output>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": true
139
+ }
140
+ },
141
+ "additional_special_tokens": [
142
+ "<|im_start|>",
143
+ "<|im_end|>"
144
+ ],
145
+ "bos_token": "<|im_start|>",
146
+ "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 %}",
147
+ "clean_up_tokenization_spaces": false,
148
+ "eos_token": "<|im_end|>",
149
+ "extra_special_tokens": {},
150
+ "model_max_length": 8192,
151
+ "pad_token": "<|im_end|>",
152
+ "tokenizer_class": "GPT2Tokenizer",
153
+ "unk_token": "<|endoftext|>",
154
+ "vocab_size": 49152
155
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff