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
4 changes: 3 additions & 1 deletion app/nullius/catalogue/benchmarks/longmemeval/benchmark.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"upstream_limitations": [
"Scores compare with the paper only with its reader, GPT-4o or GPT-4o-mini, and its judge, GPT-4o.",
"A reader you choose must take about 126,200 tokens. The history is not cut to fit, so a longer recall fails at the model.",
"An empty reply from the reader fails the question.",
"Original memory defaults to 800 reader output tokens. Larger limits reduce history space and differ from the paper.",
"Empty answers fail, including when reasoning consumes the reader's output budget.",
"Choose a judge that can return yes/no text within 10 output tokens.",
"Three combinations fail as published: merge expansion with a full-history retriever, user-only with flat-bm25-turn, and separate notes with chain-of-note reading and nl history.",
"The judge, a model, rejects about one right answer in twenty, and passes an empty answer now and then.",
"Time-aware query expansion fails as published."
Expand Down
6 changes: 5 additions & 1 deletion app/nullius/catalogue/benchmarks/longmemeval/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ def answer(unit, dir, setup, model, base_url, key, judge=None, simulator=None, a
"--retriever_type", retriever_type, "--topk_context", _opt("topk", "1000"),
"--merge_key_expansion_into_value", _opt("merge_key_expansion", "none"),
"--history_format", _opt("history_format", "json"), "--useronly", _opt("useronly", "false")] + flags.split()
# The pinned Python entry point supports this flag; omission preserves its defaults.
length = _opt("gen_length", "upstream")
if length != "upstream":
argv += ["--gen_length", length]
log = os.path.join(dir, "run_generation.log")
_run(argv, os.path.join(up, "src", "generation"), env, log, "run_generation.py")
hyp = [json.loads(ln) for p in glob.glob(os.path.join(out, "*_testlog_*")) for ln in open(p, encoding="utf-8") if ln.strip()]
Expand Down Expand Up @@ -366,7 +370,7 @@ def score_setup(unit, dir, judge):
"options": {n: _opt(n, d) for n, d in (("retriever", "full-history-session"), ("topk", "1000"),
("reading", "con"), ("separate_notes", "false"), ("history_format", "json"), ("useronly", "false"),
("merge_key_expansion", "none"), ("session_expansion", "none"), ("turn_expansion", "none"),
("expansion_join", "separate"))}}}
("expansion_join", "separate"), ("gen_length", "upstream"))}}}


