Goldenwert commited on
Commit
4684d35
·
verified ·
1 Parent(s): 3572b34

Upload Multi-Token Prediction GPT-2 model

Browse files
README.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ library_name: transformers
5
+ tags:
6
+ - multi-token-prediction
7
+ - gpt2
8
+ - mathematics
9
+ - MetaMathQA
10
+ - transformer
11
+ - speculative-decoding
12
+ pipeline_tag: text-generation
13
+ base_model: gpt2
14
+ ---
15
+
16
+ # Multi-Token Prediction GPT-2 Model
17
+
18
+ This is a GPT-2 model enhanced with **Multi-Token Prediction (MTP)** architecture, trained on the MetaMathQA dataset for mathematical reasoning tasks.
19
+
20
+ ## Model Description
21
+
22
+ This model implements the Multi-Token Prediction approach from the paper "Better & Faster Large Language Models via Multi-token Prediction" by Meta AI. Key features:
23
+
24
+ - **Shared Trunk Architecture**: Uses 9 shared transformer layers with 4 prediction heads
25
+ - **Multi-Token Prediction**: Predicts 4 tokens simultaneously (t+1, t+2, t+3, t+4)
26
+ - **Enhanced Speculative Decoding**: Achieves up to 3x inference speedup
27
+ - **Mathematical Reasoning**: Fine-tuned specifically for mathematical problem solving
28
+
29
+ ## Architecture Details
30
+
31
+ - **Base Model**: GPT-2 (124M parameters)
32
+ - **Trunk Layers**: 9 (shared processing)
33
+ - **Prediction Heads**: 4 parallel heads
34
+ - **Training Data**: MetaMathQA dataset (500 samples)
35
+ - **Training Epochs**: 1 with gradient accumulation
36
+
37
+ ## Usage
38
+
39
+ ```python
40
+ import torch
41
+ from transformers import GPT2Tokenizer
42
+ # Note: You'll need the custom MultiTokenGPT2 class from the training code
43
+
44
+ tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
45
+ tokenizer.pad_token = tokenizer.eos_token
46
+
47
+ # Load your model (custom loading required)
48
+ # model = MultiTokenGPT2.from_pretrained("Goldenwert/multitoken-gpt2-metamathqa")
49
+
50
+ prompt = "What is the derivative of f(x) = x^3?"
51
+ input_ids = tokenizer.encode(prompt, return_tensors="pt")
52
+
53
+ # Standard generation
54
+ generated = model.generate(
55
+ input_ids,
56
+ max_new_tokens=50,
57
+ use_speculative=False
58
+ )
59
+
60
+ # Fast speculative generation
61
+ generated_fast = model.generate(
62
+ input_ids,
63
+ max_new_tokens=50,
64
+ use_speculative=True
65
+ )
66
+
67
+ print(tokenizer.decode(generated[0], skip_special_tokens=True))
68
+ ```
69
+
70
+ ## Performance
71
+
72
+ - **Inference Speed**: Up to 3x faster with speculative decoding
73
+ - **Memory Efficiency**: Gradient checkpointing support
74
+ - **Mathematical Tasks**: Improved reasoning on math problems
75
+
76
+ ## Training Details
77
+
78
+ - **Dataset**: MetaMathQA (mathematical reasoning)
79
+ - **Optimizer**: AdamW with warmup
80
+ - **Learning Rate**: 5e-5
81
+ - **Batch Size**: 4 (effective 32 with gradient accumulation)
82
+ - **Hardware**: GPU with FP16 precision
83
+
84
+ ## Research Context
85
+
86
+ Based on the paper "Better & Faster Large Language Models via Multi-token Prediction" which demonstrates that predicting multiple tokens simultaneously can improve both training efficiency and inference speed.
87
+
88
+ ## Files
89
+
90
+ - `pytorch_model.bin`: Model weights
91
+ - `config.json`: Model configuration
92
+ - Additional training artifacts
93
+
94
+ ## License
95
+
96
+ Apache 2.0 (following GPT-2 base model)
checkpoint-11110/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-11110/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c80bae54059dc062c6252892a9753c0833081fa2bba482a80753ae2517c3134b
3
+ size 1052355322
checkpoint-11110/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd0a751af18be5499e755deec78668429a11049674ad4462213470816df7bbf9
3
+ size 526171530
checkpoint-11110/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40fc25e8ba1bd308447587d2888737af7602efd0bad1a094cfc837d565cbdafa
3
+ size 14244
checkpoint-11110/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c13eaf49e2347ca3e373d8fa1ac3b0078f46477102d5bac9947d4e1d1f45a43e
3
+ size 1064
checkpoint-11110/special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "pad_token": "<|endoftext|>",
5
+ "unk_token": "<|endoftext|>"
6
+ }
checkpoint-11110/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-11110/tokenizer_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "50256": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ }
12
+ },
13
+ "bos_token": "<|endoftext|>",
14
+ "clean_up_tokenization_spaces": false,
15
+ "eos_token": "<|endoftext|>",
16
+ "extra_special_tokens": {},
17
+ "model_max_length": 1024,
18
+ "pad_token": "<|endoftext|>",
19
+ "tokenizer_class": "GPT2Tokenizer",
20
+ "unk_token": "<|endoftext|>"
21
+ }
checkpoint-11110/trainer_state.json ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 1.0,
6
+ "eval_steps": 500,
7
+ "global_step": 11110,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.0450070323488045,
14
+ "grad_norm": 1.5042104721069336,
15
+ "learning_rate": 4.7754275427542756e-05,
16
+ "loss": 2.0652,
17
+ "step": 500
18
+ },
19
+ {
20
+ "epoch": 0.090014064697609,
21
+ "grad_norm": 1.1722426414489746,
22
+ "learning_rate": 4.55040504050405e-05,
23
+ "loss": 1.5388,
24
+ "step": 1000
25
+ },
26
+ {
27
+ "epoch": 0.1350210970464135,
28
+ "grad_norm": 1.0186536312103271,
29
+ "learning_rate": 4.325382538253826e-05,
30
+ "loss": 1.3771,
31
+ "step": 1500
32
+ },
33
+ {
34
+ "epoch": 0.180028129395218,
35
+ "grad_norm": 0.9214487075805664,
36
+ "learning_rate": 4.1003600360036004e-05,
37
+ "loss": 1.2963,
38
+ "step": 2000
39
+ },
40
+ {
41
+ "epoch": 0.2250351617440225,
42
+ "grad_norm": 0.8969003558158875,
43
+ "learning_rate": 3.875337533753375e-05,
44
+ "loss": 1.2492,
45
+ "step": 2500
46
+ },
47
+ {
48
+ "epoch": 0.270042194092827,
49
+ "grad_norm": 0.8213639259338379,
50
+ "learning_rate": 3.6503150315031505e-05,
51
+ "loss": 1.2009,
52
+ "step": 3000
53
+ },
54
+ {
55
+ "epoch": 0.3150492264416315,
56
+ "grad_norm": 0.8741646409034729,
57
+ "learning_rate": 3.425292529252925e-05,
58
+ "loss": 1.1572,
59
+ "step": 3500
60
+ },
61
+ {
62
+ "epoch": 0.360056258790436,
63
+ "grad_norm": 0.7562123537063599,
64
+ "learning_rate": 3.2002700270027e-05,
65
+ "loss": 1.1338,
66
+ "step": 4000
67
+ },
68
+ {
69
+ "epoch": 0.4050632911392405,
70
+ "grad_norm": 0.8160617351531982,
71
+ "learning_rate": 2.9752475247524754e-05,
72
+ "loss": 1.1104,
73
+ "step": 4500
74
+ },
75
+ {
76
+ "epoch": 0.450070323488045,
77
+ "grad_norm": 0.790651261806488,
78
+ "learning_rate": 2.75022502250225e-05,
79
+ "loss": 1.0986,
80
+ "step": 5000
81
+ },
82
+ {
83
+ "epoch": 0.49507735583684953,
84
+ "grad_norm": 0.667475163936615,
85
+ "learning_rate": 2.525202520252025e-05,
86
+ "loss": 1.0757,
87
+ "step": 5500
88
+ },
89
+ {
90
+ "epoch": 0.540084388185654,
91
+ "grad_norm": 0.7328142523765564,
92
+ "learning_rate": 2.3001800180018002e-05,
93
+ "loss": 1.0592,
94
+ "step": 6000
95
+ },
96
+ {
97
+ "epoch": 0.5850914205344585,
98
+ "grad_norm": 0.6897611618041992,
99
+ "learning_rate": 2.0751575157515752e-05,
100
+ "loss": 1.0475,
101
+ "step": 6500
102
+ },
103
+ {
104
+ "epoch": 0.630098452883263,
105
+ "grad_norm": 0.7082722783088684,
106
+ "learning_rate": 1.85013501350135e-05,
107
+ "loss": 1.0428,
108
+ "step": 7000
109
+ },
110
+ {
111
+ "epoch": 0.6751054852320675,
112
+ "grad_norm": 0.7828446626663208,
113
+ "learning_rate": 1.625112511251125e-05,
114
+ "loss": 1.0318,
115
+ "step": 7500
116
+ },
117
+ {
118
+ "epoch": 0.720112517580872,
119
+ "grad_norm": 0.8432497978210449,
120
+ "learning_rate": 1.4000900090009e-05,
121
+ "loss": 1.024,
122
+ "step": 8000
123
+ },
124
+ {
125
+ "epoch": 0.7651195499296765,
126
+ "grad_norm": 0.7583742737770081,
127
+ "learning_rate": 1.1750675067506751e-05,
128
+ "loss": 1.0168,
129
+ "step": 8500
130
+ },
131
+ {
132
+ "epoch": 0.810126582278481,
133
+ "grad_norm": 0.7724961042404175,
134
+ "learning_rate": 9.500450045004502e-06,
135
+ "loss": 1.0015,
136
+ "step": 9000
137
+ },
138
+ {
139
+ "epoch": 0.8551336146272855,
140
+ "grad_norm": 0.7692517638206482,
141
+ "learning_rate": 7.250225022502251e-06,
142
+ "loss": 1.0006,
143
+ "step": 9500
144
+ },
145
+ {
146
+ "epoch": 0.90014064697609,
147
+ "grad_norm": 0.6760990619659424,
148
+ "learning_rate": 5e-06,
149
+ "loss": 1.0056,
150
+ "step": 10000
151
+ },
152
+ {
153
+ "epoch": 0.9451476793248945,
154
+ "grad_norm": 0.7823421955108643,
155
+ "learning_rate": 2.7497749774977497e-06,
156
+ "loss": 1.0042,
157
+ "step": 10500
158
+ },
159
+ {
160
+ "epoch": 0.9901547116736991,
161
+ "grad_norm": 0.8093355298042297,
162
+ "learning_rate": 4.995499549954995e-07,
163
+ "loss": 0.9944,
164
+ "step": 11000
165
+ }
166
+ ],
167
+ "logging_steps": 500,
168
+ "max_steps": 11110,
169
+ "num_input_tokens_seen": 0,
170
+ "num_train_epochs": 1,
171
+ "save_steps": 99999999,
172
+ "stateful_callbacks": {
173
+ "TrainerControl": {
174
+ "args": {
175
+ "should_epoch_stop": false,
176
+ "should_evaluate": false,
177
+ "should_log": false,
178
+ "should_save": true,
179
+ "should_training_stop": true
180
+ },
181
+ "attributes": {}
182
+ }
183
+ },
184
+ "total_flos": 0.0,
185
+ "train_batch_size": 4,
186
+ "trial_name": null,
187
+ "trial_params": null
188
+ }
checkpoint-11110/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6a677d8267e403ee6e61f8cd7dcd956d32959303d2ab209618047ecbea6b4a5
3
+ size 5240
checkpoint-11110/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-15/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-15/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d76926653442a6cd13969aa536a82701b4d0c00935170e3ec7223339dc329684
3
+ size 1052355322
checkpoint-15/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f88f9624f6492417d1b97ceb06a3d5f2dc764ae6a22865ddd694e73bd538487
3
+ size 526173130
checkpoint-15/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ecc4530a32c803eee1dbb37f345e40c4c7380974a224f6b8e652a052311d9d2
3
+ size 14244
checkpoint-15/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d0facd13ec6092c2b43cce23b0a73463bc00999cd16da7cbf795867dc294419
3
+ size 1064
checkpoint-15/special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "pad_token": "<|endoftext|>",
5
+ "unk_token": "<|endoftext|>"
6
+ }
checkpoint-15/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-15/tokenizer_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "50256": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ }
12
+ },
13
+ "bos_token": "<|endoftext|>",
14
+ "clean_up_tokenization_spaces": false,
15
+ "eos_token": "<|endoftext|>",
16
+ "extra_special_tokens": {},
17
+ "model_max_length": 1024,
18
+ "pad_token": "<|endoftext|>",
19
+ "tokenizer_class": "GPT2Tokenizer",
20
+ "unk_token": "<|endoftext|>"
21
+ }
checkpoint-15/trainer_state.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 1.0,
6
+ "eval_steps": 500,
7
+ "global_step": 15,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [],
12
+ "logging_steps": 500,
13
+ "max_steps": 15,
14
+ "num_input_tokens_seen": 0,
15
+ "num_train_epochs": 1,
16
+ "save_steps": 99999999,
17
+ "stateful_callbacks": {
18
+ "TrainerControl": {
19
+ "args": {
20
+ "should_epoch_stop": false,
21
+ "should_evaluate": false,
22
+ "should_log": false,
23
+ "should_save": true,
24
+ "should_training_stop": true
25
+ },
26
+ "attributes": {}
27
+ }
28
+ },
29
+ "total_flos": 0.0,
30
+ "train_batch_size": 4,
31
+ "trial_name": null,
32
+ "trial_params": null
33
+ }
checkpoint-15/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6a677d8267e403ee6e61f8cd7dcd956d32959303d2ab209618047ecbea6b4a5
3
+ size 5240
checkpoint-15/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPT2LMHeadModel"
5
+ ],
6
+ "attn_pdrop": 0.1,
7
+ "bos_token_id": 50256,
8
+ "embd_pdrop": 0.1,
9
+ "eos_token_id": 50256,
10
+ "initializer_range": 0.02,
11
+ "layer_norm_epsilon": 1e-05,
12
+ "model_type": "gpt2",
13
+ "n_ctx": 1024,
14
+ "n_embd": 768,
15
+ "n_head": 12,
16
+ "n_inner": null,
17
+ "n_layer": 9,
18
+ "n_positions": 1024,
19
+ "reorder_and_upcast_attn": false,
20
+ "resid_pdrop": 0.1,
21
+ "scale_attn_by_inverse_layer_idx": false,
22
+ "scale_attn_weights": true,
23
+ "summary_activation": null,
24
+ "summary_first_dropout": 0.1,
25
+ "summary_proj_to_labels": true,
26
+ "summary_type": "cls_index",
27
+ "summary_use_proj": true,
28
+ "task_specific_params": {
29
+ "text-generation": {
30
+ "do_sample": true,
31
+ "max_length": 50
32
+ }
33
+ },
34
+ "transformers_version": "4.51.3",
35
+ "use_cache": false,
36
+ "vocab_size": 50257
37
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd0a751af18be5499e755deec78668429a11049674ad4462213470816df7bbf9
3
+ size 526171530
special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "pad_token": "<|endoftext|>",
5
+ "unk_token": "<|endoftext|>"
6
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "50256": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ }
12
+ },
13
+ "bos_token": "<|endoftext|>",
14
+ "clean_up_tokenization_spaces": false,
15
+ "eos_token": "<|endoftext|>",
16
+ "extra_special_tokens": {},
17
+ "model_max_length": 1024,
18
+ "pad_token": "<|endoftext|>",
19
+ "tokenizer_class": "GPT2Tokenizer",
20
+ "unk_token": "<|endoftext|>"
21
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6a677d8267e403ee6e61f8cd7dcd956d32959303d2ab209618047ecbea6b4a5
3
+ size 5240
vocab.json ADDED
The diff for this file is too large to render. See raw diff