Update README.md
Browse files
README.md
CHANGED
|
@@ -42,8 +42,6 @@ This model recreates the GPT architecture scaled down just to 10.8M parameters.
|
|
| 42 |
<!-- Provide the basic links for the model. -->
|
| 43 |
|
| 44 |
- **Repository:** [(https://github.com/Deepmalya2506/From-Kernel-to-Silicon---Transformers)]
|
| 45 |
-
- **Paper [optional]:** [More Information Needed]
|
| 46 |
-
- **Demo [optional]:** [More Information Needed]
|
| 47 |
|
| 48 |
## Uses
|
| 49 |
|
|
@@ -88,107 +86,64 @@ Use the code below to get started with the model.
|
|
| 88 |
#### Training Hyperparameters
|
| 89 |
|
| 90 |
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
#### Speeds, Sizes, Times [optional]
|
| 93 |
-
|
| 94 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 95 |
-
|
| 96 |
-
[More Information Needed]
|
| 97 |
|
| 98 |
## Evaluation
|
| 99 |
|
| 100 |
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 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 |
-
## Technical Specifications [optional]
|
| 149 |
-
|
| 150 |
-
### Model Architecture and Objective
|
| 151 |
-
|
| 152 |
-
[More Information Needed]
|
| 153 |
-
|
| 154 |
-
### Compute Infrastructure
|
| 155 |
-
|
| 156 |
-
[More Information Needed]
|
| 157 |
-
|
| 158 |
-
#### Hardware
|
| 159 |
-
|
| 160 |
-
[More Information Needed]
|
| 161 |
-
|
| 162 |
-
#### Software
|
| 163 |
-
|
| 164 |
-
[More Information Needed]
|
| 165 |
-
|
| 166 |
-
## Citation [optional]
|
| 167 |
-
|
| 168 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 169 |
-
|
| 170 |
-
**BibTeX:**
|
| 171 |
-
|
| 172 |
-
[More Information Needed]
|
| 173 |
-
|
| 174 |
-
**APA:**
|
| 175 |
-
|
| 176 |
-
[More Information Needed]
|
| 177 |
-
|
| 178 |
-
## Glossary [optional]
|
| 179 |
-
|
| 180 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 181 |
-
|
| 182 |
-
[More Information Needed]
|
| 183 |
-
|
| 184 |
-
## More Information [optional]
|
| 185 |
-
|
| 186 |
-
[More Information Needed]
|
| 187 |
-
|
| 188 |
-
## Model Card Authors [optional]
|
| 189 |
-
|
| 190 |
-
[More Information Needed]
|
| 191 |
-
|
| 192 |
-
## Model Card Contact
|
| 193 |
-
|
| 194 |
-
[More Information Needed]
|
|
|
|
| 42 |
<!-- Provide the basic links for the model. -->
|
| 43 |
|
| 44 |
- **Repository:** [(https://github.com/Deepmalya2506/From-Kernel-to-Silicon---Transformers)]
|
|
|
|
|
|
|
| 45 |
|
| 46 |
## Uses
|
| 47 |
|
|
|
|
| 86 |
#### Training Hyperparameters
|
| 87 |
|
| 88 |
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 89 |
+
- batch_size = 64 # how many independent sequences will we process in parallel?
|
| 90 |
+
- block_size = 256 # what is the maximum context length for predictions?
|
| 91 |
+
- max_iters = 5000
|
| 92 |
+
- eval_interval = 500
|
| 93 |
+
- learning_rate = 3e-4
|
| 94 |
+
- device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 95 |
+
- eval_iters = 200
|
| 96 |
+
- n_embed=384
|
| 97 |
+
- n_head=6 # therefore every head (head_size)= 384//6 = 64 dim
|
| 98 |
+
- dropout=0.2
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
## Evaluation
|
| 102 |
|
| 103 |
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 104 |
|
| 105 |
+
* step 0: train loss 4.3585, val loss 4.3557
|
| 106 |
+
* step 500: train loss 2.0170, val loss 2.0917
|
| 107 |
+
* step 1000: train loss 1.6125, val loss 1.7842
|
| 108 |
+
* step 1500: train loss 1.4475, val loss 1.6449
|
| 109 |
+
* step 2000: train loss 1.3575, val loss 1.5784
|
| 110 |
+
* step 2500: train loss 1.2872, val loss 1.5347
|
| 111 |
+
* step 3000: train loss 1.2367, val loss 1.5039
|
| 112 |
+
* step 3500: train loss 1.1909, val loss 1.4929
|
| 113 |
+
* step 4000: train loss 1.1529, val loss 1.4847
|
| 114 |
+
* step 4500: train loss 1.1201, val loss 1.4798
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
#### Overview & Purpose
|
| 118 |
+
To prevent overfitting on the 1.1M character TinyShakespeare dataset, **Dropout (0.2)** is injected into:
|
| 119 |
+
1. Attention softmax weights (dropping attention edges).
|
| 120 |
+
2. Multi-Head projection layer outputs.
|
| 121 |
+
3. FeedForward Network layer outputs.
|
| 122 |
+
|
| 123 |
+
#### Complete System Architecture Summary
|
| 124 |
+
|
| 125 |
+
```
|
| 126 |
+
====================================================================================================
|
| 127 |
+
Layer / Submodule Input Shape Output Shape Parameters
|
| 128 |
+
====================================================================================================
|
| 129 |
+
Token Embedding Table (B, T) (B, T, 384) 65 x 384 = 24,960
|
| 130 |
+
Positional Embedding Table (T,) (T, 384) 256 x 384 = 98,304
|
| 131 |
+
----------------------------------------------------------------------------------------------------
|
| 132 |
+
Block 1..6 (x6 Stacked):
|
| 133 |
+
βββ LayerNorm 1 (B, T, 384) (B, T, 384) 2 x 384 = 768
|
| 134 |
+
βββ Multi-Head Attention:
|
| 135 |
+
β βββ Key Linear (B, T, 384) (B, T, 384) 384 x 384 = 147,456
|
| 136 |
+
β βββ Query Linear (B, T, 384) (B, T, 384) 384 x 384 = 147,456
|
| 137 |
+
β βββ Value Linear (B, T, 384) (B, T, 384) 384 x 384 = 147,456
|
| 138 |
+
β βββ Out Projection (B, T, 384) (B, T, 384) 384 x 384 + 384 = 147,840
|
| 139 |
+
βββ LayerNorm 2 (B, T, 384) (B, T, 384) 2 x 384 = 768
|
| 140 |
+
βββ FeedForward Net:
|
| 141 |
+
βββ FC 1 (Expand) (B, T, 384) (B, T, 1536) 384 x 1536 + 1536 = 591,360
|
| 142 |
+
βββ FC 2 (Contract) (B, T, 1536) (B, T, 384) 1536 x 384 + 384 = 590,208
|
| 143 |
+
----------------------------------------------------------------------------------------------------
|
| 144 |
+
Final LayerNorm (B, T, 384) (B, T, 384) 2 x 384 = 768
|
| 145 |
+
Language Model Head (B, T, 384) (B, T, 65) 384 x 65 + 65 = 25,025
|
| 146 |
+
====================================================================================================
|
| 147 |
+
Total Parameters: ~10,788,929 (~10.8 Million)
|
| 148 |
+
====================================================================================================
|
| 149 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|