Skip to content

Commit 54088a1

Browse files
phernandezclaude
andcommitted
feat(core): add BEAM benchmark integration to the benchmarks package
BEAM (arXiv 2510.27246) joins LoCoMo as a second dataset under the same provider abstraction and fairness contract: path-based dataset adapter with tier selection (100K/500K; 10M excluded), raw transcript-as-notes converter with anti-leakage probe-marker stripping (fail-fast on unknown variants), nugget scoring (0/0.5/1 judge, per-question mean), event ordering via LLM alignment + pure-Python Kendall tau-b, per-ability reporting across all ten abilities with per-answer token accounting, and CLI wiring. Dataset is never vendored; the fetch command is documented. Runner provenance (adapted upstream prompts/math and every deviation) is recorded in docs/benchmarks.md. Tests run fully offline against a hand-written miniature fixture with stubbed LLM runners. Also: pin the benchmarks package ruff lint selection (was implicitly tracking ruff's default, which changed in 0.16), and fix two pre-existing pyright errors in untouched provider tests that blocked the typecheck gate. Closes #1400 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014pmKq6bqCi6Zp6BTHuZjrp Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 9c6fc45 commit 54088a1

26 files changed

Lines changed: 2952 additions & 25 deletions

‎benchmarks/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ benchmarks/bm-home/
1919
benchmarks/datasets/longmemeval/longmemeval_s.json
2020
benchmarks/datasets/longmemeval/longmemeval_s.provenance.json
2121
benchmarks/datasets/locomo-audit/
22+
benchmarks/datasets/beam/upstream/
2223
benchmarks/.mem0-qdrant/
2324
benchmarks/datasets/convomem/
2425
benchmarks/.bm-homes/

‎benchmarks/AGENTS.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,18 @@ CLI entrypoint: `uv run bm-bench ...`
3232
Dataset and conversion:
3333
- `uv run bm-bench datasets fetch --dataset locomo`
3434
- `uv run bm-bench convert locomo --dataset-path benchmarks/datasets/locomo/locomo10.json --output-dir benchmarks/generated/locomo`
35+
- `bash benchmarks/datasets/beam/download.sh` (BEAM data is never vendored; sparse clone)
36+
- `uv run bm-bench convert beam --tier 100K --output-dir benchmarks/generated/beam-100k`
3537

3638
Run retrieval:
3739
- `uv run bm-bench run retrieval --providers bm-local,mem0-local --dataset-id locomo --dataset-path benchmarks/datasets/locomo/locomo10.json --corpus-dir benchmarks/generated/locomo/docs --queries-path benchmarks/generated/locomo/queries.json --output-root benchmarks/runs --allow-provider-skip`
3840

3941
Run end-to-end QA scoring:
4042
- `uv run bm-bench run qa --run-dir benchmarks/runs/<run-id> --answerer claude:claude-haiku-4-5 --judge claude:claude-sonnet-4-6`
4143

44+
BEAM nugget scoring (post-hoc, after `run qa` on a BEAM run):
45+
- `uv run bm-bench run beam-score --run-dir benchmarks/runs/<run-id> --judge claude:claude-sonnet-4-6`
46+
4247
Validate and publish:
4348
- `uv run bm-bench validate-artifacts --run-dir benchmarks/runs/<run-id>`
4449
- `uv run bm-bench publish --run-dir benchmarks/runs/<run-id> --destination benchmarks/results/public`
@@ -49,6 +54,9 @@ Validate and publish:
4954
- `BM_LOCAL_PATH=.. just bench-concurrent-write-load`
5055
- `just bench-fetch-locomo`
5156
- `just bench-convert-locomo`
57+
- `just bench-prepare-beam`
58+
- `just bench-run-beam-100k`
59+
- `just bench-beam-score benchmarks/runs/<run-id>`
5260
- `just bench-run-bm-local`
5361
- `just bench-run-mem0-local`
5462
- `just bench-run-full`

‎benchmarks/README.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies remain isolated from the product environment.
2121
- Datasets:
2222
- LoCoMo (primary)
2323
- LongMemEval scaffold (placeholder)
24+
- BEAM (grouped, 100K/500K/1M tiers; never vendored)
2425
- Built-in synthetic smoke corpus
2526

2627
## Installation
@@ -156,6 +157,41 @@ Anti-leakage: raw conversations carry `containsEvidence`/`model_name` fields;
156157
rendered docs include neither and conversation ids are remapped to neutral
157158
positional ids.
158159

160+
## BEAM
161+
162+
BEAM ("Beyond a Million Tokens", arXiv 2510.27246, ICLR 2026;
163+
mohammadtavakoli78/BEAM, code MIT / data CC BY-SA 4.0) probes ten memory
164+
abilities — abstention, contradiction resolution, event ordering, information
165+
extraction, instruction following, knowledge update, multi-session ("multi-hop")
166+
reasoning, preference following, summarization, temporal reasoning — over
167+
synthetic multi-month conversations. Each conversation is its own haystack, so
168+
it runs in **grouped mode** like LongMemEval. The data is **never vendored**;
169+
fetch it with the documented sparse clone (see
170+
`benchmarks/datasets/beam/README.md`).
171+
172+
```bash
173+
just bench-prepare-beam # sparse-clone 100K/500K tiers + convert 100K
174+
just bench-convert-beam-500k # or the 500K tier
175+
just bench-run-beam-100k # grouped retrieval (bm-local + mem0-local)
176+
just bench-qa benchmarks/runs/<run-id> # answers via the shared QA stage
177+
just bench-beam-score benchmarks/runs/<run-id> # BEAM nugget/ordering scoring
178+
```
179+
180+
Answering uses the package's fixed answer prompt and context budget for every
181+
provider (the fairness contract), so absolute numbers are not directly
182+
comparable to the paper's tables. Scoring follows BEAM's nugget methodology:
183+
the probe rubric's atomic nuggets are judged 0/0.5/1 each, Event Ordering is
184+
scored with Kendall tau-b over an LLM-aligned event sequence, and
185+
`beam-summary.md` reports per-ability scores plus per-answer token accounting
186+
— never just an overall average. Runs pass the converter's `conversion.json`
187+
as `--dataset-path`, which pins per-file sha256s of the exact BEAM inputs.
188+
189+
Anti-leakage: upstream message content ends with a `->-> <batch>,<question>`
190+
marker (the question field is sometimes non-numeric, e.g. `N/A`) linking
191+
transcript text to probe indices; the converter strips it and fails fast if a
192+
marker variant survives, and rubrics/reference answers live only in
193+
`queries.json`, never in ingested docs.
194+
159195
## Concurrent-write benchmark (basic-memory#1248)
160196

161197
Measures correctness under concurrency: independent `bm mcp` client sessions
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# BEAM Dataset
2+
3+
BEAM ("Beyond a Million Tokens: Benchmarking the Long-Term Memory of Large
4+
Language Models", arXiv 2510.27246, ICLR 2026) probes long-term conversational
5+
memory across ten abilities over synthetic multi-month chat histories.
6+
7+
- Upstream: https://github.com/mohammadtavakoli78/BEAM
8+
- License: the upstream **code is MIT**; the **benchmark data is CC BY-SA 4.0**
9+
— attribution and share-alike are required for any redistributed derivative.
10+
The data is therefore never vendored into this repo; fetch it locally.
11+
12+
## Fetch
13+
14+
The data lives in-tree upstream under `chats/{100K,500K,1M,10M}/<N>/`. Fetch
15+
only the tiers you need with a sparse clone (the full tree is thousands of
16+
blobs):
17+
18+
```bash
19+
bash benchmarks/datasets/beam/download.sh
20+
# or via just:
21+
just bench-fetch-beam
22+
```
23+
24+
This clones into `benchmarks/datasets/beam/upstream/` (gitignored) with only
25+
`chats/100K` and `chats/500K` checked out. To add the 1M tier:
26+
27+
```bash
28+
git -C benchmarks/datasets/beam/upstream sparse-checkout add chats/1M
29+
```
30+
31+
## Tiers
32+
33+
| Tier | Layout | Supported |
34+
| --- | --- | --- |
35+
| 100K | `chats/100K/<N>/` per-conversation | yes |
36+
| 500K | `chats/500K/<N>/` per-conversation | yes |
37+
| 1M | `chats/1M/<N>/` per-conversation | yes (same layout) |
38+
| 10M | combined plan-N layout | no (v1 out of scope) |
39+
40+
Each conversation directory contains `chat.json` (and sometimes
41+
`chat_trunecated.json` — sic, upstream misspelling — which is preferred when
42+
present, mirroring upstream's answer generation) plus
43+
`probing_questions/probing_questions.json` keyed by the ten abilities.
44+
45+
## Convert and run
46+
47+
```bash
48+
uv run bm-bench convert beam --tier 100K --output-dir benchmarks/generated/beam-100k
49+
uv run bm-bench run retrieval \
50+
--dataset-id beam-100k \
51+
--dataset-path benchmarks/generated/beam-100k/conversion.json \
52+
--corpus-dir benchmarks/generated/beam-100k/groups \
53+
--queries-path benchmarks/generated/beam-100k/queries.json \
54+
--providers bm-local,mem0-local --allow-provider-skip
55+
uv run bm-bench run qa --run-dir benchmarks/runs/<run-id> --answerer ... --judge ...
56+
uv run bm-bench run beam-score --run-dir benchmarks/runs/<run-id> --judge ...
57+
```
58+
59+
`conversion.json` is the provenance manifest the converter writes: it records
60+
the tier, per-conversation source filenames and sha256 checksums of every chat
61+
and probing-questions file consumed. Runs pass it as `--dataset-path` so the
62+
run manifest's dataset checksum pins the exact converted inputs.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# BEAM benchmark data (CC BY-SA 4.0) is never vendored into this repo.
5+
# The upstream repo carries the data in-tree, so a sparse blobless clone of
6+
# just the needed tiers is the minimal fetch. Destination is gitignored.
7+
8+
dest="benchmarks/datasets/beam/upstream"
9+
10+
if [ ! -d "$dest/.git" ]; then
11+
git clone --filter=blob:none --sparse https://github.com/mohammadtavakoli78/BEAM "$dest"
12+
fi
13+
git -C "$dest" sparse-checkout set chats/100K chats/500K
14+
15+
echo "BEAM 100K/500K tiers available under $dest/chats"
16+
echo "Add more tiers with: git -C $dest sparse-checkout add chats/1M"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dataset_id": "beam",
3+
"source_url": "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/mohammadtavakoli78/BEAM",
4+
"citation": "BEAM: Beyond a Million Tokens (ICLR 2026, arXiv 2510.27246)",
5+
"license_note": "Code MIT; benchmark data CC BY-SA 4.0"
6+
}

‎benchmarks/docs/benchmarks.md‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ It covers:
3131

3232
- Official headline: LoCoMo categories 1-4 (`official_headline` in summaries)
3333
- Adversarial breakout: LoCoMo category 5 (`adversarial_breakout`)
34+
- BEAM datasets reuse the same two containers with a dataset-keyed split:
35+
the nine answerable abilities are the headline and abstention is the
36+
breakout (abstention rows have empty ground truth, so their recall is 0 by
37+
construction). The field names are kept for artifact-schema stability and
38+
read as generic headline/breakout.
3439

3540
### Fairness contract
3641

@@ -77,9 +82,12 @@ just bench-prepare-long
7782
- `bench-concurrent-write-load`
7883
- `bench-prepare-short`
7984
- `bench-prepare-long`
85+
- `bench-prepare-beam`
8086
- `bench-run-short`
8187
- `bench-run-long`
8288
- `bench-run-full`
89+
- `bench-run-beam-100k`
90+
- `bench-beam-score`
8391
- `bench-validate`
8492
- `bench-publish`
8593
- `bench-compare`
@@ -91,10 +99,12 @@ Top-level commands:
9199

92100
- `datasets fetch`
93101
- `convert locomo`
102+
- `convert beam`
94103
- `run retrieval`
95104
- `run concurrent-write`
96105
- `run full`
97106
- `run qa`
107+
- `run beam-score`
98108
- `run rejudge`
99109
- `run review`
100110
- `compare`
@@ -199,6 +209,12 @@ Optional QA files:
199209
- `review.html`
200210
- `qa-diagnosis.json`
201211

212+
Optional BEAM files (only on BEAM runs, after `run beam-score`):
213+
214+
- `per-query-beam.jsonl`
215+
- `beam-summary.json`
216+
- `beam-summary.md`
217+
202218
### Key provenance fields
203219

204220
From `manifest.json`:
@@ -230,6 +246,82 @@ Publish bundle:
230246
just bench-publish run_dir="$(just bench-latest-run)"
231247
```
232248

249+
## 6b) BEAM (arXiv 2510.27246)
250+
251+
BEAM probes ten long-term-memory abilities (abstention, contradiction
252+
resolution, event ordering, information extraction, instruction following,
253+
knowledge update, multi-session reasoning, preference following,
254+
summarization, temporal reasoning) over synthetic multi-month conversations.
255+
Each conversation is an isolated haystack, so BEAM runs in grouped mode.
256+
257+
### Workflow
258+
259+
```bash
260+
just bench-fetch-beam # sparse clone of chats/100K + chats/500K (never vendored)
261+
just bench-convert-beam-100k # -> benchmarks/generated/beam-100k/{groups,queries.json,conversion.json}
262+
just bench-run-beam-100k # grouped retrieval, unchanged runner/fairness surface
263+
just bench-qa benchmarks/runs/<run-id> # answers via the shared fixed QA stage
264+
just bench-beam-score benchmarks/runs/<run-id> # BEAM nugget/ordering scoring (post-hoc)
265+
```
266+
267+
Runs pass `benchmarks/generated/beam-<tier>/conversion.json` as
268+
`--dataset-path`: the converter records per-file sha256 of every consumed
269+
chat/probing file there, so the run manifest's dataset checksum pins the exact
270+
converted inputs. Tiers 100K/500K/1M share a layout and are supported; the
271+
10M tier's combined plan-N layout is rejected in v1.
272+
273+
### Scoring definition
274+
275+
- Every probe's reference answer is pre-decomposed upstream into atomic
276+
nuggets (`rubric`). The judge scores each nugget 0/0.5/1 against the stored
277+
generated answer; the per-question nugget score is the mean.
278+
- Event Ordering: the answer's lines are aligned against the ordered
279+
reference events with an LLM equivalence judge (greedy first-match, matched
280+
lines replaced by the reference label), then scored with set P/R/F1 and
281+
Kendall tau-b over union rank vectors; `tau_norm = (tau_b + 1) / 2` and
282+
`final_score = tau_norm * f1` are both recorded.
283+
- Per-ability headline: mean `tau_norm` for event_ordering, mean nugget score
284+
for the other nine — mirroring upstream `report_results.py`. Reports always
285+
show all ten abilities plus per-answer token accounting; the macro average
286+
is reported beside them, never instead of them.
287+
- Errored cases (answerer/judge failure, malformed verdict) are excluded from
288+
means and counted explicitly — never silently zero-scored.
289+
290+
### Runner provenance
291+
292+
Adapted from `mohammadtavakoli78/BEAM` (MIT code / CC BY-SA 4.0 data):
293+
294+
- `unified_llm_judge_base_prompt` (`src/prompts.py:11547`) →
295+
`BEAM_NUGGET_JUDGE_PROMPT` in `scoring/beam.py`. Modification: the probing
296+
question is injected as an explicit input — upstream's RESPONSIVENESS
297+
section references "the QUESTION" without ever providing it.
298+
- `llm_equivalence` + `align_with_llm` + `event_ordering_score`
299+
(`src/evaluation/compute_metrics.py`) → equivalence prompt merged to
300+
single-prompt form for the package `LLMRunner`; the math (union ranks,
301+
tie rank, tau-b, normalisation, `final = tau_norm * f1`) is replicated,
302+
with one deviation: when the tie-corrected denominator is 0 (e.g. a
303+
single-event probe), upstream propagates scipy's NaN into its means,
304+
while this port maps undefined tau to `tau_norm = 0.0` so the case stays
305+
countable. System list = the response split on newlines (the shipped
306+
path; upstream's commented-out fact-extraction variant is not adopted),
307+
with blank lines dropped. Caveat: the package's fixed answer prompt asks
308+
for concise answers, which can yield single-line orderings that collapse
309+
to one system item and deflate F1/tau for every provider alike; a
310+
per-ability format hint would breach the fixed-prompt fairness contract,
311+
so v1 accepts and discloses this instead.
312+
- Aggregation from `src/evaluation/report_results.py` as described above.
313+
- Not reused, and why: `scipy.stats.kendalltau` (pure-Python tau-b instead —
314+
rank vectors are tiny); `json_repair` (silent repair conflicts with the
315+
package's fail-fast rule; malformed verdicts become explicit per-case
316+
errors); upstream's LangChain gpt-4.1-mini judge (replaced by the package
317+
`LLMRunner` seam — the judge is an operator flag recorded in artifacts, so
318+
published numbers must note the judge differs from the paper's); BEAM's
319+
answering baselines and RAG prompt (answers go through this package's fixed
320+
`ANSWER_PROMPT_TEMPLATE` + context budget so all providers face identical
321+
conditions — absolute numbers are therefore not directly comparable to the
322+
paper's tables); the HF materialization script and `chat.pickle` (the
323+
repo's JSON layout is read directly); the 10M tier.
324+
233325
## 7) Commit-to-Commit Comparison (Current Manual Method)
234326

235327
Use this workflow today to compare BM revisions while keeping benchmark tooling fixed.

‎benchmarks/justfile‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ locomo_c1_output_dir := "benchmarks/generated/locomo-c1"
1212
longmemeval_dataset_path := "benchmarks/datasets/longmemeval/longmemeval_s.json"
1313
longmemeval_output_dir := "benchmarks/generated/longmemeval-s"
1414
longmemeval_dev_output_dir := "benchmarks/generated/longmemeval-s-dev"
15+
beam_root := "benchmarks/datasets/beam/upstream/chats"
16+
beam_100k_output_dir := "benchmarks/generated/beam-100k"
17+
beam_500k_output_dir := "benchmarks/generated/beam-500k"
1518

1619
# --- Repo maintenance ---
1720

@@ -70,6 +73,33 @@ bench-convert-convomem:
7073

7174
bench-prepare-convomem: bench-fetch-convomem bench-convert-convomem
7275

76+
# BEAM data is never vendored: sparse-clone the 100K/500K tiers locally
77+
bench-fetch-beam:
78+
bash benchmarks/datasets/beam/download.sh
79+
80+
bench-convert-beam-100k:
81+
uv run bm-bench convert beam --dataset-root {{beam_root}} --tier 100K --output-dir {{beam_100k_output_dir}}
82+
83+
bench-convert-beam-500k:
84+
uv run bm-bench convert beam --dataset-root {{beam_root}} --tier 500K --output-dir {{beam_500k_output_dir}}
85+
86+
bench-prepare-beam: bench-fetch-beam bench-convert-beam-100k
87+
88+
# Grouped retrieval over BEAM 100K (one isolated corpus per conversation)
89+
bench-run-beam-100k:
90+
uv run bm-bench run retrieval \
91+
--dataset-id beam-100k \
92+
--dataset-path {{beam_100k_output_dir}}/conversion.json \
93+
--corpus-dir {{beam_100k_output_dir}}/groups \
94+
--queries-path {{beam_100k_output_dir}}/queries.json \
95+
--providers bm-local,mem0-local \
96+
{{bm_local_path_flag}} \
97+
--allow-provider-skip
98+
99+
# BEAM nugget/ordering scoring over a run's stored QA answers
100+
bench-beam-score run_dir judge="claude:claude-sonnet-4-6":
101+
uv run bm-bench run beam-score --run-dir "{{run_dir}}" --judge "{{judge}}"
102+
73103
bench-fetch-locomo-audit:
74104
uv run bm-bench datasets fetch --dataset locomo-audit
75105

‎benchmarks/pyproject.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ markers = [
4747
line-length = 100
4848
target-version = "py312"
4949

50+
# Same explicit selection as the root pyproject: pin the rule set the package
51+
# was written against so ruff default-select drift across versions (e.g. the
52+
# 0.16 default expansion) cannot change lint results between environments.
53+
[tool.ruff.lint]
54+
select = ["E4", "E7", "E9", "F"]
55+
5056
[tool.pyright]
5157
include = ["src", "tests", "test-int"]
5258
pythonVersion = "3.12"

0 commit comments

Comments
 (0)