diff --git a/README.md b/README.md index 8c8289e..e3d7550 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ Yes, in a controlled test run before the plugin was built, with direct questions A stronger reader doesn't remove the need. On the 384 questions after the fifth compaction that all three models answered, the summary alone scored 0.42 on `claude-haiku-5-5` and 0.43 on `claude-opus-5-5`; with search, 0.72 and 0.85. On Opus, though, search cost about as much per correct answer as the bigger summary. - - Score against mean tokens per question for each arm on claude-haiku-5-5, with 95% intervals: summary 0.53, summary-big 0.72, search 0.80, search-nudged 0.83, ceiling 0.95, floor 0.00 + + Score per arm for each of three models on the same 384 questions after the fifth compaction, in the order claude-haiku-5-5, claude-sonnet-5-5, claude-opus-5-5: summary 0.42, 0.42, 0.43; summary-big 0.56, 0.62, 0.62; search 0.72, 0.81, 0.85; search-nudged 0.77, 0.80, 0.86 The test also found a blind spot: the agent nearly always searched when the summary had left something out, but much less often when the summary gave a wrong answer, and seldom fixed those. [The test behind it](#the-test-behind-it) has the method and every hypothesis, and [REPORT.md](REPORT.md) is the full write-up. @@ -83,6 +83,11 @@ When a long agent session runs out of context, the conversation is replaced by a A search returns at most 3 excerpts of at most 500 characters, and the reader gets at most 3 searches per question, so a search arm sees at most about 1,200 tokens of the original: less than the 3,072 extra tokens `summary-big` gets. Scoring is CompactBench's own scorer; no judge model is used. The main run asked 1,802 questions in each arm. + + + Score against mean tokens per question for each arm on claude-haiku-5-5, with 95% intervals: summary 0.53, summary-big 0.72, search 0.80, search-nudged 0.83, ceiling 0.95, floor 0.00 + + ### What happened Four hypotheses were fixed in [PLAN.md](PLAN.md) before any paid run. Three passed. diff --git a/REPORT.md b/REPORT.md index e9d37a3..7e72387 100644 --- a/REPORT.md +++ b/REPORT.md @@ -355,6 +355,15 @@ On the questions both models answered: An extra, added after the plan and recorded in [PLAN.md's Deviations](PLAN.md#deviations): the second-model run again on `claude-opus-5-5`, a stronger reader, to see whether searching still pays off when the reader itself is stronger. It uses the same four arms, questions and effort as the Sonnet run, and decides no hypothesis. + + + + + Score per arm for each of the three models on their shared questions + + + + `claude-opus-5-5` at effort `high`, 48 cases. diff --git a/docs/charts.md b/docs/charts.md index 75058c0..154cd59 100644 --- a/docs/charts.md +++ b/docs/charts.md @@ -13,6 +13,7 @@ Each chart is written four times as `-.`, with `light` and | Name | Shows | | --- | --- | | `main` | Score against mean tokens per question (log scale) for `summary`, `summary-big`, `search` and `search-nudged`, with 95% intervals; `floor` and `ceiling` as dashed reference lines, labelled at the right edge with their tokens per question. Thin lines join `summary` to `summary-big`, and `summary` to `search` to `search-nudged`. The subtitle gives the model, cases and questions per arm | +| `three-models` | Score for each of the three models in each of the four arms, as grouped bars, on the questions all three answered (after the fifth compaction), each bar labelled with its score, the arms named in plain words ("4x summary", "Summary + search"). This is the README's lead chart | | `recovery-by-state` | Recovery rate on *held*, *missing* and *misled* questions for both search arms, each bar labelled with the share that searched | | `stale-and-trap` | Stale-answer rate and trap rate per arm, with 95% intervals and counts | | `cycles` | Each arm's score at cycle 0 and cycle 4 (the first and last cycle every arm was asked at), as a slope chart | @@ -20,15 +21,15 @@ Each chart is written four times as `-.`, with `light` and | `second-model` | The main model and the second model on their shared questions: score per arm, search rate for the search arms | | `flip` | Flip rate between the two `summary` runs, by family, with the overall rate as a reference line | -`second-model` needs a second-model run and `flip` a second `summary` run; without them the command skips those charts and removes any earlier copies. `cycles` compares the first and last cycle every arm was asked at. +`second-model` needs a second-model run, `three-models` a third-model run and `flip` a second `summary` run; without them the command skips those charts and removes any earlier copies. `cycles` compares the first and last cycle every arm was asked at. ## Look - **Fixed size and font.** Every chart is 8 × 5 inches: 576 × 360 pt as SVG, 1600 × 1000 px as PNG. Text is DejaVu Sans, which matplotlib ships, and SVG text is drawn as paths, so a chart looks the same on any machine. The same summary gives the same SVG bytes everywhere and the same PNG pixels; PNG files themselves are encoded differently on macOS and Linux, so `scripts/check_report.py` compares PNGs by pixel. - **Themes.** Ink and backgrounds follow GitHub's light and dark pages. SVGs are transparent and PNGs are filled with the page colour. -- **Colour.** Arms that see the same 1,024-token memory (`summary`, `search`, `search-nudged`) are three steps of one blue, `summary-big` is orange, and `floor` and `ceiling` are grey. Every mark colour clears 3:1 against its page. The blues are ordered by contrast with the page, so `search-nudged` is the darkest blue on light and the lightest on dark. They differ in lightness, not hue, so every arm is named beside its mark, on the axis or in a legend, and colour never identifies an arm on its own. On the main, stale-and-trap and cycles charts, search arms are drawn as diamonds and the others as circles. +- **Colour.** Arms that see the same 1,024-token memory (`summary`, `search`, `search-nudged`) are three steps of one blue, `summary-big` is orange, and `floor` and `ceiling` are grey. In `three-models`, the bars are the models, not arms: three steps of one green, with the strongest model's the darkest on light and the lightest on dark, named in a legend under the subtitle. Every mark colour clears 3:1 against its page. The blues are ordered by contrast with the page, so `search-nudged` is the darkest blue on light and the lightest on dark. They differ in lightness, not hue, so every arm is named beside its mark, on the axis or in a legend, and colour never identifies an arm on its own. On the main, stale-and-trap and cycles charts, search arms are drawn as diamonds and the others as circles. -To show the main chart in a README with the theme the reader uses: +The README leads with `three-models` and shows `main` under "The test behind it". To show a chart in a README with the theme the reader uses: ```html diff --git a/results/charts/three-models-dark.png b/results/charts/three-models-dark.png new file mode 100644 index 0000000..07508b1 Binary files /dev/null and b/results/charts/three-models-dark.png differ diff --git a/results/charts/three-models-dark.svg b/results/charts/three-models-dark.svg new file mode 100644 index 0000000..bba1dfb --- /dev/null +++ b/results/charts/three-models-dark.svg @@ -0,0 +1,1942 @@ + + + + + + + + image/svg+xml + + + Matplotlib v3.11.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/results/charts/three-models-light.png b/results/charts/three-models-light.png new file mode 100644 index 0000000..76597de Binary files /dev/null and b/results/charts/three-models-light.png differ diff --git a/results/charts/three-models-light.svg b/results/charts/three-models-light.svg new file mode 100644 index 0000000..34be4fc --- /dev/null +++ b/results/charts/three-models-light.svg @@ -0,0 +1,1942 @@ + + + + + + + + image/svg+xml + + + Matplotlib v3.11.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/backread_exp/charts.py b/src/backread_exp/charts.py index f95e82a..c708773 100644 --- a/src/backread_exp/charts.py +++ b/src/backread_exp/charts.py @@ -58,6 +58,9 @@ class Theme: grid: str axis: str arms: dict[str, str] + models: tuple[str, str, str] + """The main, second and third model's bars: three steps of one green, darkest on light and + lightest on dark for the third, the strongest.""" LIGHT = Theme( @@ -76,6 +79,7 @@ class Theme: "search-nudged": "#0d366b", "ceiling": "#59636e", }, + models=("#2a9d7f", "#1b7a62", "#0c4a3a"), ) DARK = Theme( @@ -94,6 +98,7 @@ class Theme: "search-nudged": "#b7d3f6", "ceiling": "#b1bac4", }, + models=("#2f9e7f", "#5cc4a4", "#a8e6d2"), ) THEMES = (LIGHT, DARK) @@ -832,10 +837,80 @@ def flip_chart(summary: dict[str, Any], theme: Theme) -> Figure | None: return fig +ARM_WORDS = { + "summary": "Summary", + "summary-big": "4x summary", + "search": "Summary + search", + "search-nudged": "Search + nudge", +} +"""Plain names for the arms on the `three-models` axis, which the README shows before it explains +the arms. The alt text keeps the arm names.""" + + +def three_models_chart(summary: dict[str, Any], theme: Theme) -> Figure | None: + """Score per arm for each of the three models, on the questions all three answered.""" + shared = summary.get("shared_all") + third = summary.get("third_model") + second = summary.get("second_model") + if not shared or not third or not second: + return None + runs = ( + ("main", summary["main"]["model"]), + ("second_model", second["model"]), + ("third_model", third["model"]), + ) + shown = [arm for arm in ARMS if arm in shared] + counts = {shared[arm]["questions"] for arm in shown} + same = f"The same {counts.pop():,}" if len(counts) == 1 else "The same" + fig = _figure( + theme, + "Search helps every model; a stronger model alone doesn't", + f"{same} questions per arm, asked after the fifth compaction", + ) + _legend_marks( + fig, + theme, + [ + (model_name(model), {"marker": "s", "markersize": 8, "color": color}) + for (_, model), color in zip(runs, theme.models, strict=True) + ], + ) + ax = _plot_area(fig, left=PLOT["left"], right=0.95, top=0.78) + _style(ax, theme) + width = 0.26 + for i, arm in enumerate(shown): + for j, ((key, _), color) in enumerate(zip(runs, theme.models, strict=True)): + value = shared[arm][key]["score"] + if value is None: + continue + x = i + (j - 1) * (width + 0.03) + ax.bar(x, value, width=width, color=color, zorder=3) + ax.annotate( + score_text(value), + (x, value), + xytext=(0, 3), + textcoords="offset points", + ha="center", + va="bottom", + fontsize=TICK_SIZE, + color=theme.ink, + zorder=6, + ) + ax.set_xticks(range(len(shown)), [ARM_WORDS.get(arm, arm) for arm in shown]) + ax.set_xlim(-0.55, len(shown) - 0.45) + ax.set_ylim(0, 1.0) + ax.yaxis.set_major_locator(FixedLocator([0, 0.25, 0.5, 0.75, 1.0])) + ax.yaxis.set_major_formatter(FuncFormatter(_plain_tick)) + ax.spines["bottom"].set_visible(False) + _axis_label(ax, theme, y="Score") + return fig + + # --- Command --------------------------------------------------------------------------------- CHARTS: dict[str, Callable[[dict[str, Any], Theme], Figure | None]] = { "main": main_chart, + "three-models": three_models_chart, "recovery-by-state": recovery_chart, "stale-and-trap": stale_trap_chart, "cycles": cycles_chart, diff --git a/src/backread_exp/document.py b/src/backread_exp/document.py index fefce07..4d1251f 100644 --- a/src/backread_exp/document.py +++ b/src/backread_exp/document.py @@ -368,6 +368,7 @@ def _gallery(sources: Sources) -> list[str]: CHART_ALT = { "main": "Score against tokens per question for each arm, with 95% intervals", + "three-models": "Score per arm for each of the three models on their shared questions", "recovery-by-state": "Recovery rate by summary state for the two search arms", "stale-and-trap": "Stale-answer rate and trap rate per arm, with 95% intervals", "cycles": "Each arm's score at the first and last cycle", @@ -377,7 +378,11 @@ def _gallery(sources: Sources) -> list[str]: } """Each chart's alt text.""" -CHART_NEEDS = {"second-model": "a second-model run", "flip": "a second `summary` run"} +CHART_NEEDS = { + "second-model": "a second-model run", + "three-models": "a third-model run", + "flip": "a second `summary` run", +} def _chart(stem: str) -> Block: diff --git a/src/backread_exp/readme.py b/src/backread_exp/readme.py index c9eaef2..f0f0398 100644 --- a/src/backread_exp/readme.py +++ b/src/backread_exp/readme.py @@ -45,6 +45,25 @@ def _usd(entries: Sequence[LedgerEntry]) -> str: return f"${sum(e.usd for e in entries):.2f}" +def three_models_alt(summary: dict[str, Any]) -> str: + """The lead chart's alt text: each arm's score for the main, second and third model.""" + shared = summary["shared_all"] + models = [summary["main"]["model"], summary["second_model"]["model"]] + models.append(summary["third_model"]["model"]) + runs = ("main", "second_model", "third_model") + arms = [arm for arm in ARMS if arm in shared] + rows = [ + f"{arm} " + ", ".join(fmt_num(shared[arm][run]["score"], 2) for run in runs) for arm in arms + ] + return ( + f"Score per arm for each of three models on the same {shared[arms[0]]['questions']:,}" + " questions after the fifth compaction, in the order " + + ", ".join(models) + + ": " + + "; ".join(rows) + ) + + def expected( summary: dict[str, Any], ledger: Sequence[LedgerEntry], gallery_picks: int ) -> list[str]: @@ -125,6 +144,8 @@ def shared_score(arm: str, run: str) -> str: f" with search, {shared_score('search', 'main')} and" f" {shared_score('search', 'third_model')}.", ] + if second is not None: + fragments.append(three_models_alt(summary)) return fragments diff --git a/tests/chart_fixtures.py b/tests/chart_fixtures.py index 6c2d0eb..10271a4 100644 --- a/tests/chart_fixtures.py +++ b/tests/chart_fixtures.py @@ -118,8 +118,9 @@ def _flip(t: Trace) -> Trace: ) -def chart_summary() -> dict[str, Any]: - """Every section filled: main run, a second `summary` run and a second-model run.""" +def chart_summary(*, third: bool = False) -> dict[str, Any]: + """Every section filled: main run, a second `summary` run and a second-model run, and with + `third` a third-model run too.""" main = make_run(_traces(1), CASES) rng = random.Random(2) rerun = make_run([_flip(t) if rng.random() < 0.1 else t for t in main.arms["summary"]], CASES) @@ -135,6 +136,20 @@ def chart_summary() -> dict[str, Any]: ], CASES, ) - out = summarize(main, rerun, sonnet) + opus = None + if third: + opus = make_run( + [ + t + for t in _traces( + 4, + model="claude-opus-5-5", + arms=("summary", "summary-big", "search", "search-nudged"), + ) + if t.cycle == 4 and t.question_key.endswith("-0") + ], + CASES, + ) + out = summarize(main, rerun, sonnet, opus) out["main"]["model"] = "claude-haiku-5-5" return out diff --git a/tests/test_charts.py b/tests/test_charts.py index de2f68f..a7530c9 100644 --- a/tests/test_charts.py +++ b/tests/test_charts.py @@ -17,6 +17,7 @@ STEMS = [ "main", + "three-models", "recovery-by-state", "stale-and-trap", "cycles", @@ -29,7 +30,7 @@ @pytest.fixture(scope="module") def summary() -> dict[str, Any]: # Round-trip through JSON, as the command reads it. - return json.loads(json.dumps(chart_summary())) + return json.loads(json.dumps(chart_summary(third=True))) @pytest.fixture(scope="module") @@ -92,9 +93,16 @@ def test_optional_sections_are_skipped_and_old_copies_removed( summary: dict[str, Any], tmp_path: Path ) -> None: charts.render(summary, tmp_path) - trimmed = {**summary, "flip": None, "second_model": None, "shared_questions": None} + trimmed = { + **summary, + "flip": None, + "second_model": None, + "shared_questions": None, + "third_model": None, + "shared_all": None, + } names = {path.name for path in charts.render(trimmed, tmp_path)} - assert not any(name.startswith(("flip-", "second-model-")) for name in names) + assert not any(name.startswith(("flip-", "second-model-", "three-models-")) for name in names) assert "main-light.svg" in names on_disk = {path.name for path in tmp_path.iterdir()} assert on_disk == names diff --git a/tests/test_readme.py b/tests/test_readme.py index b3efe02..0efe9e1 100644 --- a/tests/test_readme.py +++ b/tests/test_readme.py @@ -126,3 +126,12 @@ def test_a_moved_third_model_score_is_caught( moved["shared_all"]["search"]["third_model"]["score"] = 0.70 found = readme.problems(text, moved, ledger, PICKS) assert any("with search, 0.72 and 0.70." in p for p in found) + + +def test_a_moved_lead_chart_score_is_caught( + text: str, summary: dict[str, Any], ledger: list[LedgerEntry] +) -> None: + moved = copy.deepcopy(summary) + moved["shared_all"]["search"]["second_model"]["score"] = 0.70 + found = readme.problems(text, moved, ledger, PICKS) + assert any("search 0.72, 0.70, 0.85" in p for p in found)