Repository navigation
feat(memory): add optional Jev reranking and comparison - #2005
Conversation
Add bounded native System One scoring with coarse-order fallback and usage accounting. Preserve Atomic Memory identity, authorization, read-only preparation, and delivery budgets. Include matched three-arm evaluation, bilingual smoke inputs, and reproducible evidence limits. Refs oceanbase#1937 (restores oceanbase#1643). Validation: 205 related tests passed, 3 OceanBase cases skipped; make check passed. Live Jev comparison and OceanBase acceptance require deployment credentials.
hireview001
left a comment
There was a problem hiding this comment.
- CI failed: controlled-cli (failure).
- CI failed: ZCode acceptance (failure). Failed steps: controlled-cli / Run two independent controlled CLI acceptances.
|
Is ready to review ? |
Resolve comparison identities through the same provider used by answer and judge inference, including environment-derived endpoints and provider defaults. Close the inspection client before execution. Add endpoint-drift regression coverage and run Jev integration in the real OceanBase CI job without skipped cases.
hidb4ai
left a comment
There was a problem hiding this comment.
Two evaluation correctness issues remain at 2392a670: incomplete billing can pass the adoption gate, and resumed runs do not pin the independent LLM reranker's effective endpoint. Details inline.
| ( | ||
| jev_config.endpoint | ||
| if jev_config is not None | ||
| else str(settings.inference.rerank_base_url or settings.inference.generation_base_url) |
There was a problem hiding this comment.
[P2] Fingerprint the resolved independent reranker endpoint
With generation_model="openai:test-chat", rerank_model="anthropic:test-rerank", and both explicit base URLs unset, changing only ANTHROPIC_BASE_URL from service A to service B changes the actual reranker endpoint but leaves this hash at sha256("None"). I reproduced prepare_run() accepting the same output directory after that change with an identical manifest. The downstream fingerprint stays unchanged because the answer/judge provider is still OpenAI. Resuming can therefore mix baseline results from different services without invalidating the comparison. Resolve and fingerprint the provider endpoint actually used by the independent LLM reranker, including environment values and defaults, before accepting a resumed run.
There was a problem hiding this comment.
独立复核确认该问题在 head 2392a6703a747e20a65da61779eba5c2f276e4de 仍然存在,而且与同一 PR 已经修好的同类问题形成了不对称。
evaluation/memory/locomo/runner.py现在对 generation 端点走的是解析后的值:async with infer_model(settings.inference.generation_model) as downstream_model: downstream_base_url = downstream_model.base_url(infer_model来自pydantic_ai.models,会带上 provider 的环境默认端点)。- 但同一个 manifest 里的
comparison_reranker.endpoint_sha256仍取settings.inference.rerank_base_url or settings.inference.generation_base_url。这两个都是InferenceSettings的普通配置字段(src/powercontext/builtin/runtime/config.py:312为rerank_base_url: AnyHttpUrl | None = None),不包含 provider 环境变量的解析结果;composition.py:1452是把该配置值直接交给 reranker provider,取值为None时由 provider 自身的环境默认值兜底。 - 因此在
rerank_model指向另一个 provider(例如anthropic:...)、且未显式配置rerank_base_url时,只改该 provider 的环境变量(ANTHROPIC_BASE_URL)就会改变真实 reranker 端点,而指纹恒为sha256("None"),prepare_run()会接受同一输出目录、比较也会放过这次漂移;同一头部的 generation 端点却会因downstream_base_url变化而被拒绝。
建议对 reranker 也走解析路径(与 generation 对称,取 provider 解析后的 base_url),而不是读取原始设置字段;comparison_reranker.model 若与 generation 模型相同,也应避免同一事实在 manifest 里出现两个不同来源。
hidb4ai
left a comment
There was a problem hiding this comment.
Two non-blocking design notes: distinguish reusable test fixtures from one-off execution records, and keep the evaluation workflow reusable across reranker implementations. The existing MemoryReranker injection boundary is already provider-neutral.
| ) -> dict[str, Any]: | ||
| """Reject changed inputs, then report each run on the same question denominator.""" | ||
|
|
||
| if set(runs) != {"none", "llm", "jev"}: |
There was a problem hiding this comment.
Design note (non-blocking): Keep reranker comparison independent of Jev
The comparator requires exactly none, llm, and jev, and the quality/adoption logic below also names Jev directly. I verified that our real none/llm pair is rejected with comparison requires none, llm, and jev runs. This makes the shared comparison workflow require a Jev arm even when evaluating another candidate or only the existing baseline. Consider accepting named runs with explicit baseline/candidate selections and per-run pricing. Keep Jev's protocol, model pinning, and credentials in its adapter, and vendor selection in the evaluation composition layer rather than adding a core MemoryRerankMode member for each provider. The existing MemoryReranker interface is sufficient; a new provider framework is unnecessary.
|
@Oxidaner The billing-completeness and independent-reranker endpoint issues are fixed in the current head (
These remain non-blocking design notes. Please implement them or explain the rationale for retaining the current choices in the respective threads, and resolve the two fixed P2 threads. |
|
@Oxidaner This PR is now blocked by a merge conflict with Please update the branch and resolve the conflict while preserving both master's new The two earlier non-blocking design notes also remain open: move the one-off hosted-run snapshot out of the source tree, and make the comparison usable without a mandatory Jev arm. Please address them or explain the rationale for retaining the current choices in those threads. The two P2 correctness fixes are already present; please mark those threads as resolved as well. |
|
@Oxidaner Please update this PR and share an expected timeline. The branch is still at Please sync with the latest Please also respond to the two remaining non-blocking design notes—moving the one-off execution snapshot and making comparisons work without a mandatory Jev arm—either with changes or a rationale in the respective threads. The two fixed P2 threads can be marked resolved. If anything is blocking progress, please let us know. |
|
Jev 记忆重排评测报告 结论**建议继续作为可选适配器评估,不建议凭现有数据宣布 Jev 提高了最终答题准确率或关闭 issue。**在同一段公开 LoCoMo 对话的 16 道预选题中,Jev 的官方标注证据会话召回为 67.9%,高于 Qwen 文本向量的 44.5%;MiniMax 普通重排是 65.0%, 已完成的 12 道 PowerContext 产品链路短题在 MiniMax 生成条件下,三种重排均为 12/12,无法比较准确率提升。Jev 产品阶段耗时的中位数低于普通 MiniMax 重排,p95 反而更高。网络、可能的代理、网关和服务端等待均混在耗时里,不能由此比较模型自身推理速度。 测试设计
Jev 调用 TypeSafe 官方接口固定模型 题目来自公开 LoCoMo 数据集。16 题包括 6 道单会话证据题、8 道 2–3 会话证据题,以及 2 道证据跨 4 或 5 个会话的题。由于只准返回 3 个会话,最后两题不可能召回全部官方标注证据;它们仍计入平均召回,但不能用“全部证据入选”判断重排器是否有效。题目全部来自同一段对话,并非 LoCoMo 全集或跨对话抽样。 公开题:16 道配对证据召回召回 = 所选 3 个会话与官方标注证据会话的交集 / 官方标注证据会话数。每题三组共享问题、19 个候选、会话日期和输出上限。MiniMax 两次批次的冻结数据哈希、候选身份、Jev 回执哈希、模型与预算一致,题号互不重叠;向量组前 8 道在另一次同模型运行中得到完全相同的前三名。
Jev 对向量逐题召回赢 9、输 1、平 6,平均高 23.4 个百分点;对普通 MiniMax 重排赢 2、输 1、平 13,平均高 2.9 个百分点。Jev 对 MiniMax 的三道不同题分别是 公开题:答案核对三组都由同一个 MiniMax-M3 生成并由它判分。模型原始自判为向量 4/16、普通重排 8/16、Jev 6/16;这些数字不能当作准确率: 为核对显而易见的错判,我们另外对其中 11 道事实/日期题列出标准答案中的 29 个必要事实;只有回答覆盖该题全部事实才算通过,允许同义表达和换算明确的相对日期。逐题规则与三组勾选记录已保存。核对结果:向量 2/11(17/29 项事实)、MiniMax 7/11(24/29)、Jev 7/11(23/29)。例如 这个逐项核对由本次评测代理编写,未盲化、没有第二位独立核查者,也没有逐一裁定额外事实是否受所选会话支持。其作用是暴露自判错误和提供可审查依据,不是外部独立验证过的答题准确率。剩余 5 道推断题(例如反事实职业意愿和性格判断)没有并入这组事实题分母。
|
| 原始会话排序 | 全部 16 题平均召回 | 单会话题(6) | 2–3 会话题(8) | 4–5 会话题(2) | 全部证据入选 |
|---|---|---|---|---|---|
| Qwen 文本向量 | 44.5% | 66.7% | 33.3% | 22.5% | 4/16 |
gpt-6-sol 普通重排 |
73.3% | 100.0% | 60.4% | 45.0% | 8/16 |
| Jev | 67.9% | 83.3% | 64.6% | 35.0% | 7/16 |
Jev 对 gpt-6-sol 逐题召回赢 1、输 2、平 13;整体平均低 5.4 个百分点。沿用同一组 11 道事实题、29 项标准答案事实和相同的核对规则,gpt-6-sol 生成的回答核对为:向量 3/11(18/29 项)、gpt-6-sol 普通重排 8/11(26/29 项)、Jev 7/11(23/29 项)。q040 中普通重排回答明确说出加入行动团体,Jev 回答只笼统提及倡议,构成这一分差;q016 三组中后两组都包含标准答案要求的四项活动,却被 gpt-6-sol 自判为错。自判的原始数字为 3/16、6/16、6/16,不能替代逐项核对。同样需要强调:本地核对不盲化,无法建立跨对话的普遍准确率差异。
产品链路:12 道短题
每题检索候选最多 10 条、供回答最多 3 条,完整回答输入最多 4096 UTF-8 字节,三组逐题有序候选摘要全部一致。产品耗时为检索 + 重排 + 回答,排除判分;仅统计成功完成的题。
| 重排 | 完成 / MiniMax 判对 | 产品 p50 | 产品 p95 | 产品阶段官网参考价* |
|---|---|---|---|---|
| 不重排 | 12/12 | 1.799 秒 | 3.500 秒 | $0.00233760 + ¥0.000178 |
| MiniMax | 12/12 | 4.019 秒 | 6.027 秒 | $0.00354402 + ¥0.000178 |
| Jev | 12/12 | 2.130 秒 | 8.504 秒 | $0.002477922 + ¥0.000178 |
* 价格仅含查询向量、重排和回答,排除判分及已存在记忆的提取/重建。美元和人民币不相加。这 12 道自编题已出现三组同时满分的天花板,不能证明 Jev 改善答题质量,也不能代表公开难题上的产品表现。
16 道公开题的价格对比:MiniMax 生成
三组使用同一个 MiniMax-M3 回答模型,每题最多交给它 3 个原始会话。下表统计 16 道题每组各完成一次所对应的成功模型调用参考价。向量组还需支付百炼的文档及查询向量费用;另外两组直接阅读原始文本,没有发生 Qwen 向量调用。判分单列。
| 排序方式 | 重排美元 | 回答美元 | 重排 + 回答美元 | 向量人民币 | 判分美元(另计) |
|---|---|---|---|---|---|
| Qwen 向量 | $0 | $0.01821588 | $0.01821588 | ¥0.0208855 | $0.00155742 |
| MiniMax 普通 LLM | $0.09580188 | $0.01751826 | $0.11332014 | ¥0 | $0.00165072 |
| Jev | $0.01831032 | $0.01661178 | $0.03492210 | ¥0 | $0.00143202 |
平均每题(排除判分):向量组 $0.00113849 + ¥0.00130534,MiniMax 组 $0.00708251,Jev 组 $0.00218263。在这个原始会话诊断里,Jev 的美元重排+回答参考价比 MiniMax 普通重排低约 69.2%;向量组同时使用美元与人民币,未换汇,因此不比较它与 Jev 的总价高低。Jev 与 MiniMax 的证据召回和 11 道事实题结果接近,不能只凭价格选择。
MiniMax 价格按成功回执的普通输入 $0.30/百万、缓存读取 $0.06/百万、输出 $1.20/百万 token 计算。Jev 对这 16 道题的 304 次成功评分共 435,960 输入 token,按 $0.042/百万输入计为表中的 $0.01831032;评分发生在更早的同一冻结题集上,此处计入一次完整成本,没有当成补测时新发的请求。向量组的两批独立运行各自重新嵌入了 19 个文档,连同 16 个问题向量共 41,771 输入 token,按北京地域 ¥0.50/百万 token 换算为表中的 ¥0.0208855。这反映本次两批实际运行;若在一次运行中复用文档向量,向量组成本会下降。判分三组合计 $0.00464016,不在“重排+回答”列中。美元和人民币未相加。
16 道公开题的价格对比:gpt-6-sol 生成
同样是 16 道题、19 个原始会话和三会话回答上限,回答/普通重排/判分均使用 gpt-6-sol。下表美元金额按照OpenAI 官方 gpt-6-sol 标准价及测试接口回执 usage折算,仅供参考;实际接口报价和账户账单未知。
| 排序方式 | 重排美元 | 回答美元 | 重排 + 回答美元 | 向量人民币 | 判分美元(另计) |
|---|---|---|---|---|---|
| Qwen 向量 | $0 | $0.20069960 | $0.20069960 | 复用同一向量基线* | $0.07910000 |
gpt-6-sol 普通重排 |
$0.77049520 | $0.17959200 | $0.95008720 | ¥0 | $0.06077240 |
| Jev | $0.01831032 | $0.17974800 | $0.19805832 | ¥0 | $0.05263160 |
平均每题(排除判分和向量准备):向量组 $0.01254373、gpt-6-sol 普通重排 $0.05938045、Jev $0.01237865。在官网换算价口径下,Jev 的重排+回答比 gpt-6-sol 普通重排低约 79.2%;但后者的标注证据召回 73.3% 高于 Jev 的 67.9%,11 道事实题的本地核对为 8/11 对 7/11。因此这不是“质量相同而费用更低”的证据。
* 向量组使用的 Qwen 排序与 MiniMax 表为同一批已核对的结果;如将两种生成模型分别视为独立方案,须为各自准备向量,参考上表测得的 16 题向量开销 ¥0.0208855。实际追加 gpt-6-sol 测试时,前六题还重复计算了一次文档/问题向量,新增 ¥0.0104195,其余题复用既有向量。这个重复开销是本次测试执行成本,不混进上表模型费用。Jev 对 16 题的 304 次评分也在两张方案表中各展示一次完整重跑所需的成本,实际历史评分只发生一次,不能把两张表的 Jev 费用相加当作账单。gpt-6-sol 的 112 次成功响应合计 1,003,021 输入 token(其中 305,024 缓存)和 6,604 输出 token;包括判分的官方标价等价额为 $1.5230388,仍不是实际账单。
耗时与计费边界
价格来源:MiniMax 官方价格、百炼模型价格、TypeSafe 模型价格。这些是按成功 usage 回执与网页标价得到的参考额,未计优惠、税费或账单差异。原始会话评分不是 PowerContext 产品耗时;12 道产品耗时受本机网络、可能的代理、服务网关与模型调用共同影响,未测每一跳,不应推断 Jev 模型本身更快或更慢。
gpt-6-sol 产品短题三组均完成 12/12;模型自判为 12/12、12/12、11/12,最后一组标错的答案正确说明演示环境标签不支配生产配置。16 道公开题的两批生成/判分均已完成,判分仍有可核实的错判。前 8 题的预算调整及逐阶段用量详见同目录的 minimax-results-for-review.md 和本报告对应的本地回执。
判断与后续验收
现有数据支持两点:Jev 在这段对话上的证据会话召回明显优于文本向量;与 MiniMax 普通重排的差异很小,而使用 gpt-6-sol 时,普通重排的标注证据召回和 11 道事实题本地核对均略高于 Jev。Jev 在两种模型下的官网参考重排成本均低于普通重排。现有数据不支持跨对话准确率提升、产品难题胜出、实际账单节约或模型推理更快的结论。
如果 issue 的验收要求是“在真实产品路径上提升或保持公开难题质量”,仍需完成多段对话的 Source→Atomic Memory→Runtime 入库与检索、对答案作独立盲审,并记录实际提供商账单与网络分段耗时。两次尝试的公开对话原生提取尚未完成,不能把这里的原始会话诊断冒充产品链路评测。建议在 PR 中报告这些结果及限制,保留 Jev 为可选适配器,暂不关闭 #1937。
Which issue or RFC does this PR close?
Refs #1937, restored from #1643. The implementation follows RFC 0080's existing MemoryReranker boundary and explicit inference-failure contract. The hosted three-arm empirical acceptance remains open.
Rationale for this change
Deployments can opt into pinned Jev System One relevance scoring for authorized Atomic Memory candidates. Provider timeouts, unavailability, invalid scores, missing usage, and model-version drift surface as inference errors, so callers can retry idempotent retrieval and preparation without mistaking provider failure for successful ranking.
What changes are included in this PR?
Minimal-diff audit: no added dependencies or Server configuration options in this PR. HTTPX 0.28.1 already defaults to zero transport retries. OpenAI 2.46.0 and Anthropic 0.117.0 default to two SDK retries; comparison models require the explicit zero override so runner retry accounting is complete. The billing-policy marker prevents applying that guarantee retrospectively to legacy records. Provider resolution and header merging reuse Runtime behavior, and inspected model clients are closed.
Are there any user-facing changes?
Python deployments can inject JevMemoryReranker explicitly. Normal installations require no Jev key. The evaluation CLI adds --rerank-mode jev, --answer-max-bytes, and compare-rerank. Jev provider failures use the existing inference-error contract; HTTP timeout/unavailability are explicit 503 responses. Comparison runs pin effective provider endpoints and require usable per-response receipts before declaring cost complete.
How was this change tested?
SQLite uses an actual local database and Runtime/HTTP/preparation paths. The native SDK regression responses are simulated. Hosted Jev probes execute the actual adapter against public session text; they do not perform ingestion, downstream answering/judging, or a held-out three-arm comparison. No quality, latency, or cost improvement is claimed. See evaluation/memory/locomo/JEV_EVALUATION.md and evaluation/memory/locomo/evidence/jev_live_smoke_2026-10-16.json for evidence and limits.
AI usage statement
Implemented and verified with OpenAI Codex.