Skip to content

Commit 7f1bc29

Browse files
authored
fix(catalogue): expose LongMemEval reader generation limit (#283)
Expose the pinned LongMemEval reader's existing `--gen_length` as `gen_length` (Reader output tokens) for Original/model setups. Omit the flag by default, preserve the upstream pin, pass explicit values unchanged, and record the choice in score details. This is a supported upstream option, not a patch or a replacement reader.
1 parent f226eba commit 7f1bc29

6 files changed

Lines changed: 62 additions & 5 deletions

File tree

‎app/nullius/catalogue/benchmarks/longmemeval/benchmark.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"upstream_limitations": [
1818
"Scores compare with the paper only with its reader, GPT-4o or GPT-4o-mini, and its judge, GPT-4o.",
1919
"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.",
20-
"An empty reply from the reader fails the question.",
20+
"Original memory defaults to 800 reader output tokens. Larger limits reduce history space and differ from the paper.",
21+
"Empty answers fail, including when reasoning consumes the reader's output budget.",
22+
"Choose a judge that can return yes/no text within 10 output tokens.",
2123
"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.",
2224
"The judge, a model, rejects about one right answer in twenty, and passes an empty answer now and then.",
2325
"Time-aware query expansion fails as published."

‎app/nullius/catalogue/benchmarks/longmemeval/driver.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ def answer(unit, dir, setup, model, base_url, key, judge=None, simulator=None, a
334334
"--retriever_type", retriever_type, "--topk_context", _opt("topk", "1000"),
335335
"--merge_key_expansion_into_value", _opt("merge_key_expansion", "none"),
336336
"--history_format", _opt("history_format", "json"), "--useronly", _opt("useronly", "false")] + flags.split()
337+
# The pinned Python entry point supports this flag; omission preserves its defaults.
338+
length = _opt("gen_length", "upstream")
339+
if length != "upstream":
340+
argv += ["--gen_length", length]
337341
log = os.path.join(dir, "run_generation.log")
338342
_run(argv, os.path.join(up, "src", "generation"), env, log, "run_generation.py")
339343
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()]
@@ -366,7 +370,7 @@ def score_setup(unit, dir, judge):
366370
"options": {n: _opt(n, d) for n, d in (("retriever", "full-history-session"), ("topk", "1000"),
367371
("reading", "con"), ("separate_notes", "false"), ("history_format", "json"), ("useronly", "false"),
368372
("merge_key_expansion", "none"), ("session_expansion", "none"), ("turn_expansion", "none"),
369-
("expansion_join", "separate"))}}}
373+
("expansion_join", "separate"), ("gen_length", "upstream"))}}}
370374

371375

372376
HANDLERS = {"units": units, "setup": setup, "produce": produce, "score": score, "oracle": oracle, "answer": answer}

