singhpratech commited on
Commit
ccbf889
·
verified ·
1 Parent(s): ce69b53

Add RESULTS.md

Browse files
Files changed (1) hide show
  1. RESULTS.md +72 -0
RESULTS.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Lesson 05 results: instruction tuning from scratch
2
+
3
+ Run: 2026-10-11, `lesson_05.ipynb` executed end to end with papermill (kernel `tiny-storyteller`).
4
+ Device: Apple M4 Max, PyTorch 2.14.1, MPS, GPU shared with other jobs. Not run on Colab tonight
5
+ (T4 time not measured). Wall-clock, whole notebook: **102.1 s** (final run; an earlier run without
6
+ the familiar-request contrast took 69.4 s and gave the same check numbers).
7
+
8
+ ## Setup
9
+ - Start: `tiny-storyteller-v2` downloaded from the Hub repo `singhpratech/emc2-lesson-04-fine-tune`
10
+ (the final Lesson 04 run), 5,853,184 parameters, vocab 4,096.
11
+ - Special tokens added: `<|instruction|>` (id 4096), `<|story|>` (id 4097). Embedding (and the tied output
12
+ head) resized 4,096 -> 4,098 rows; old rows copied, new rows = mean of old rows. 5,853,696 parameters after.
13
+ - Chat template: `<|endoftext|><|instruction|>{instruction}<|story|>{story}<|endoftext|>`.
14
+ - Prompt masking: labels -100 for every position whose target is a prompt token; padding also -100.
15
+ - Pairs (4,000 training):
16
+ - 2,000 TinyStories-Instruct pairs from `TinyStories-Instruct-valid.txt` (public dataset
17
+ `roneneldan/TinyStoriesInstruct`, 26.9 MB; not found as separate files inside `roneneldan/TinyStories`,
18
+ only inside its 1.6 GB tarball). 25,027 records; pairs with Summary + Story that fit in 256 tokens, in file
19
+ order; first 2,000 train, next 100 held out. Instruction = "Write a story about this: {Summary}" +
20
+ " Use the words a, b and c." when Words is present.
21
+ - 2,000 generator pairs: 1,000 Momo + 1,000 Zuri (`generator_pairs(1000, seed=5)`), instruction
22
+ "Write a story about {name} {scene gist} {setting}." (setting omitted if the story names no place).
23
+ - Held-out test: 50 instructions (25 Momo, 25 Zuri, seed 123), each a (character, scene, setting)
24
+ combination that appears in no training story (training stories of that character and scene containing
25
+ the held-out place anywhere were excluded). Every test instruction names a place.
26
+ - Familiar contrast (not the check): 50 instructions (seed 456) whose combination does occur in training;
27
+ stories are new, wording may match a training instruction.
28
+ - Cross-world stretch (not the check): 20 instructions putting each character in the other's places.
29
+ - Held-out loss set: 150 pairs (100 held-out TinyStories-Instruct + the 50 test pairs with reference stories).
30
+ - Training: 500 steps, batch 32 pairs (padded), AdamW lr 3e-4 (warm-up 30, cosine to 10%), wd 0.1, clip 1.0, seed 42.
31
+ - Generation for the check: temperature 0.8, top-k 40, max 200 new tokens, seed = instruction index.
32
+ Before tuning: v2 gets `<|endoftext|>` + instruction as plain text (it has no special tokens).
33
+
34
+ ## Leakage check (executed, cell asserts)
35
+ test stories in training 0; test instructions in training 0; training stories showing a held-out
36
+ combination 0; Lesson 04 quiz stories (100 Momo + 100 Zuri, rebuilt with the same seeds) in training 0;
37
+ TinyStories-Instruct held-out stories in training 0. Familiar-set stories in training: 0 (assert).
38
+
39
+ ## THE CHECK (string match: character name AND exact place phrase, case-insensitive for the place)
40
+ | 50 held-out instructions | both | character | setting |
41
+ |---|---|---|---|
42
+ | before (v2, plain prompt) | 12% (6/50) | 68% | 14% |
43
+ | after (tiny-storyteller-instruct, template) | **44% (22/50)** | 100% | 44% |
44
+
45
+ After, by character: Momo 9/25, Zuri 13/25.
46
+
47
+ Contrast sets:
48
+ - Familiar combinations: before 8% both (character 82%, setting 8%); after **86%** both (43/50; character 100%).
49
+ - Cross-world, after: 5% both (1/20; character 100%, setting 5%).
50
+
51
+ Held-out masked loss: 2.540 before (v2 + two new rows) -> 2.145 after.
52
+ Training time: 37.4 s for 500 steps = 75 ms per step (first run: 36 s, 72 ms/step).
53
+
54
+ ## Observations (from the executed notebook)
55
+ - Typical held-out failure: right character and scene, practised place instead of the requested one
56
+ ("Momo hiding from the rain near the little pond" -> Momo hid "in the tall grass").
57
+ - TinyStories-Instruct sample ("A little dog finds a lost ball in the park and gives it back to a girl."): kept the
58
+ park and the ball, the dog never appears.
59
+ - Before tuning, v2 given a Momo request wrote about Zuri ("Words can hurt, Zuri") - the Lesson 04 bleed.
60
+ - Generator stories are still recited template sentences.
61
+
62
+ ## Artifacts
63
+ - `tiny-storyteller-instruct/`: model.pt, config.json (vocab 4098), tokenizer.json, tokenizer_config.json, chat_template.json. 23 MB.
64
+ - `pairs/`: train.jsonl (4,000), heldout.jsonl (150), test50.jsonl, familiar50.jsonl, crossworld20.jsonl. 3.1 MB.
65
+ TinyStories-Instruct rows are derived from a CDLA-Sharing-1.0 dataset.
66
+ - `story_pairs.py`: the pair generator. `results.json`: all numbers and every generated test story.
67
+ - Masking widget checked in headless Chromium at 700 px: no console errors, no horizontal scroll.
68
+
69
+ ## What went wrong / limits
70
+ - The TinyStories-Instruct files are not separate files in `roneneldan/TinyStories`; used the authors'
71
+ `roneneldan/TinyStoriesInstruct` validation file instead (fast download).
72
+ - One sample per instruction (seed fixed); 50 instructions is a small set, so each point is 2 percentage points.