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
34 changes: 32 additions & 2 deletions app/nullius/catalogue/benchmarks/locomo/benchmark.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"What goes into the memory is an option: the conversation itself by default, or the authors' released facts or session summaries."
],
"upstream_limitations": [
"The 446 adversarial questions are left out, because the published file has no answer for them. 1,540 of the 1,986 questions remain.",
"The 446 adversarial questions are left out, because the published code cannot ask or score them. 1,540 of the 1,986 questions remain. The experiment version, full, includes them.",
"The reader's model name must contain gpt-4 or gpt-3.5, as LoCoMo's own code requires. Any other model fails every question.",
"OpenAI has retired gpt-4-turbo and gpt-3.5-turbo, so Original cannot run Like the paper. Choose Any of your choice; its scores do not compare with the paper's.",
"The reader gets 32 tokens per answer. A reasoning model can spend them all reasoning, and that question fails.",
Expand Down Expand Up @@ -54,5 +54,35 @@
"label": "Expected answer",
"path": "reference"
}
]
],
"versions": {
"full": {
"good_to_know": [
"Each conversation is one task, with its questions inside. The smallest run is one conversation.",
"The score is the mean over the 1,986 questions: token F1, or for the 446 adversarial ones, 1 when the answer says the conversation does not mention it. Compare it with runs of this version only.",
"What goes into the memory is an option: the conversation itself by default, or the authors' released facts or session summaries."
],
"upstream_limitations": [
"An adversarial question is a choice between its false answer and \"Not mentioned in the conversation\". A refusal in other words counts as wrong.",
"At least one adversarial question is answered in the conversation (conv-26, Caroline's hand-painted bowl; LoCoMo's issue 43). The right answer counts as wrong.",
"Original draws the order of the two choices at random, so it can differ from run to run.",
"The reader's model name must contain gpt-4 or gpt-3.5, as LoCoMo's own code requires. Any other model fails every question.",
"OpenAI has retired gpt-4-turbo and gpt-3.5-turbo, so Original cannot run Like the paper. Choose Any of your choice; its scores do not compare with the paper's.",
"The reader gets 32 tokens per answer. A reasoning model can spend them all reasoning, and that question fails.",
"One unreadable reply stops the whole conversation, because LoCoMo's script writes its answers only at the end.",
"Original memory runs the paper's retrieval setup and needs a CUDA GPU. It writes facts and summaries anew each run, so they differ from the authors' released ones.",
"Contriever, LoCoMo's default retriever, and the OpenAI retriever fail as published, so they are not offered.",
"Claude 3 Sonnet and Gemini 1.0 Pro, also readers in the paper, are retired and not offered."
],
"limitations": [
"With a memory, the order of an adversarial question's two choices is fixed by the question, so every memory is asked the same.",
"The paper's Llama 2 70B, Llama 3 70B and Mistral 7B v0.2 readers are not offered: LoCoMo runs them as local weights, which Nullius does not serve."
],
"datasets": {
"locomo10": {
"verifier": "LoCoMo's own task_eval/evaluate_qa.py: the token F1 of each answer against the reference, or the right choice for an adversarial question; no judge model."
}
}
}
}
}
75 changes: 52 additions & 23 deletions app/nullius/catalogue/benchmarks/locomo/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
modules import torch, bert_score and the vendors' clients, so the driver runs
in the environment of its own that standard.json declares (driver.install).

