anath2 commited on
Commit
c467ee0
·
verified ·
1 Parent(s): 026c9a3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -39
README.md CHANGED
@@ -9,23 +9,13 @@ tags:
9
  - tinystories
10
  - positional-embeddings
11
  - nope
12
- - arena
13
  ---
14
 
15
  # TinyStories toy transformer: learned vs no positional embeddings
16
 
17
- Checkpoints from a small experiment comparing positional-embedding schemes on a
18
- 4-layer GPT-2-style transformer trained on [TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories),
19
- built from the [ARENA](https://github.com/callummcdougall/ARENA_3.0) transformer-from-scratch exercises.
20
-
21
  Two variants, identical except for the positional embedding:
22
-
23
- - **`learned`** — standard learned absolute positional embeddings (`W_pos`, shape `n_ctx × d_model`).
24
- - **`none`** — no positional embedding at all (NoPE). The model can only recover position
25
- implicitly through the causal attention mask.
26
-
27
- Both variants share the same seed, so every non-positional parameter starts from identical values
28
- and the data order is the same.
29
 
30
  ## Model
31
 
@@ -50,11 +40,6 @@ i.e. fresh data — no repeats). Test loss is mean next-token cross-entropy on a
50
  | `learned.pt` | 40 | 20k | 80M | **2.779** |
51
  | `none.pt` | 40 | 20k | 80M | **2.808** |
52
 
53
- The learned–none gap peaks early (~0.09 nats around 2k steps) and then narrows as the NoPE model
54
- learns to extract position from the causal mask, settling at ~0.03 nats by 20k steps, where both
55
- curves have nearly flattened. Consistent with
56
- [Haviv et al. 2022](https://arxiv.org/abs/2203.16634): causal LMs without positional encodings still
57
- learn positional information, at a small cost.
58
 
59
  ## Checkpoint format
60
 
@@ -67,25 +52,4 @@ Each `.pt` is a plain dict, loadable with `weights_only=True`:
67
  "args": {...}, # training args (epochs, lr, seed, ...)
68
  "test_loss": float, # final held-out loss
69
  }
70
- ```
71
-
72
- ## Loading
73
-
74
- The model classes live in the ARENA fork's
75
- [`pos_embed_experiment.py`](https://github.com/anath2/ARENA_3.0/blob/main/chapter1_transformer_interp/exercises/part1_transformer_from_scratch/pos_embed_experiment.py):
76
-
77
- ```python
78
- from huggingface_hub import hf_hub_download
79
- from part1_transformer_from_scratch.pos_embed_experiment import load_model
80
- from part1_transformer_from_scratch.sampler import TransformerSampler
81
- from transformers import GPT2TokenizerFast
82
-
83
- path = hf_hub_download("anath2/tinystories-pos-embed", "none.pt")
84
- model = load_model(path)
85
-
86
- tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
87
- print(TransformerSampler(model, tokenizer).sample("Once upon a time", max_tokens_generated=100))
88
- ```
89
-
90
- Training data was tokenized with the GPT-2 tokenizer and each story prefixed with `<|endoftext|>`
91
- as a BOS token, so prompts beginning with that token are closest to the training distribution.
 
9
  - tinystories
10
  - positional-embeddings
11
  - nope
 
12
  ---
13
 
14
  # TinyStories toy transformer: learned vs no positional embeddings
15
 
 
 
 
 
16
  Two variants, identical except for the positional embedding:
17
+ - **`learned`**
18
+ - **`none`**
 
 
 
 
 
19
 
20
  ## Model
21
 
 
40
  | `learned.pt` | 40 | 20k | 80M | **2.779** |
41
  | `none.pt` | 40 | 20k | 80M | **2.808** |
42
 
 
 
 
 
 
43
 
44
  ## Checkpoint format
45
 
 
52
  "args": {...}, # training args (epochs, lr, seed, ...)
53
  "test_loss": float, # final held-out loss
54
  }
55
+ ```