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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ demo/.config/

# sqlite in-memory session artifact accidentally created by tooling
:memory:*
eval/data/
35 changes: 26 additions & 9 deletions eval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,41 @@ this measures, on a labeled set, comparing:
```bash
make bench # ships a labeled synthetic set (16 docs, 21 questions)
python eval/bench_recall_ab.py --json
python eval/bench_recall_ab.py --dataset path/to/longmemeval.json
python eval/bench_recall_ab.py --dataset eval/data/longmemeval_s_cleaned.json
python eval/bench_recall_ab.py --dataset eval/bench_dataset_contradictions.json
python eval/bench_recall_ab.py --dataset eval/data/lme_v2 # LongMemEval-V2 root
python eval/bench_recall_ab.py --dataset X --limit 50 # cheap smoke of a big set
```

Metrics (condition B): recall@1/3/5, MRR, and answer-coverage@5 (the fraction
of questions whose answer text lands in the top-5 context, a proxy for
"re-explanation avoided"). Latest numbers and methodology are in
[`RESULTS.md`](RESULTS.md).
Metrics (condition B): recall@1/3/5 and MRR over questions with `supports`
labels; answer-coverage@5 over all questions (the "re-explanation avoided" /
retrieval-sufficiency proxy); and, on contradiction-labelled sets such as
`bench_dataset_contradictions.json`, stale-ahead rate (an outdated doc
outranks the current one) and stale-answer-coverage@5 (the outdated answer
text reaches the injected context). Latest numbers and methodology are in
[`RESULTS.md`](RESULTS.md); `--write-results` refreshes the marked block.

`--dataset` accepts three shapes (conversion in `longmemeval_convert.py`):
native `{corpus, questions}` JSON, LongMemEval v1 JSON (each session becomes
one doc; each question retrieves within its own haystack), or a prepared
LongMemEval-V2 data directory (`questions.jsonl` + `trajectories.jsonl` +
`haystacks/lme_v2_<tier>.json`; V2 has no answer-trajectory labels, so its
questions are coverage-only). Small labeled sets ship in `eval/`; large
downloaded benchmarks live in `eval/data/`, which is gitignored — download
LongMemEval-S from
`https://huggingface.co/datasets/xiaowu0162/longmemeval-cleaned` and V2 from
`https://huggingface.co/datasets/xiaowu0162/longmemeval-v2`.

### Honest scope

This is a **retrieval-grounded** benchmark, not an end-to-end task-success
score with an LLM judge. It proves the right memory is surfaced; it does not by
itself prove the agent's final answer is better. The shipped set is synthetic
and small, with distractor documents and indirect phrasing added so the score
is not a trivial 1.000. The credible public benchmark is **LongMemEval**
(multi-session, with distractors); the harness ingests its JSON via
`--dataset`, but running the full public set is tracked in `ROADMAP.md`, not
done here.
is not a trivial 1.000. The same code path runs the public **LongMemEval-S**
(500 questions, per-question haystacks) and **LongMemEval-V2** (451 questions,
coverage-only) sets; per-run numbers and caveats live in
[`RESULTS.md`](RESULTS.md).

## `calibrate_rerank_gate.py`: what should `auto_recall_min_rerank` be?

Expand Down
52 changes: 48 additions & 4 deletions eval/RESULTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,54 @@ Reproduce: `make bench` (a few seconds once the embedding model is cached).
and indirectly-worded questions, including against near-neighbor distractors.
That is the precondition for recall being useful.
- It does **not** by itself prove an agent's final answer is better, and it is
a small synthetic set, not a public benchmark. The credible next step is
**LongMemEval** (multi-session, large, with distractors); the harness already
ingests its JSON format via `--dataset`, and running the full public set is
on the roadmap. Numbers will be published whatever they say.
a small synthetic set, not a public benchmark. **LongMemEval (S and V2) has
since been run in full — see the section below.**

<!-- longmemeval:start -->
## LongMemEval (public benchmark, 2026-09-24)

Full public sets, shipped retrieval config (hybrid BM25+dense bge-base, no
rerank gate — the gate stays off per the calibration above), run end-to-end
on this machine. Conversion from the official distributions lives in
[`longmemeval_convert.py`](longmemeval_convert.py); per-question haystacks
restrict retrieval to that question's own sessions.

### LongMemEval-S (500 questions, 23,854 sessions)

| metric | value |
|---|---:|
| recall@1 | 0.836 |
| recall@3 | 0.954 |
| recall@5 | 0.970 |
| MRR | 0.894 |
| answer-coverage@5 (raw substring) | 0.466 |
| answer-coverage@5 (groundable-only) | 0.896 (233/260) |

