---
base_model: gpt2
datasets:
- wikimedia/wikipedia
library_name: Distily
license: mit
tags:
- bitnet
- 1.58b
- generated_from_trainer
model-index:
- name: distily_multi_experiment
results: []
---
# Summary
Distilled with [Distily](https://github.com/lapp0/distily) library
using teacher model [gpt2](https://huggingface.co/gpt2)
on dataset [wikimedia/wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia).
# Model Architecture:
- **Architecture**: `GPT2LMHeadModel`
- **Total Parameters**: 124,439,808
- **Data Type (dtype)**: torch.bfloat16
- **Model Size**: 0.24 GB
# Evaluation Metrics Comparison
| step | epoch | enwikippl | frwikippl | loss | runtime | samples_per_second | steps_per_second | tinystoriesppl | zhwikippl |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **teacher eval** | | 43.25 | 61.25 | | | | | 11.6875 | 19.125 |
| 0 | 0 | 1829656068096.0 | 79714593013760.0 | 26.8020 | 30.2396 | 82.673 | 10.351 | 4898947072.0 | 21715354648576.0 |
| 2500 | 0.0404 | 908.0 | 7264.0 | 6.0454 | 30.2047 | 82.769 | 10.363 | 608.0 | 13888.0 |
| 5000 | 0.0808 | 376.0 | 1888.0 | 4.9904 | 30.154 | 82.908 | 10.38 | 294.0 | 250.0 |
| 7500 | 0.1212 | 227.0 | 904.0 | 4.4958 | 30.2026 | 82.774 | 10.363 | 199.0 | 183.0 |
| 10000 | 0.1616 | 170.0 | 692.0 | 4.2057 | 30.1547 | 82.906 | 10.38 | 160.0 | 172.0 |
| 12500 | 0.2020 | 129.0 | 458.0 | 3.8235 | 30.3035 | 82.499 | 10.329 | 107.0 | 127.0 |
| 15000 | 0.2424 | 108.5 | 404.0 | 3.6530 | 30.2712 | 82.587 | 10.34 | 88.0 | 179.0 |
| 17500 | 0.2828 | 94.0 | 362.0 | 3.5036 | 30.2085 | 82.758 | 10.361 | 75.0 | 125.0 |
| 20000 | 0.3232 | 77.5 | 264.0 | 3.3187 | 30.1387 | 82.95 | 10.385 | 62.0 | 128.0 |
| 22500 | 0.3636 | 66.0 | 219.0 | 3.1312 | 30.1887 | 82.812 | 10.368 | 51.0 | 95.0 |
| 25000 | 0.4040 | 63.75 | 191.0 | 3.0365 | 30.175 | 82.85 | 10.373 | 47.0 | 69.5 |
| 27500 | 0.4444 | 60.25 | 193.0 | 2.9840 | 30.2256 | 82.711 | 10.355 | 41.5 | 63.75 |
| 30000 | 0.4848 | 61.0 | 196.0 | 2.9776 | 30.1558 | 82.903 | 10.379 | 41.75 | 132.0 |
| 32500 | 0.5253 | 58.5 | 189.0 | 2.9520 | 30.1884 | 82.813 | 10.368 | 42.25 | 121.5 |
| 35000 | 0.5657 | 56.5 | 175.0 | 2.8863 | 30.1265 | 82.983 | 10.39 | 38.5 | 59.75 |
| 37500 | 0.6061 | 57.0 | 168.0 | 2.8672 | 30.1704 | 82.863 | 10.374 | 37.75 | 72.0 |
| 40000 | 0.6465 | 55.0 | 173.0 | 2.8404 | 30.1803 | 82.836 | 10.371 | 35.75 | 45.75 |
| 42500 | 0.6869 | 55.0 | 160.0 | 2.8200 | 30.1856 | 82.821 | 10.369 | 36.0 | 64.5 |
| 45000 | 0.7273 | 50.0 | 136.0 | 2.7104 | 30.1734 | 82.854 | 10.373 | 31.25 | 42.75 |
| 47500 | 0.7677 | 49.5 | 129.0 | 2.6868 | 30.192 | 82.803 | 10.367 | 29.75 | 37.0 |
| 50000 | 0.8081 | 50.0 | 131.0 | 2.6746 | 30.1592 | 82.893 | 10.378 | 29.5 | 39.0 |
| 52500 | 0.8485 | 49.5 | 126.0 | 2.6637 | 30.1577 | 82.898 | 10.379 | 28.75 | 39.25 |
| 55000 | 0.8889 | 48.5 | 121.5 | 2.6448 | 30.156 | 82.902 | 10.379 | 28.375 | 35.5 |
| 57500 | 0.9293 | 48.25 | 120.5 | 2.6397 | 30.2088 | 82.757 | 10.361 | 28.125 | 33.5 |
| 60000 | 0.9697 | 48.0 | 121.0 | 2.6370 | 30.1788 | 82.84 | 10.372 | 28.0 | 33.5 |
| 61875 | 1.0 | 48.0 | 121.0 | 2.6364 | 30.261 | 82.615 | 10.343 | 28.0 | 33.75 |
# Resource Usage Comparison
- VRAM Use: 7.7831 GB
`# Distillation (Teacher -> Student) Architecture Difference:
- **Architecture**: `GPT2LMHeadModel` -> `GPT2LMHeadModel`
- **Total Parameters**: 124,439,808 -> 124,439,808
- **Data Type (dtype)**: 124439808 -> torch.bfloat16
- **Model Size**: 0.24 GB -> 0.24 GB
Module Diff Details
```diff
```
# Train Dataset
Trained on 145,702,102 tokens from the [wikimedia/wikipedia](https://huggingface.co/datasets/wikimedia/wikipedia) dataset.
- Num Samples: `247,500`
- Subset: `20231101.en`
- Split: `train`
# Training Objective
```
DistillationObjective(logits_loss_component=LossComponent(label=logits, weight=1, loss_fn=kl), attn_loss_component=LossComponent(label=attn, weight=5, loss_fn=cos, layer_mapper=layer-2))
```
# Hyperparameters
The following hyperparameters were used during training:
Expand
- learning_rate: `0.0001`
- train_batch_size: `4`
- eval_batch_size: `8`
- seed: `42`
- optimizer: `Adam with betas=(0.9,0.999) and epsilon=1e-08`
- lr_scheduler_type: `linear`
- lr_scheduler_warmup_ratio: `0.5`
- num_epochs: `1.0`
- distillation_objective: `DistillationObjective(logits_loss_component=LossComponent(label=logits, weight=1, loss_fn=kl), attn_loss_component=LossComponent(label=attn, weight=5, loss_fn=cos, layer_mapper=layer-2))`
- train_embeddings: `True`
- lr_scheduler: ``
- student_model_name_or_path: `None`
- student_config_name_or_path: `None`
- student_model_config: `None`
- reinitialize_weights: `None`
- copy_teacher_modules: `[('lm_head', False)]`
- student_model_as_bitnet: `True`
- student_model_compile: `False`
- dropout: `None`
- teacher_model_name_or_path: `gpt2`
- teacher_load_in_8bit: `False`
- teacher_load_in_4bit: `False`
- teacher_model_compile: `False`
- dataset_uri: `wikimedia/wikipedia`
- dataset_subset: `20231101.en`
- dataset_split: `train`
- dataset_column_name: `text`
- dataset_sample_size: `250000`
- dataset_test_size: `0.01`
- gradient_accumulation_steps: `1`
- weight_decay: `0.0`
- max_grad_norm: `1.0`
- warmup_ratio: `0.5`
- warmup_steps: `0`
- gradient_checkpointing: `True`
# Framework Versions
- Distily 0.2.0
- Transformers 4.44.0
- Pytorch 2.3.0
- Datasets 2.21.0