Files
natural-memory-nm21/inspect_locomo_adversarial.py
T
WpyQwq 643e22ecb9 Natural Memory NM2.1: 记忆路由器分叉、数据集缺陷修复与全轴评测证据
- 引入 MemoryRouterXL 与 v5/v6 流式多线程训练/编码管线
- 修复 prepare_memory_router_dataset 候选池重建缺陷(mega 家族 3568x 加速,输出逐字节相同)
- 修复 v5 被破坏的拒答与多跳标签(train 未知样本 319 -> 16319,multi_hop 平均正例 1.00 -> 2.00)
- 同存储预算下 V2-128 v6 逐轴 22/22 通过:Top-1 41.12% -> 94.62%,未知拒答 0.00% -> 100.00%
- 记录三条被实测推翻的显然优化(logits_to_keep=1 反而慢 55%、XL 容量未带来收益)
- 记忆手术跨架构可移植性 14/14,读写关闭时与原生模型逐位相同
2026-09-19 11:11:31 +08:00

35 lines
1.1 KiB
Python

"""Check how LoCoMo's adversarial questions carry evidence, before trusting the mapping."""
import json
import sys
from collections import Counter
from pathlib import Path
path = Path(sys.argv[1] if len(sys.argv) > 1 else r"H:\Memory\V2_dpskw\data\net_locomo\locomo10.json")
data = json.loads(path.read_text(encoding="utf-8"))
with_evidence = Counter()
without_evidence = Counter()
keys_seen = Counter()
examples = []
for item in data:
for qa in item["qa"]:
cat = qa.get("category")
keys_seen.update(qa.keys())
ev = qa.get("evidence") or []
if ev:
with_evidence[cat] += 1
else:
without_evidence[cat] += 1
if cat == 5 and len(examples) < 4:
examples.append(qa)
print("qa field names:", dict(keys_seen))
print()
print(f"{'category':>9}{'with evidence':>15}{'without':>10}")
for cat in sorted(set(with_evidence) | set(without_evidence)):
print(f"{cat:>9}{with_evidence[cat]:>15}{without_evidence[cat]:>10}")
print()
print("=== adversarial examples ===")
for qa in examples:
print(json.dumps(qa, ensure_ascii=False, indent=1)[:600])