**The raw coverage number needs its caveat spelled out.** LongMemEval answers
are often abstractions ("February 14th") that appear verbatim in *no* session
body — only 260 of 500 answer substrings occur anywhere in their haystack.
Substring coverage is therefore a floor, not a failure: among questions whose
answer text exists verbatim in the corpus, top-5 context contains it 89.6% of
the time. recall@5 = 0.970 means the labeled answer-bearing session is in the
injected context for 97% of questions (418/500 rank it #1).

Condition A (empty brain) is 0.000 on every metric by construction.

### LongMemEval-V2 small (451 questions, coverage-only)

| metric | value |
|---|---:|
| answer-coverage@5 (raw substring) | 0.421 |

V2 ships no `supports` labels, so recall@k is undefined by construction; the
coverage metric has the same abstraction caveat as above (215/451 answers
appear verbatim somewhere in the haystack). Reported as a floor.

Reproduce: `python eval/bench_recall_ab.py --dataset eval/data/longmemeval_s_cleaned.json`
(~4 h on an M4 Pro; the embedding of 23.8k sessions dominates) and
`python eval/bench_recall_ab.py --dataset eval/data/lme_v2`.

<!-- longmemeval:end -->

<!-- rerank-gate:start -->
## Rerank relevance gate (S4)
Expand Down
Empty file added eval/__init__.py
Empty file.
134 changes: 134 additions & 0 deletions eval/bench_dataset_contradictions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"corpus": [
{
"slug": "deploy-old",
"title": "Deployment runbook (2025)",
"body": "Deployments go through CodeDeploy with blue-green instance groups. The pipeline waits for the old fleet to drain before traffic shifts."
},
{
"slug": "deploy-new",
"title": "Deployment runbook (updated June 2026)",
"body": "Since 2026-06 deployments run on ECS with rolling updates. CodeDeploy was retired; the pipeline now watches ECS service stabilization instead of instance draining."
},
{
"slug": "linter-old",
"title": "Repo tooling notes (2025)",
"body": "Python linting uses pylint with the shared config in tools/pylint.ini. Pre-commit runs pylint on changed files."
},
{
"slug": "linter-new",
"title": "Repo tooling notes (updated August 2026)",
"body": "Since 2026-08 the repo lints with ruff. The pylint config was deleted and pre-commit now runs ruff check on changed files."
},
{
"slug": "datastore-old",
"title": "Storage architecture (2025)",
"body": "The primary datastore is MongoDB. Services read and write through the shared mongoose models package."
},
{
"slug": "datastore-new",
"title": "Storage architecture (updated March 2026)",
"body": "PostgreSQL is the primary datastore as of 2026-03, accessed through Kysely migrations. MongoDB remains only for legacy session archives."
},
{
"slug": "standup-old",
"title": "Team rituals (2025)",
"body": "Daily standup runs at 09:30 UTC in the engineering voice channel."
},
{
"slug": "standup-new",
"title": "Team rituals (updated July 2026)",
"body": "Since 2026-07 daily standup runs at 16:00 UTC to include the Warsaw team. The 09:30 slot was dropped."
},
{
"slug": "oncall-old",
"title": "Incident process (2025)",
"body": "Incident paging goes through PagerDuty service rotations with a weekly handoff on Mondays."
},
{
"slug": "oncall-new",
"title": "Incident process (updated May 2026)",
"body": "Since 2026-05 incident paging runs through Helix with NOC-first triage. PagerDuty is kept read-only for historical reports."
},
{
"slug": "feature-flags",
"title": "Feature flags",
"body": "Feature flags are managed through the flag SDK; flags default to disabled and roll out by percentage."
},
{
"slug": "vector-store",
"title": "Local retrieval notes",
"body": "Local memory retrieval uses a hybrid of vector similarity and BM25 keyword ranking fused together."
},
{
"slug": "runbooks",
"title": "Runbook index",
"body": "Operational runbooks live in the wiki and are indexed by service name and symptom keyword."
},
{
"slug": "ci-notes",
"title": "CI pipeline",
"body": "CI runs lint on Linux and the hermetic test subset on macOS. Test jobs run on multiple Python versions."
}
],
"questions": [
{
"id": "q-deploy",
"q": "How do services get deployed to production these days?",
"supports": ["deploy-new"],
"stale": ["deploy-old"],
"answer_substring": "ECS",
"stale_answer_substring": "CodeDeploy"
},
{
"id": "q-lint",
"q": "Which linter should I configure for the Python repo?",
"supports": ["linter-new"],
"stale": ["linter-old"],
"answer_substring": "ruff",
"stale_answer_substring": "pylint"
},
{
"id": "q-datastore",
"q": "What database do new services build on?",
"supports": ["datastore-new"],
"stale": ["datastore-old"],
"answer_substring": "PostgreSQL",
"stale_answer_substring": "MongoDB"
},
{
"id": "q-standup",
"q": "When is the daily standup meeting?",
"supports": ["standup-new"],
"stale": ["standup-old"],
"answer_substring": "16:00",
"stale_answer_substring": "09:30"
},
{
"id": "q-oncall",
"q": "Where do incident pages come from now?",
"supports": ["oncall-new"],
"stale": ["oncall-old"],
"answer_substring": "Helix",
"stale_answer_substring": "PagerDuty"
},
{
"id": "q-flags",
"q": "How are feature flags rolled out?",
"supports": ["feature-flags"],
"answer_substring": "flag SDK"
},
{
"id": "q-retrieval",
"q": "How does local memory retrieval rank results?",
"supports": ["vector-store"],
"answer_substring": "BM25"
},
{
"id": "q-runbooks",
"q": "Where do I find the operational runbooks?",
"supports": ["runbooks"],
"answer_substring": "wiki"
}
]
}
Loading
Loading