mirror of
https://github.com/karpathy/nanochat.git
synced 2026-07-08 13:59:13 +00:00
Compare commits
6 Commits
db504bae94
...
e0ea752d4b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0ea752d4b | ||
|
|
dc54a1a307 | ||
|
|
8cfa0451f4 | ||
|
|
e64aa82620 | ||
|
|
bf067e2a66 | ||
|
|
d6829284c4 |
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -11,3 +11,4 @@ eval_bundle/
|
|||
# Local setup
|
||||
CLAUDE.md
|
||||
wandb/
|
||||
*.egg-info/
|
||||
|
|
|
|||
12
dev/LOG.md
12
dev/LOG.md
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user