HANDLERS = {"units": units, "setup": setup, "produce": produce, "score": score, "oracle": oracle, "answer": answer}
Expand Down
11 changes: 11 additions & 0 deletions app/nullius/catalogue/benchmarks/longmemeval/standard.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,17 @@
"model"
]
},
"gen_length": {
"label": "Reader output tokens",
"summary": "Reader output limit; larger values leave less room for history.",
"pattern": "(?:upstream|[1-9][0-9]*)",
"example": "4096",
"default": "upstream",
"setups": [
"original",
"model"
]
},
"separate_notes": {
"label": "Separate notes",
"summary": "Write a separate note for each retrieved session or turn before reasoning. Original memory only.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{"entry": "src/generation/run_generation.py", "setting": "--con", "values": "true, false", "default": "false", "nullius": "option:separate_notes"},
{"entry": "src/generation/run_generation.py", "setting": "--cot", "values": "true, false", "default": "required", "nullius": "option:reading"},
{"entry": "src/generation/run_generation.py", "setting": "--merge_key_expansion_into_value", "values": "merge, replace, none", "default": "none", "nullius": "option:merge_key_expansion"},
{"entry": "src/generation/run_generation.py", "setting": "--gen_length", "values": "an integer", "default": "None (500, or 800 with --cot)", "nullius": "fixed:None - run_generation.sh never passes it, so the answer length follows the reading method"},
{"entry": "src/generation/run_generation.py", "setting": "--gen_length", "values": "an integer", "default": "None (800: --cot is a nonempty string, including false)", "nullius": "option:gen_length"},
{"entry": "src/generation/run_generation.py", "setting": "model2maxlength, max_retrieval_length", "values": "128000 for the GPT readers; the window less the answer length less 1000", "default": "", "nullius": "fixed:as published - the history is cut to 126,200 tokens (con) by o200k_base, the start kept"},
{"entry": "src/generation/run_generation.py", "setting": "temperature, n", "values": "0, 1", "default": "", "nullius": "fixed:0, 1 - as published"},
{"entry": "src/generation/run_generation.py", "setting": "chat_completions_with_backoff", "values": "a rate limit retried every 5 s, without end", "default": "", "nullius": "fixed:as published - the unit's turn_seconds (3600 s) bounds it"},
Expand Down
37 changes: 37 additions & 0 deletions app/tests/test_longmemeval_setups.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ def test_the_setups_are_the_papers(self):
self.assertEqual(defaults, {"retriever": "full-history-session", "topk": "1000", "reading": "con", "separate_notes": "false",
"history_format": "json", "useronly": "false", "merge_key_expansion": "none"})

def test_generation_limit_validation_and_scope(self):
for setup in ("original", "model"):
for length in ("upstream", "1", "4096"):
vals, bad = definitions.bench_options_of(BENCH, "longmemeval_s", {"gen_length": length}, setup)
self.assertEqual(bad, [])
self.assertEqual(vals["gen_length"], length)
for length in ("0", "-1", "1.5", "", "4096x"):
_, bad = definitions.bench_options_of(BENCH, "longmemeval_s", {"gen_length": length}, setup)
self.assertTrue(bad, length)
vals, _ = definitions.bench_options_of(BENCH, "longmemeval_s", {}, "yours")
self.assertNotIn("gen_length", vals)

def test_the_memory_path_keeps_its_meaning(self):
"""Reading is shared; retrieval and separate notes belong to Original."""
for setup in ("original", "model", "yours"):
Expand Down Expand Up @@ -194,9 +206,24 @@ def test_the_original_runs_run_generation_as_the_script_does_and_scores_with_eva
self.assertEqual(pairs["--openai_base_url"], "http://relay/v1")
self.assertEqual(pairs["--openai_key"], "placeholder")
self.assertEqual(argv[-2:], ["--cot", "true"])
self.assertNotIn("--gen_length", argv)
self.assertTrue(got[1]["passed"], got[1])
self.assertEqual(got[1]["detail"]["asked_as"], "gpt-4o-2024-08-06")

def test_explicit_generation_limit_reaches_upstream_and_score_provenance(self):
judge = {"model": "chosen-judge", "base_url": "http://judge/v1", "key": "k"}
for setup in ("original", "model"):
got = self.run_driver([
{"op": "answer", "unit": "q1", "setup": setup, "model": "gpt-4o",
"base_url": "http://relay/v1", "key": "k"},
{"op": "score", "unit": "q1", "setup": setup, "transcript": [],
"answer": "", "judge": judge}], {"gen_length": "4096"})
self.assertNotIn("error", got[0], got[0])
argv = json.loads(got[0]["answer"])
self.assertEqual(argv[-2:], ["--gen_length", "4096"])
self.assertEqual(got[1]["detail"]["options"]["gen_length"], "4096")
self.assertEqual(got[1]["detail"]["judge"], "chosen-judge")

def test_direct_reading_reaches_original_even_with_separate_notes_selected(self):
got = self.run_driver([{"op": "answer", "unit": "q1", "setup": "original", "model": "gpt-4o",
"base_url": "u", "key": "k"}],
Expand Down Expand Up @@ -337,6 +364,16 @@ def test_every_flag_of_run_generation_and_run_retrieval_has_a_row(self):
if path[1] == "generation":
self.assertEqual({f for f in flags if f not in recorded}, set())

def test_pinned_reader_supports_length_but_judge_keeps_ten(self):
source = self.script("src", "generation", "run_generation.py")
self.assertIn("parser.add_argument('--gen_length', type=int, default=None)", source)
self.assertIn("gen_length = args.gen_length", source)
self.assertIn("gen_length = 500 if not args.cot else 800", source)
self.assertIn("max_retrieval_length = model_max_length - gen_length - 1000", source)
self.assertIn("'max_tokens': gen_length", source)
judge = self.script("src", "evaluation", "evaluate_qa.py")
self.assertIn("'max_tokens': 10", judge)

def test_every_offered_value_is_a_script_alias(self):
sh = self.script("src", "generation", "run_generation.sh")
for v in BENCH["options"]["retriever"]["values"]:
Expand Down
7 changes: 5 additions & 2 deletions docs/benchmarks/supported/longmemeval.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ Long-term chat memory: questions over timestamped chat histories.

| Version | Setups as published, whose model | Options |
|---|---|---|
| `longmemeval` | Original · Original memory · Like the paper or Any of your choice | `expansion_join`, `history_format`, `merge_key_expansion`, `question_type`, `reading`, `retriever`, `separate_notes`, `session_expansion`, `topk`, `turn_expansion`, `useronly` |
| `longmemeval` | Original · Original memory · Like the paper or Any of your choice | `expansion_join`, `gen_length`, `history_format`, `merge_key_expansion`, `question_type`, `reading`, `retriever`, `separate_notes`, `session_expansion`, `topk`, `turn_expansion`, `useronly` |

## Options

| Option | Values, default in bold | What it sets | Setups |
|---|---|---|---|
| `expansion_join` | **`separate`**, `split-separate`, `merge`, `split-merge`, `replace`, `split-replace` | How cached expansions join retrieval keys when expansion is enabled: separate keys, merged text or replacement text. Split modes separate sentences or phrases first. | `original`, `model` |
| `gen_length` | e.g. `4096`, default `upstream` | Reader output limit; larger values leave less room for history. | `original`, `model` |
| `history_format` | **`json`**, `nl` | Whether conversation history is shown to the model as JSON or as lines of text labelled by speaker. | `original`, `model` |
| `merge_key_expansion` | **`none`**, `merge`, `replace` | Whether retrieved conversations are shown in full, replaced by their user text, or combined with that text. | `original`, `model` |
| `question_type` | **`all`**, `knowledge-update`, `temporal-reasoning`, `multi-session`, `single-session-user`, `single-session-assistant`, `single-session-preference` | Which memory ability the run measures: every question, or only the questions of one type. | `original`, `model`, `yours` |
Expand Down Expand Up @@ -78,7 +79,9 @@ Long-term chat memory: questions over timestamped chat histories.

- Scores compare with the paper only with its reader, GPT-4o or GPT-4o-mini, and its judge, GPT-4o.
- A reader you choose must take about 126,200 tokens. The history is not cut to fit, so a longer recall fails at the model.
- An empty reply from the reader fails the question.
- Original memory defaults to 800 reader output tokens. Larger limits reduce history space and differ from the paper.
- Empty answers fail, including when reasoning consumes the reader's output budget.
- Choose a judge that can return yes/no text within 10 output tokens.
- Three combinations fail as published: merge expansion with a full-history retriever, user-only with flat-bm25-turn, and separate notes with chain-of-note reading and nl history.
- The judge, a model, rejects about one right answer in twenty, and passes an empty answer now and then.
- Time-aware query expansion fails as published.
Expand Down