Compare commits

...

6 Commits

Author SHA1 Message Date
askerlee
e0ea752d4b
Merge 8cfa0451f4 into dc54a1a307 2026-05-11 11:19:19 +08:00
Andrej Karpathy
dc54a1a307 tried and failed at DyT 2026-05-05 03:17:21 +00:00
askerlee
8cfa0451f4 When eval language_modeling tasks, be case insensitive to answers 2026-01-14 15:47:36 +08:00
askerlee
e64aa82620 When evaluating language_modeling tasks, be case-insensitive when matching with the correct answer 2026-01-14 15:34:40 +08:00
askerlee
bf067e2a66 Add max_seq_len argument for gpt2 2026-01-14 14:19:20 +08:00
askerlee
d6829284c4 Allow local install and model loading 2026-01-13 22:20:22 +08:00
3 changed files with 21 additions and 1 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ eval_bundle/
# Local setup
CLAUDE.md
wandb/
*.egg-info/

View File

@ -4,6 +4,18 @@ A running summary documenting some experiments and findings. Started ~Jan 7 2026
---
## 2026-05-05: DyT for d12 pretraining (negative)
Tried replacing normalization with [DyT](https://arxiv.org/abs/2503.10622) for d12-scale pretraining following some [hype](https://x.com/LodestoneRock/status/2050367217087512953) on X.
- DyT uses `gamma * tanh(alpha * x) + beta` with learnable scalar `alpha` and per-channel `gamma`/`beta`.
- Added separate alpha initializers for attention vs other normalization sites, following the paper's width-dependent heuristic unless overridden.
- Added optional embedding DyT plus the LLM-specific `sqrt(d_model)` embedding scale from the paper.
Every variation of the idea that was attempted, including after a bunch of parameter tuning did not outperform the baseline d12 model on master, even with steps on the x-axis. In addition, the throughput (tokens per second) was ~10% lower.
---
## 2026-03-24: Parameter-Golf Ideas Sweep (Negative)
Reviewed `openai/parameter-golf` for small/simple ideas that might transfer to nanochat pretraining without bloating the codebase. Cached notes are in `knowledge/parameter_golf.md`.

View File

@ -201,6 +201,9 @@ def evaluate_example(idx, model, tokenizer, data, device, task_meta):
for t, s, e in zip(tokens, start_idxs, end_idxs):
if len(t) > max_tokens:
num_to_crop = len(t) - max_tokens
# Take the last max_tokens tokens instead of the first ones.
# The overly long questions are usually the few-shot contexts. They are placed
# at the beginning of the sequence, so cropping from the start should be ok.
new_tokens.append(t[-max_tokens:]) # take the last max_tokens tokens
new_start_idxs.append(s - num_to_crop) # shift the indices down
new_end_idxs.append(e - num_to_crop)
@ -228,7 +231,11 @@ def evaluate_example(idx, model, tokenizer, data, device, task_meta):
# predictions[i] predict input_ids[i+1] autoregressively
predicted_tokens = predictions[0, si-1:ei-1]
actual_tokens = input_ids[0, si:ei]
is_correct = torch.all(predicted_tokens == actual_tokens).item()
# Make the matching case-insensitive for LM tasks
predicted_text = tokenizer.decode(predicted_tokens.cpu().tolist()).lower()
actual_text = tokenizer.decode(actual_tokens.cpu().tolist()).lower()
# is_correct = torch.all(predicted_tokens == actual_tokens).item()
is_correct = (predicted_text == actual_text)
elif task_type in ['multiple_choice', 'schema']:
# For MC/schema: find the option with lowest average loss
mean_losses = [losses[i, si-1:ei-1].mean().item()