units - every question of categories 1 to 4, as <sample_id>:<n> (the
adversarial category 5 has no reference answer in the file)
units - every question of categories 1 to 4, as <sample_id>:<n>: the
published code cannot ask or score the adversarial category 5, whose
records have no "answer". The version "full", whose
upstream reads their "adversarial_answer", has them too
setup - the question's conversation, a session at a time, for ``add``;
the question, for ``recall``
produce - LoCoMo's reader prompt over what the memory recalled, as its RAG
Expand All @@ -27,14 +29,19 @@
connection and unavailable errors without end (a rate limit with
no wait), and a reply with no text fails the question. The run's
turn_seconds bounds it: past them the question is the reader's
error and the driver is started again for the next
error and the driver is started again for the next. A category-5
question is a choice between its false answer and "Not mentioned in
the conversation", in get_gpt_answers' words and QA_PROMPT_CAT_5, its
reply read by get_cat_5_answer; which comes first is drawn from the
unit's id, so every memory is asked the same
score - LoCoMo's own eval_question_answering (task_eval/evaluation.py) on
the one question: token F1 with its normalisation and Porter
stemming, category 1 by comma-separated parts, category 3 against
the reference's part before the first ";"
the reference's part before the first ";", category 5 whether it
says the conversation does not mention it
answer - a setup's (original, model): LoCoMo's own task_eval/evaluate_qa.py,
run as published on the one conversation - its questions of
categories 1 to 4, as its scripts feed it - with --model
run as published on the one conversation - the version's
questions, as its scripts feed it - with --model
the model the setup asks as and --batch-size as the paper's
scripts give it (20 for gpt-4-turbo, 10 for the gpt-3.5-turbo
windows); its openai 0.28 client pointed at the relay through
Expand All @@ -53,13 +60,15 @@
scorer reads it - for category 3, its first part (``gold``): there
the field can carry the authors' reasoning after a ";", which
LoCoMo's evaluation cuts off before scoring, so the whole field
would lose F1 on its own words
would lose F1 on its own words; for category 5, "Not mentioned in
the conversation", the choice the scorer looks for
"""
import ast
import contextlib
import inspect
import json
import os
import random
import subprocess
import sys
import textwrap
Expand All @@ -70,6 +79,7 @@
import openai # noqa: E402 0.28, the client run_chatgpt is written for

DATA = {}
CATEGORIES = (1, 2, 3, 4, 5) if os.environ.get("NULLIUS_VERSION") == "full" else (1, 2, 3, 4)


def load():
Expand All @@ -90,7 +100,7 @@ def units(dataset, setup=None):
return {"units": list(load())}
out = []
for sid, conv in load().items():
out += [f"{sid}:{i}" for i, q in enumerate(conv["qa"]) if q.get("category") in (1, 2, 3, 4)]
out += [f"{sid}:{i}" for i, q in enumerate(conv["qa"]) if q.get("category") in CATEGORIES]
return {"units": out}


Expand Down Expand Up @@ -126,41 +136,60 @@ def setup(unit, dir):
return {"memory": {"add": sessions(conv), "recall": [{"id": unit, "question": q["question"]}]}}


def date_hint():
"""The words LoCoMo's reader adds to a category-2 question. They have no
name of their own in the upstream: they are read from get_gpt_answers'
source, through the imported module, at the tested commit."""
def reader_words(category):
"""The words LoCoMo's reader adds to a question of ``category``, and, for 5,
the choice it offers beside the false answer. They have no name of their own
in the upstream: they are read from get_gpt_answers' source, through the
imported module, at the tested commit."""
tree = ast.parse(textwrap.dedent(inspect.getsource(gpt_utils.get_gpt_answers)))
for node in ast.walk(tree):
if isinstance(node, ast.If) and ast.unparse(node.test).replace('"', "'") == "qa['category'] == 2":
for sub in ast.walk(node.body[0]):
if isinstance(sub, ast.BinOp) and isinstance(sub.right, ast.Constant) and isinstance(sub.right.value, str):
return sub.right.value
raise RuntimeError("LoCoMo's get_gpt_answers no longer adds a date hint to a category-2 question")
if isinstance(node, ast.If) and ast.unparse(node.test).replace('"', "'") == f"qa['category'] == {category}":
found = list(ast.walk(ast.Module(node.body, [])))
added = [n.right.value for n in found if isinstance(n, ast.BinOp) and isinstance(n.right, ast.Constant)
and isinstance(n.right.value, str)]
offered = [x.value for n in found if isinstance(n, ast.Call) and ast.unparse(n.func) == "question.format"
for x in n.args if isinstance(x, ast.Constant)]
if added and (category != 5 or offered):
return added[0], next(iter(offered), "")
raise RuntimeError(f"LoCoMo's get_gpt_answers no longer words a category-{category} question as it did")


HINT = date_hint()
HINT, _ = reader_words(2)
CHOICE, UNMENTIONED = reader_words(5) if 5 in CATEGORIES else ("", "")


def produce(unit, dir, recalled, model, base_url, key):
_, q = question(unit)
memory = recalled[0]["memory"] if recalled else ""
asked = q["question"] + (HINT if q["category"] == 2 else "")
query = (memory or "(nothing recalled)") + "\n\n" + gpt_utils.QA_PROMPT.format(asked)
prompt, choices = gpt_utils.QA_PROMPT, {}
if q["category"] == 5:
pair = [UNMENTIONED, q["adversarial_answer"]]
if random.Random(unit).random() >= 0.5:
pair.reverse()
prompt, choices, asked = gpt_utils.QA_PROMPT_CAT_5, dict(zip("ab", pair)), q["question"] + CHOICE.format(*pair)
query = (memory or "(nothing recalled)") + "\n\n" + prompt.format(asked)
openai.api_base, openai.api_key = base_url, key
with contextlib.redirect_stdout(sys.stderr):
# get_gpt_answers' own call for one question (batch size 1, as its RAG mode asks)
answer = gpt_utils.run_chatgpt(query, num_gen=1, num_tokens_request=32,
model='chatgpt' if 'gpt-3.5' in model else model,
use_16k=True if any([k in model for k in ['16k', '12k', '8k', '4k']]) else False,
temperature=0, wait_time=2)
if choices:
answer = gpt_utils.get_cat_5_answer(answer, choices)
return {"answer": answer.strip()}


def reference(q):
"""The question's reference, as its record shows it."""
return UNMENTIONED if q["category"] == 5 else q["answer"]


