File size: 8,754 Bytes
ce5a5b8
 
86f60e4
78196d3
86f60e4
 
ce5a5b8
 
86f60e4
 
ce5a5b8
 
 
 
 
 
86f60e4
ce5a5b8
86f60e4
 
78196d3
ce5a5b8
86f60e4
 
ce5a5b8
86f60e4
ce5a5b8
 
 
86f60e4
ce5a5b8
 
86f60e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a07e465
 
 
 
 
3c993aa
78196d3
cb04b21
 
 
 
 
 
 
 
 
 
 
86f60e4
 
 
78196d3
86f60e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78196d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86f60e4
 
 
 
 
 
 
cb04b21
86f60e4
78196d3
 
86f60e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ce5a5b8
 
86f60e4
 
 
cb04b21
86f60e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb04b21
86f60e4
 
 
 
 
 
 
 
 
 
78196d3
 
86f60e4
 
78196d3
86f60e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ce5a5b8
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
---
base_model: HuggingFaceTB/SmolLM-135M
datasets:
- wikimedia/wikipedia
library_name: Distily
license: creativeml-openrail-m
tags:
- generated_from_trainer
- Distily
base_model_relation: finetune
model-index:
- name: distily_smollm_dataset_sweep
  results: []
---


# Summary

Distilled with [Distily](https://github.com/lapp0/distily) library
using teacher model [HuggingFaceTB/SmolLM-135M](https://huggingface.co/HuggingFaceTB/SmolLM-135M)
on dataset [wikimedia/wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia).

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment.

# Model description

More information needed

# Intended uses & limitations

More information needed
-->

# Model Architecture:
- **Architecture**: `LlamaForCausalLM`
- **Total Parameters**: 81,413,568
- **Data Type (dtype)**: torch.float32
- **Model Size**: 0.30 GB

<details>
<summary>Student Model Details</summary>

```
LlamaForCausalLM(
  (model): LlamaModel(
    (embed_tokens): Embedding(49152, 576)
    (layers): ModuleList(
      (0-14): 15 x LlamaDecoderLayer(
        (self_attn): LlamaSdpaAttention(
          (q_proj): Linear(in_features=576, out_features=576, bias=False)
          (k_proj): Linear(in_features=576, out_features=192, bias=False)
          (v_proj): Linear(in_features=576, out_features=192, bias=False)
          (o_proj): Linear(in_features=576, out_features=576, bias=False)
          (rotary_emb): LlamaRotaryEmbedding()
        )
        (mlp): LigerSwiGLUMLP(
          (gate_proj): Linear(in_features=576, out_features=1536, bias=False)
          (up_proj): Linear(in_features=576, out_features=1536, bias=False)
          (down_proj): Linear(in_features=1536, out_features=576, bias=False)
        )
        (input_layernorm): LigerRMSNorm((576,), eps=1e-05, offset=0.0)
        (post_attention_layernorm): LigerRMSNorm((576,), eps=1e-05, offset=0.0)
      )
    )
    (norm): LigerRMSNorm((576,), eps=1e-05, offset=0.0)
    (rotary_emb): LlamaRotaryEmbedding()
  )
  (lm_head): Linear(in_features=576, out_features=49152, bias=False)
)
```

</details>
<br/>

# Benchmark Metrics Comparison

- student 0: `dataset_max_seq_length=1024, dataset_sample_size=1000000, dataset_subset=20231101.en, dataset_uri=wikimedia_wikipedia, per_device_train_batch_size=8`
- student 1: `dataset_max_seq_length=1024, dataset_sample_size=1000000, dataset_subset=None, dataset_uri=distily_filtered_redpajama_en, per_device_train_batch_size=8`
- student 2: `dataset_max_seq_length=1024, dataset_sample_size=1000000, dataset_subset=sample-10BT, dataset_uri=HuggingFaceFW_fineweb-edu, per_device_train_batch_size=8`
- student 3: `dataset_max_seq_length=1024, dataset_sample_size=1000000, dataset_subset=sample-10BT, dataset_uri=HuggingFaceFW_fineweb, per_device_train_batch_size=8`
- student 4: `dataset_max_seq_length=1024, dataset_sample_size=1000000, dataset_subset=sample-10BT, dataset_uri=HuggingFaceFW_fineweb, learning_rate=6e-05, per_device_train_batch_size=8`
- student 5: `dataset_max_seq_length=1024, dataset_sample_size=1000000, dataset_subset=sample-10BT, dataset_uri=HuggingFaceFW_fineweb-edu, learning_rate=6e-05, per_device_train_batch_size=8`
- student 6: `dataset_max_seq_length=1024, dataset_sample_size=4000000, dataset_subset=20231101.en, dataset_uri=wikimedia_wikipedia, per_device_train_batch_size=8`
- student 7: `dataset_max_seq_length=1024, dataset_sample_size=4000000, dataset_subset=20231101.en, dataset_uri=wikimedia_wikipedia, learning_rate=6e-05, per_device_train_batch_size=8`

| Metric | teacher | student 0 | student 1 | student 2 | student 3 | student 4 | student 5 | student 6 | student 7 |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| tinyArc.acc_norm,none | 0.37 | 0.303 | 0.295 | 0.302 | 0.26 | 0.269 | **0.319** | 0.286 | 0.299 |
| tinyGSM8k.exact_match,flexible-extract | 0.006 | 0.029 | **0.03** | 0.025 | 0.006 | 0.006 | 0.012 | 0.012 | 0.017 |
| tinyGSM8k.exact_match,strict-match | 0.006 | **0.006** | **0.006** | **0.006** | **0.006** | **0.006** | **0.006** | **0.006** | **0.006** |
| tinyHellaswag.acc_norm,none | 0.452 | 0.341 | 0.281 | 0.327 | 0.3 | 0.303 | 0.301 | **0.364** | 0.356 |
| tinyMMLU.acc_norm,none | 0.341 | 0.276 | 0.281 | 0.31 | 0.286 | 0.279 | 0.292 | 0.295 | **0.328** |
| tinyTruthfulQA.acc,none | 0.38 | **0.463** | 0.447 | 0.423 | 0.419 | 0.421 | 0.427 | 0.44 | 0.436 |
| tinyWinogrande.acc_norm,none | 0.509 | 0.466 | 0.436 | 0.46 | **0.492** | 0.473 | 0.417 | 0.439 | 0.482 |

# Resource Usage

- Max Train VRAM Use: 13.1269 GB
- Available VRAM: 23.4329 GB
- GPUs: 
  - 1x NVIDIA GeForce RTX 4090
- CPUs: 64
- CPU Memory: 251.7299 GB
- CPU Memory Bandwidth: 1600 GB/s

# Distillation (Teacher -> Student) Architecture Difference:

- **Architecture**: `LlamaForCausalLM` -> `LlamaForCausalLM`
- **Total Parameters**: 134,515,008 -> 81,413,568
- **Data Type (dtype)**: torch.float32 -> torch.float32
- **Model Size**: 0.25 GB -> 0.30 GB

<details>
<summary>Module Diff Details</summary>

```diff
--- teacher model modules
+++ student model modules
@@ -2,7 +2,7 @@
   (model): LlamaModel(
     (embed_tokens): Embedding(49152, 576)
     (layers): ModuleList(
-      (0-29): 30 x LlamaDecoderLayer(
+      (0-14): 15 x LlamaDecoderLayer(
         (self_attn): LlamaSdpaAttention(
           (q_proj): Linear(in_features=576, out_features=576, bias=False)
           (k_proj): Linear(in_features=576, out_features=192, bias=False)
@@ -10,17 +10,16 @@
           (o_proj): Linear(in_features=576, out_features=576, bias=False)
           (rotary_emb): LlamaRotaryEmbedding()
         )
-        (mlp): LlamaMLP(
+        (mlp): LigerSwiGLUMLP(
           (gate_proj): Linear(in_features=576, out_features=1536, bias=False)
           (up_proj): Linear(in_features=576, out_features=1536, bias=False)
           (down_proj): Linear(in_features=1536, out_features=576, bias=False)
-          (act_fn): SiLU()
         )
-        (input_layernorm): LlamaRMSNorm((576,), eps=1e-05)
-        (post_attention_layernorm): LlamaRMSNorm((576,), eps=1e-05)
+        (input_layernorm): LigerRMSNorm((576,), eps=1e-05, offset=0.0)
+        (post_attention_layernorm): LigerRMSNorm((576,), eps=1e-05, offset=0.0)
       )
     )
-    (norm): LlamaRMSNorm((576,), eps=1e-05)
+    (norm): LigerRMSNorm((576,), eps=1e-05, offset=0.0)
     (rotary_emb): LlamaRotaryEmbedding()
   )
   (lm_head): Linear(in_features=576, out_features=49152, bias=False)

```

</details>
<br/>

# Train Dataset
Trained on 1,857,304,596 tokens from the [wikimedia/wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia) dataset.

- Num Samples: `3,992,000`
- Subset: `20231101.en`
- Split: `train`


# Training Objective

```
DistillationObjective(
    logits_loss_component=LossComponent(
        weight=1,
        loss_fn='kl'
    ),
    hs_loss_component=LossComponent(
        weight=0
    ),
    attn_loss_component=LossComponent(
        weight=0
    )
)
```

# Hyperparameters
The following hyperparameters were used during training:

<details>
<summary>Expand</summary>

- learning_rate: `6e-05`
- train_batch_size: `8`
- eval_batch_size: `4`
- seed: `42`
- optimizer: `Adam with betas=(0.9,0.999) and epsilon=1e-08`
- lr_scheduler_type: `polynomial`
- lr_scheduler_warmup_ratio: `0.1`
- num_epochs: `1.0`
- distillation_objective: `DistillationObjective(
    logits_loss_component=LossComponent(
        weight=1,
        loss_fn='kl'
    ),
    hs_loss_component=LossComponent(
        weight=0
    ),
    attn_loss_component=LossComponent(
        weight=0
    )
)`
- lr_scheduler: `<torch.optim.lr_scheduler.LambdaLR object at 0x7d28e0fc5450>`
- student_model_name_or_path: `None`
- student_config_name_or_path: `None`
- student_model_config: `{'num_hidden_layers': 15}`
- reinitialize_weights: `None`
- copy_teacher_modules: `[('lm_head', False)]`
- student_model_as_bitnet: `False`
- student_use_liger_kernel: `True`
- teacher_model_name_or_path: `HuggingFaceTB/SmolLM-135M`
- teacher_load_in_8bit: `False`
- teacher_load_in_4bit: `False`
- dataset_uri: `wikimedia/wikipedia`
- dataset_subset: `20231101.en`
- dataset_split: `train`
- dataset_column_name: `text`
- dataset_sample_size: `4000000`
- dataset_max_seq_length: `1024`
- dataset_test_size: `0.002`
- dataset_shuffle: `False`
- dataset_shuffle_seed: `42`
- dataset_trust_remote_code: `False`
- gradient_accumulation_steps: `1`
- weight_decay: `0.0`
- max_grad_norm: `1.0`
- warmup_ratio: `0.1`
- warmup_steps: `0`
- gradient_checkpointing: `True`

</details>
<br/>


# Framework Versions
- Distily 0.5.0
- Transformers 4.45.0.dev0
- Pytorch 2.5.0.dev20240910+cu121
- Datasets 2.21.0