eliebak HF staff commited on
Commit
c369d07
1 Parent(s): e682e54

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +108 -68
README.md CHANGED
@@ -1,87 +1,127 @@
1
  ---
2
- base_model: HuggingFaceTB/smollm2-135M-8k-lc100k-mix1-ep2
3
- tags:
4
- - alignment-handbook
5
- - trl
6
- - dpo
7
- - generated_from_trainer
8
- - trl
9
- - dpo
10
- - generated_from_trainer
11
- datasets:
12
- - HuggingFaceH4/ultrafeedback_binarized
13
- model-index:
14
- - name: smollm2-135M-8k-lc100k-dpo-ultaf-ep2
15
- results: []
16
  ---
17
 
18
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
19
- should probably proofread and complete it, then remove this comment. -->
20
 
21
- [<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="200" height="32"/>](https://wandb.ai/loubnabnl/huggingface/runs/3el89rp6)
22
- # smollm2-135M-8k-lc100k-dpo-ultaf-ep2
23
 
24
- This model is a fine-tuned version of [HuggingFaceTB/smollm2-135M-8k-lc100k-mix1-ep2](https://huggingface.co/HuggingFaceTB/smollm2-135M-8k-lc100k-mix1-ep2) on the HuggingFaceH4/ultrafeedback_binarized dataset.
25
- It achieves the following results on the evaluation set:
26
- - Loss: 0.6741
27
- - Rewards/chosen: -0.0719
28
- - Rewards/rejected: -0.3407
29
- - Rewards/accuracies: 0.6151
30
- - Rewards/margins: 0.2687
31
- - Logps/rejected: -378.1583
32
- - Logps/chosen: -443.6482
33
- - Logits/rejected: 4.9520
34
- - Logits/chosen: 4.6009
35
 
36
- ## Model description
37
 
38
- More information needed
 
 
 
 
39
 
40
- ## Intended uses & limitations
41
 
42
- More information needed
43
 
44
- ## Training and evaluation data
45
 
46
- More information needed
47
 
48
- ## Training procedure
49
 
50
- ### Training hyperparameters
 
 
 
51
 
52
- The following hyperparameters were used during training:
53
- - learning_rate: 1e-06
54
- - train_batch_size: 2
55
- - eval_batch_size: 4
56
- - seed: 42
57
- - distributed_type: multi-GPU
58
- - num_devices: 8
59
- - gradient_accumulation_steps: 8
60
- - total_train_batch_size: 128
61
- - total_eval_batch_size: 32
62
- - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
63
- - lr_scheduler_type: cosine
64
- - lr_scheduler_warmup_ratio: 0.1
65
- - num_epochs: 2
66
 
67
- ### Training results
 
 
 
68
 
69
- | Training Loss | Epoch | Step | Validation Loss | Rewards/chosen | Rewards/rejected | Rewards/accuracies | Rewards/margins | Logps/rejected | Logps/chosen | Logits/rejected | Logits/chosen |
70
- |:-------------:|:------:|:----:|:---------------:|:--------------:|:----------------:|:------------------:|:---------------:|:--------------:|:------------:|:---------------:|:-------------:|
71
- | 0.7296 | 0.2094 | 100 | 0.7357 | 0.0117 | -0.0252 | 0.5516 | 0.0369 | -377.5274 | -443.4810 | 5.1272 | 4.7554 |
72
- | 0.7062 | 0.4187 | 200 | 0.6988 | -0.0251 | -0.0968 | 0.5675 | 0.0717 | -377.6706 | -443.5545 | 5.0879 | 4.7255 |
73
- | 0.6782 | 0.6281 | 300 | 0.6943 | -0.0323 | -0.2031 | 0.5675 | 0.1708 | -377.8831 | -443.5688 | 5.0161 | 4.6621 |
74
- | 0.6863 | 0.8375 | 400 | 0.6757 | -0.0882 | -0.2789 | 0.5992 | 0.1907 | -378.0348 | -443.6808 | 4.9992 | 4.6459 |
75
- | 0.6836 | 1.0468 | 500 | 0.6708 | -0.0957 | -0.3325 | 0.6349 | 0.2368 | -378.1419 | -443.6958 | 4.9696 | 4.6170 |
76
- | 0.6349 | 1.2562 | 600 | 0.6720 | -0.0539 | -0.3214 | 0.5992 | 0.2675 | -378.1197 | -443.6121 | 4.9707 | 4.6203 |
77
- | 0.6427 | 1.4656 | 700 | 0.6796 | -0.0877 | -0.3456 | 0.6032 | 0.2579 | -378.1681 | -443.6797 | 4.9430 | 4.5920 |
78
- | 0.6128 | 1.6750 | 800 | 0.6704 | -0.0604 | -0.3680 | 0.6071 | 0.3075 | -378.2128 | -443.6252 | 4.9689 | 4.6106 |
79
- | 0.6474 | 1.8843 | 900 | 0.6692 | -0.0590 | -0.3703 | 0.6270 | 0.3113 | -378.2174 | -443.6223 | 4.9211 | 4.5737 |
80
 
 
81
 
82
- ### Framework versions
 
 
 
 
 
83
 
84
- - Transformers 4.42.3
85
- - Pytorch 2.1.2
86
- - Datasets 2.20.0
87
- - Tokenizers 0.19.1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/7IzejwZJ62MfRwvDYvQXY.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.
26
 
27
+ We developed the instruct version through supervised fine-tuning (SFT) using a combination of public datasets and our own curated datasets, designed to enhance instruction following, rewriting, and summarization capabilities. We then applied Direct Preference Optimization (DPO) using a mix of UltraFeedback and DPO-ORPO.
28
 
29
+ ### How to use
30
 
31
+ ### Transformers
32
+ ```bash
33
+ pip install transformers
34
+ ```
35
 
36
+ ```python
37
+ from transformers import AutoModelForCausalLM, AutoTokenizer
38
+ checkpoint = "HuggingFaceTB/SmolLM2-135M-Instruct"
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
41
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
42
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
43
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
44
 
45
+ messages = [{"role": "user", "content": "What is gravity?"}]
46
+ input_text=tokenizer.apply_chat_template(messages, tokenize=False)
47
+ print(input_text)
48
+ inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
49
+ outputs = model.generate(inputs, max_new_tokens=50, temperature=0.2, top_p=0.9, do_sample=True)
50
+ print(tokenizer.decode(outputs[0]))
51
+ ```
 
 
 
 
52
 
53
+ 🚧 TODO ADD SYSTEM PROMPT AND GOOD EXAMPLES FOR EXAMPLE FOR REWRITING.. 🚧
54
 
55
+ ### Chat in TRL
56
+ You can also use the TRL CLI to chat with the model from the terminal:
57
+ ```bash
58
+ pip install trl
59
+ trl chat --model_name_or_path HuggingFaceTB/SmolLM2-135M-Instruct --device cpu
60
+ ```
61
 
62
+ ## Evaluation
63
+
64
+ 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.
65
+
66
+ ## Base pre-trained model
67
+
68
+ | Metrics | SmolLM2-135M-8k | SmolLM-135M |
69
+ |:-------------------|:----------------:|:------------:|
70
+ | HellaSwag | **42.1** | 41.2 |
71
+ | ARC (Average) | **43.9** | 42.4 |
72
+ | PIQA | 68.4 | 68.4 |
73
+ | MMLU (cloze) | **31.5** | 30.2 |
74
+ | CommonsenseQA | **33.9** | 32.7 |
75
+ | TriviaQA | 4.1 | **4.3** |
76
+ | Winogrande | 51.3 | 51.3 |
77
+ | OpenBookQA | **34.6** | 34.0 |
78
+ | GSM8K (5-shot) | **1.4** | 1.0 |
79
+
80
+
81
+ ## Instruction model
82
+
83
+ | Metric | SmolLM2-135M-Instruct | SmolLM-135M-Instruct |
84
+ |:-----------------------------|:---------------------:|:--------------------:|
85
+ | IFEval (Average prompt/inst) | **29.9** | 17.2 |
86
+ | MT-Bench | **19.8** | 16.8 |
87
+ | HellaSwag | **40.9** | 38.9 |
88
+ | ARC (Average) | **37.3** | 33.9 |
89
+ | PIQA | **66.3** | 64.0 |
90
+ | MMLU (cloze) | **29.3** | 28.3 |
91
+ | BBH (3-shot) | **28.2** | 25.2 |
92
+ | GSM8K (5-shot) | 1.4 | 1.4 |
93
+
94
+
95
+
96
+ ## Limitations
97
+
98
+ 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.
99
+
100
+ ## Training
101
+
102
+ ### Model
103
+
104
+ - **Architecture:** Transformer decoder
105
+ - **Pretraining tokens:** 4T
106
+ - **Precision:** bfloat16
107
+
108
+ ### Hardware
109
+
110
+ - **GPUs:** 64 H100
111
+
112
+ ### Software
113
+
114
+ - **Training Framework:** [nanotron](https://github.com/huggingface/nanotron/tree/main)
115
+
116
+ ## License
117
+
118
+ [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
119
+
120
+ ## Citation
121
+ ```bash
122
+ @misc{allal2024SmolLM2,
123
+ title={SmolLM2 - with great data, comes great performance},
124
+ 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},
125
+ year={2024},
126
+ }
127
+ ```