def gold(q):
"""The reference as LoCoMo's evaluation scores against it: the answer
field, for category 3 only its part before the first ";"."""
ref = str(q["answer"])
ref = str(reference(q))
return ref.split(";")[0].strip() if q["category"] == 3 else ref


Expand Down Expand Up @@ -200,7 +229,7 @@ def upstream(script, argv, dir, env):

def answer(unit, dir, setup, model, base_url, key):
conv = load()[unit]
fed = dict(conv, qa=[q for q in conv["qa"] if q.get("category") in (1, 2, 3, 4)])
fed = dict(conv, qa=[q for q in conv["qa"] if q.get("category") in CATEGORIES])
asked = os.path.join(dir, ASKED)
with open(asked, "w") as f:
json.dump([fed], f)
Expand Down Expand Up @@ -243,14 +272,14 @@ def score(unit, dir, transcript, answer, setup=None, **_):
for i, q in enumerate(qa) if isinstance(q.get(f"{k}_f1"), (int, float))]}
return {"reward": sum(got) / len(got) if got else 0.0, **({"parts": parts} if got else {}),
"detail": dict({"questions": len(qa), "scored": len(got), "model": model,
"per_question": [dict({"question": q["question"], "reference": q["answer"], "category": q["category"],
"per_question": [dict({"question": q["question"], "reference": reference(q), "category": q["category"],
"answer": q.get(f"{k}_prediction"), "f1": q.get(f"{k}_f1")},
**({"retrieved": q.get(f"{k}_prediction_context"), "recall": q.get(f"{k}_recall")} if rag else {}))
for q in qa]}, **rag)}
_, q = question(unit)
with contextlib.redirect_stdout(sys.stderr):
values, _, _ = evaluation.eval_question_answering([dict(q, prediction=answer or "")], "prediction")
return {"reward": float(values[0]), "detail": {"question": q["question"], "reference": q["answer"], "category": q["category"],
return {"reward": float(values[0]), "detail": {"question": q["question"], "reference": reference(q), "category": q["category"],
"answer": answer, "evidence": q.get("evidence")}}


Expand Down
59 changes: 56 additions & 3 deletions app/nullius/catalogue/benchmarks/locomo/proofs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"kind": "benchmark",
"key": "locomo",
"versions": {
"": {
"3eb6f2c": {
"proven": {
"locomo10": {
"units": {
Expand Down Expand Up @@ -31,15 +31,68 @@
"expect": {
"at_most": 0.0
},
"units": 1540
"units": 1540,
"options": {
"rag_mode": "dialog"
}
},
"oracle": {
"passed": "1540/1540",
"value": 1.0,
"expect": {
"at_least": 1.0
},
"units": 1540
"units": 1540,
"options": {
"rag_mode": "dialog"
}
}
}
}
},
"full": {
"proven": {
"locomo10": {
"units": {
"units": 1986,
"passed": "1986 ids, the same twice, unique"
},
"leak": {
"units": 1986,
"looked_for": 1590,
"short": 396,
"passed": "1986/1986",
"in_prompt": {
"units": 2,
"first": [
"conv-49:10",
"conv-50:39"
],
"why": "A comparison question names its answer among the options it offers ('A or B?'), with the other option beside it."
},
"note": "396 reference(s) under 12 characters not looked for: too short to tell a leak from chance; 2 prompt(s) name their answer, as the benchmark says they may: A comparison question names its answer among the options it offers ('A or B?'), with the other option beside it."
},
"nop": {
"passed": "0/1986",
"value": 0.0,
"expect": {
"at_most": 0.0
},
"units": 1986,
"options": {
"rag_mode": "dialog"
}
},
"oracle": {
"passed": "1986/1986",
"value": 1.0,
"expect": {
"at_least": 1.0
},
"units": 1986,
"options": {
"rag_mode": "dialog"
}
}
}
}
Expand Down
46 changes: 45 additions & 1 deletion app/nullius/catalogue/benchmarks/locomo/standard.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
},
"setups": {
"original": {
"summary": "LoCoMo's question answering as the paper ran it: its own task_eval/evaluate_qa.py on a whole conversation - the conversation in the prompt, cut to the reader's window, its questions 20 a call (10 for the gpt-3.5-turbo windows), or, with retrieval, the top-k of a database its own code builds, one question a call, as its RAG rows ran with gpt-3.5-turbo - its prompts, temperature 0 and token budget, scored by its own eval_question_answering, the mean token F1 over the conversation's questions of categories 1 to 4.",
"summary": "LoCoMo's question answering as the paper ran it: its own task_eval/evaluate_qa.py on a whole conversation - the conversation in the prompt, cut to the reader's window, its questions 20 a call (10 for the gpt-3.5-turbo windows), or, with retrieval, the top-k of a database its own code builds, one question a call, as its RAG rows ran with gpt-3.5-turbo - its prompts, temperature 0 and token budget, scored by its own eval_question_answering, the mean over the conversation's questions.",
"models": [
"gpt-4-turbo",
"gpt-3.5-turbo",
Expand Down Expand Up @@ -216,5 +216,49 @@
"summary": "The same pipeline with any model in the reader's place: LoCoMo's code asks for gpt-4-turbo - its 128k window, 20 questions a call, its token budget - and the relay sends the model chosen; with retrieval, the observations and summaries its code writes are asked of the model chosen too. Its scores compare with other runs of this setup, not with the paper.",
"runs_as": "gpt-4-turbo"
}
},
"default": "3eb6f2c",
"versions": {
"3eb6f2c": {
"upstream": {
"branch": "main"
}
},
"full": {
"upstream": {
"repository": "https://github.com/aitianshi/locomo",
"branch": "full",
"tested": "66d303a5505b5a26b211e7542ad5dc582033239d",
"tested_date": "2026-11-25",
"origin": "experiment",
"fixes": [
"The 446 adversarial questions are asked and scored too, 1,986 in all, with LoCoMo's open pull request #41 (https://github.com/snap-research/locomo/pull/41)."
]
},
"datasets": [
{
"id": "locomo10",
"label": "LoCoMo-10",
"path": "data/locomo10.json",
"sha256": "79fa87e90f04081343b8c8debecb80a9a6842b76a7aa537dc9fdf651ea698ff4",
"units": 1986
}
],
"controls": {
"nop": {
"source": "nullius",
"from": "Nullius: no capability runs and nothing is recalled; the answer is empty."
},
"oracle": {
"source": "nullius",
"from": "Nullius, from the authors' answers: the question's answer field in the authors' locomo10.json, as their evaluation scores against it (task_eval/evaluation.py): for a category-3 question, the part before the first ';' - in 11 of them the field goes on with the authors' reasoning, which their scorer cuts off. For a category-5 question, 'Not mentioned in the conversation', the choice their scorer looks for. Given to the scorer as the answer.",
"in_prompt": "A comparison question names its answer among the options it offers ('A or B?'), with the other option beside it."
}
},
"score": {
"kind": "score",
"says": "token F1 of the answer against the reference, by LoCoMo's own eval_question_answering (task_eval/evaluation.py), category 5 scored 1 when the answer says it is not mentioned, else 0: its normalisation and Porter stemming, category 1 by comma-separated parts, category 3 against the reference's part before the first ';' (categories 1 to 5)"
}
}
}
}
Loading