Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ to 0.109 releases under the wrong numbers; they are yanked.

## Unreleased

- `recipes/papers/context-lm/figures.py`: plain-language titles and subtitles on all five figures.
- `recipes/papers/context-lm/figures.py` adds two figures: right answers by training step, and the untrained vs
trained model's notes on the same held-out log, each line checked against the log's real final values.
- `recipes/papers/context-lm/figures.py`: three figures (what a context LM sees, held-out pass@1, tokens a
Expand Down
8 changes: 4 additions & 4 deletions docs/figures/context-lm-accuracy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/figures/context-lm-before-after.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/figures/context-lm-idea.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/figures/context-lm-learning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/figures/context-lm-tokens.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions recipes/papers/context-lm/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
# labeled, so color is never the only cue.
ARMS = [
("baseline", "Plain GRPO", C["muted"]),
("paper", "+ paper's Eq. 6", C["green"]),
("recipe", "+ Eq. 6, complete files", C["warm"]),
("paper", "Paper's bonus", C["green"]),
("recipe", "Our stricter bonus", C["warm"]),
]
LABEL_W = 176
SEEDS = "17, 18, 19, 20"
Expand Down Expand Up @@ -108,8 +108,8 @@ def idea() -> None:
s = Svg(100 + 150 + 104 + 60)
y0 = title(
s,
"What the model sees before each answer",
"A log in 5 chunks of 8 lines, then: final value of maple? (Illustration.)",
"Normal LLM vs context LM",
"Same log, read in 5 chunks. One piles it all up. One keeps notes.",
)
x0, gap = 24, 8
cw = (W - 48 - gap * (steps - 1)) / steps
Expand All @@ -131,7 +131,7 @@ def idea() -> None:
s.text(x + 8, top + 77, "...", size=11, color="muted", mono=True)
s.text(x + cw / 2, top + 102, f"after chunk {t + 1}", size=12, color="muted",
anchor="middle") # fmt: skip
s.text(24, s.h - 18, "Each chunk is gone after its turn. The model keeps only what it wrote.",
s.text(24, s.h - 18, "Illustration. Once a chunk is read it's gone; only the notes remain.",
size=13, color="body") # fmt: skip
s.save("context-lm-idea.svg")

Expand Down Expand Up @@ -164,8 +164,8 @@ def accuracy() -> None:
s = Svg(100 + 170)
y0 = title(
s,
"Answered right on 200 held-out logs",
f"Qwen2.5-1.5B, 60 steps. Untrained: {base:.2f}. Dots: 4 seeds. Tick: mean.",
"Trained, it gets almost every log right",
f"Untrained: {base:.0%} right. Each dot is one training run; the line is the average.",
)
dot_panel(
s, y0, "score", "per_seed", 0.80, 1.00, [0.8, 0.85, 0.9, 0.95, 1.0], lambda v: f"{v:.2f}"
Expand All @@ -179,14 +179,14 @@ def tokens() -> None:
s = Svg(100 + 170 + 26)
y0 = title(
s,
"Tokens spent per held-out log",
f"Prefix-reuse tokens over 6 steps. Untrained: {base:,}. Dots: 4 seeds.",
"Tokens used per log (lower is cheaper)",
f"Untrained: {base:,}. Each dot is one training run; the line is the average.",
)
dot_panel(s, y0, "cost_tokens", "cost_per_seed", 800, 2200, [800, 1200, 1600, 2000],
lambda v: f"{v:,.0f}") # fmt: skip
d = R["deltas"]["paper"]["cost"]["pooled"]["relative"]
s.text(24, s.h - 18, f"Eq. 6 spends {abs(d):.0%} less than plain GRPO; most of that is one "
"seed whose file bloated.", size=12.5, color="body") # fmt: skip
s.text(24, s.h - 18, f"The paper's bonus uses {abs(d):.0%} fewer tokens, mostly because one "
"plain run let its notes bloat.", size=12.5, color="body") # fmt: skip
s.save("context-lm-tokens.svg")


Expand Down Expand Up @@ -221,8 +221,8 @@ def lines(sample):
s = Svg(100 + 40 + n * 26 + 62)
y0 = title(
s,
"Its notes after the last chunk, same held-out log",
f"Checked against the log's real final values. Question: final value of {task['ask']}?",
"Its notes after reading the whole log",
f"Same unseen log, checked against the true values. Asked: what is {task['ask']}?",
)
cw = (W - 48 - 16) / 2
for c, (head, rows, right) in enumerate(cols):
Expand Down Expand Up @@ -259,8 +259,8 @@ def smooth(xs, k=5):
s = Svg(100 + 230)
y0 = title(
s,
"Learning to keep its own notes",
"Share of training logs answered right, by step. Thin: 4 seeds. Thick: mean.",
"It learns to keep notes in about 15 steps",
"Practice logs answered right during training. Faint: each run. Bold: average.",
)
px0, px1, py0, py1 = 70, W - 30, y0 + 10, y0 + 180

Expand Down
Loading