shreyask commited on
Commit
00da4c8
·
verified ·
1 Parent(s): 62f1757

GPT from scratch — 1800 steps, ppl=195.7

Browse files
Files changed (5) hide show
  1. README.md +59 -0
  2. config.json +22 -0
  3. pytorch_model.bin +3 -0
  4. tokenizer.json +0 -0
  5. tokenizer_config.json +8 -0
README.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ tags:
6
+ - causal-lm
7
+ - gpt
8
+ - from-scratch
9
+ - fineweb
10
+ - pytorch
11
+ ---
12
+
13
+ # FineWeb GPT — trained from scratch
14
+
15
+ A GPT-style language model trained completely from scratch as a learning exercise.
16
+ Every component was written from scratch: BPE tokenizer, transformer architecture,
17
+ and training loop.
18
+
19
+ ## Architecture
20
+
21
+ | | |
22
+ |---|---|
23
+ | Parameters | 8.4M |
24
+ | Layers | 6 |
25
+ | d_model | 256 |
26
+ | Attention heads | 8 |
27
+ | Context length | 512 |
28
+ | Vocabulary | 8,192 (BPE ByteLevel) |
29
+ | Positional encoding | RoPE |
30
+ | Normalization | RMSNorm |
31
+ | Activation | SwiGLU |
32
+
33
+ ## Training
34
+
35
+ | | |
36
+ |---|---|
37
+ | Dataset | FineWeb-Edu sample-10BT (~5M tokens) |
38
+ | Steps | 1,800 |
39
+ | Optimizer | AdamW, cosine LR + warmup |
40
+ | Val loss | 5.2764 |
41
+ | Perplexity | 195.7 |
42
+ | Hardware | Apple Silicon MPS |
43
+
44
+ ## Load the tokenizer
45
+
46
+ ```python
47
+ from transformers import PreTrainedTokenizerFast
48
+ tokenizer = PreTrainedTokenizerFast.from_pretrained("REPO_ID")
49
+ print(tokenizer("The study of mathematics").tokens())
50
+ ```
51
+
52
+ ## Limitations
53
+
54
+ Learning exercise only — trained on ~5M tokens, perplexity 196.
55
+ Outputs are repetitive and often incoherent.
56
+
57
+ ## Stack
58
+
59
+ PyTorch · HuggingFace datasets · tokenizers · wandb · huggingface_hub
config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "fineweb-gpt",
3
+ "architectures": [
4
+ "GPTForCausalLM"
5
+ ],
6
+ "bos_token_id": 0,
7
+ "eos_token_id": 0,
8
+ "pad_token_id": 1,
9
+ "vocab_size": 8192,
10
+ "context_len": 512,
11
+ "n_layers": 6,
12
+ "d_model": 256,
13
+ "n_heads": 8,
14
+ "d_ff": 1024,
15
+ "dropout": 0.1,
16
+ "tie_embeddings": true,
17
+ "trained_steps": 1800,
18
+ "val_loss": 5.2764,
19
+ "perplexity": 195.7,
20
+ "training_tokens": "~5M",
21
+ "dataset": "HuggingFaceFW/fineweb-edu (sample-10BT, 10k docs)"
22
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6639466bda7219a3a74354e8b42031a7cfae53a56c6804224765a3d0a64e4818
3
+ size 35556865
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "PreTrainedTokenizerFast",
3
+ "bos_token": "<|endoftext|>",
4
+ "eos_token": "<|endoftext|>",
5
+ "pad_token": "<|pad|>",
6
+ "unk_token": "<|unk|>",
7
+ "model_max_length": 512
8
+ }