‎app/nullius/catalogue/benchmarks/longmemeval/standard.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,17 @@
264264
"model"
265265
]
266266
},
267+
"gen_length": {
268+
"label": "Reader output tokens",
269+
"summary": "Reader output limit; larger values leave less room for history.",
270+
"pattern": "(?:upstream|[1-9][0-9]*)",
271+
"example": "4096",
272+
"default": "upstream",
273+
"setups": [
274+
"original",
275+
"model"
276+
]
277+
},
267278
"separate_notes": {
268279
"label": "Separate notes",
269280
"summary": "Write a separate note for each retrieved session or turn before reasoning. Original memory only.",

‎app/nullius/catalogue/benchmarks/longmemeval/upstream-settings.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{"entry": "src/generation/run_generation.py", "setting": "--con", "values": "true, false", "default": "false", "nullius": "option:separate_notes"},
3535
{"entry": "src/generation/run_generation.py", "setting": "--cot", "values": "true, false", "default": "required", "nullius": "option:reading"},
3636
{"entry": "src/generation/run_generation.py", "setting": "--merge_key_expansion_into_value", "values": "merge, replace, none", "default": "none", "nullius": "option:merge_key_expansion"},
37-
{"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"},
37+
{"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"},
3838
{"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"},
3939
{"entry": "src/generation/run_generation.py", "setting": "temperature, n", "values": "0, 1", "default": "", "nullius": "fixed:0, 1 - as published"},
4040
{"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"},

‎app/tests/test_longmemeval_setups.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ def test_the_setups_are_the_papers(self):
6464
self.assertEqual(defaults, {"retriever": "full-history-session", "topk": "1000", "reading": "con", "separate_notes": "false",
6565
"history_format": "json", "useronly": "false", "merge_key_expansion": "none"})
6666

67+
def test_generation_limit_validation_and_scope(self):
68+
for setup in ("original", "model"):
69+
for length in ("upstream", "1", "4096"):
70+
vals, bad = definitions.bench_options_of(BENCH, "longmemeval_s", {"gen_length": length}, setup)
71+
self.assertEqual(bad, [])
72+
self.assertEqual(vals["gen_length"], length)
73+
for length in ("0", "-1", "1.5", "", "4096x"):
74+
_, bad = definitions.bench_options_of(BENCH, "longmemeval_s", {"gen_length": length}, setup)
75+
self.assertTrue(bad, length)
76+
vals, _ = definitions.bench_options_of(BENCH, "longmemeval_s", {}, "yours")
77+
self.assertNotIn("gen_length", vals)
78+
6779
def test_the_memory_path_keeps_its_meaning(self):
6880
"""Reading is shared; retrieval and separate notes belong to Original."""
6981
for setup in ("original", "model", "yours"):
@@ -194,9 +206,24 @@ def test_the_original_runs_run_generation_as_the_script_does_and_scores_with_eva
194206
self.assertEqual(pairs["--openai_base_url"], "http://relay/v1")
195207
self.assertEqual(pairs["--openai_key"], "placeholder")
196208
self.assertEqual(argv[-2:], ["--cot", "true"])
209+
self.assertNotIn("--gen_length", argv)
197210
self.assertTrue(got[1]["passed"], got[1])
198211
self.assertEqual(got[1]["detail"]["asked_as"], "gpt-4o-2024-08-06")
199212

213+
def test_explicit_generation_limit_reaches_upstream_and_score_provenance(self):
214+
judge = {"model": "chosen-judge", "base_url": "http://judge/v1", "key": "k"}
215+
for setup in ("original", "model"):
216+
got = self.run_driver([
217+
{"op": "answer", "unit": "q1", "setup": setup, "model": "gpt-4o",
218+
"base_url": "http://relay/v1", "key": "k"},
219+
{"op": "score", "unit": "q1", "setup": setup, "transcript": [],
220+
"answer": "", "judge": judge}], {"gen_length": "4096"})
221+
self.assertNotIn("error", got[0], got[0])
222+
argv = json.loads(got[0]["answer"])
223+
self.assertEqual(argv[-2:], ["--gen_length", "4096"])
224+
self.assertEqual(got[1]["detail"]["options"]["gen_length"], "4096")
225+
self.assertEqual(got[1]["detail"]["judge"], "chosen-judge")
226+
200227
def test_direct_reading_reaches_original_even_with_separate_notes_selected(self):
201228
got = self.run_driver([{"op": "answer", "unit": "q1", "setup": "original", "model": "gpt-4o",
202229
"base_url": "u", "key": "k"}],
@@ -337,6 +364,16 @@ def test_every_flag_of_run_generation_and_run_retrieval_has_a_row(self):
337364
if path[1] == "generation":
338365
self.assertEqual({f for f in flags if f not in recorded}, set())
339366

367+
def test_pinned_reader_supports_length_but_judge_keeps_ten(self):
368+
source = self.script("src", "generation", "run_generation.py")
369+
self.assertIn("parser.add_argument('--gen_length', type=int, default=None)", source)
370+
self.assertIn("gen_length = args.gen_length", source)
371+
self.assertIn("gen_length = 500 if not args.cot else 800", source)
372+
self.assertIn("max_retrieval_length = model_max_length - gen_length - 1000", source)
373+
self.assertIn("'max_tokens': gen_length", source)
374+
judge = self.script("src", "evaluation", "evaluate_qa.py")
375+
self.assertIn("'max_tokens': 10", judge)
376+
340377
def test_every_offered_value_is_a_script_alias(self):
341378
sh = self.script("src", "generation", "run_generation.sh")
342379
for v in BENCH["options"]["retriever"]["values"]:

‎docs/benchmarks/supported/longmemeval.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ Long-term chat memory: questions over timestamped chat histories.
3434

3535
| Version | Setups as published, whose model | Options |
3636
|---|---|---|
37-
| `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` |
37+
| `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` |
3838

3939
## Options
4040

4141
| Option | Values, default in bold | What it sets | Setups |
4242
|---|---|---|---|
4343
| `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` |
44+
| `gen_length` | e.g. `4096`, default `upstream` | Reader output limit; larger values leave less room for history. | `original`, `model` |
4445
| `history_format` | **`json`**, `nl` | Whether conversation history is shown to the model as JSON or as lines of text labelled by speaker. | `original`, `model` |
4546
| `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` |
4647
| `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` |
@@ -78,7 +79,9 @@ Long-term chat memory: questions over timestamped chat histories.
7879

7980
- Scores compare with the paper only with its reader, GPT-4o or GPT-4o-mini, and its judge, GPT-4o.
8081
- 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.
81-
- An empty reply from the reader fails the question.
82+
- Original memory defaults to 800 reader output tokens. Larger limits reduce history space and differ from the paper.
83+
- Empty answers fail, including when reasoning consumes the reader's output budget.
84+
- Choose a judge that can return yes/no text within 10 output tokens.
8285
- 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.
8386
- The judge, a model, rejects about one right answer in twenty, and passes an empty answer now and then.
8487
- Time-aware query expansion fails as published.

0 commit comments

Comments
 (0)