Model Card for Model ID
This modelcard aims to be a base template for new models. It has been generated using this raw template.
Model Details
This model recreates the GPT architecture scaled down just to 10.8M parameters. This Model is build entirely from Scratch.
Model Description
- Developed by: [Deepmalya Koley]
- Funded by [optional]: [More Information Needed]
- Inspired by [optional]: [Andrej Karpathy]
- Model type: [Transformer]
- Language(s) (NLP): [Decoder only]
- License: [MIT]
- Evolved from model [optional]: [BigramLanguageModel]
Model Sources [optional]
Uses
The Model replicates the exact same Decoder only Transformer architecture used in GPT. However this model is trained over 5000 epochs with Parallely processed batches of 328 vectors to predict the next token in the subsequent timestep
Bias, Risks, and Limitations
[The Model is a scaled down version of actual GPT architecture build entirely from scratch. It has only 10.8M params unlike GPT with Billions. The model doesnot incorporate autoregressive processings ]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
Training Details
Training Data
[More Information Needed]
Training Procedure
Preprocessing [optional]
[More Information Needed]
Training Hyperparameters
- Training regime: [More Information Needed]
- batch_size = 64 # how many independent sequences will we process in parallel?
- block_size = 256 # what is the maximum context length for predictions?
- max_iters = 5000
- eval_interval = 500
- learning_rate = 3e-4
- device = 'cuda' if torch.cuda.is_available() else 'cpu'
- eval_iters = 200
- n_embed=384
- n_head=6 # therefore every head (head_size)= 384//6 = 64 dim
- dropout=0.2
Evaluation
- step 0: train loss 4.3585, val loss 4.3557
- step 500: train loss 2.0170, val loss 2.0917
- step 1000: train loss 1.6125, val loss 1.7842
- step 1500: train loss 1.4475, val loss 1.6449
- step 2000: train loss 1.3575, val loss 1.5784
- step 2500: train loss 1.2872, val loss 1.5347
- step 3000: train loss 1.2367, val loss 1.5039
- step 3500: train loss 1.1909, val loss 1.4929
- step 4000: train loss 1.1529, val loss 1.4847
- step 4500: train loss 1.1201, val loss 1.4798
Overview & Purpose
To prevent overfitting on the 1.1M character TinyShakespeare dataset, Dropout (0.2) is injected into:
- Attention softmax weights (dropping attention edges).
- Multi-Head projection layer outputs.
- FeedForward Network layer outputs.
Complete System Architecture Summary
====================================================================================================
Layer / Submodule Input Shape Output Shape Parameters
====================================================================================================
Token Embedding Table (B, T) (B, T, 384) 65 x 384 = 24,960
Positional Embedding Table (T,) (T, 384) 256 x 384 = 98,304
----------------------------------------------------------------------------------------------------
Block 1..6 (x6 Stacked):
βββ LayerNorm 1 (B, T, 384) (B, T, 384) 2 x 384 = 768
βββ Multi-Head Attention:
β βββ Key Linear (B, T, 384) (B, T, 384) 384 x 384 = 147,456
β βββ Query Linear (B, T, 384) (B, T, 384) 384 x 384 = 147,456
β βββ Value Linear (B, T, 384) (B, T, 384) 384 x 384 = 147,456
β βββ Out Projection (B, T, 384) (B, T, 384) 384 x 384 + 384 = 147,840
βββ LayerNorm 2 (B, T, 384) (B, T, 384) 2 x 384 = 768
βββ FeedForward Net:
βββ FC 1 (Expand) (B, T, 384) (B, T, 1536) 384 x 1536 + 1536 = 591,360
βββ FC 2 (Contract) (B, T, 1536) (B, T, 384) 1536 x 384 + 384 = 590,208
----------------------------------------------------------------------------------------------------
Final LayerNorm (B, T, 384) (B, T, 384) 2 x 384 = 768
Language Model Head (B, T, 384) (B, T, 65) 384 x 65 + 65 = 25,025
====================================================================================================
Total Parameters: ~10,788,929 (~10.8 Million)
====================================================================================================