Token Lab搜索

IMPLEMENT → TEST → DEFEND

有基线与测量的证据检索

分开评价检索准确率、可回答题召回与正确弃答。

学习指南与本课目录LEARNING CONTRACT

理解 → 实现 → 研究

目标:解释本课机制、复现一个例子、测试一个失败案例。读完不自动代表掌握。

先修与预测

学习先修课程 →

添加更多关键词能证明语义泛化吗?

提示 1:识别机制

标签由谁编写,他们是否知道题目?

预测后展开分析

不能。这里五题是开发样例,改善仅验证干预在该样例上的效果。

运行参考实现

{
  "baseline": {
    "accuracy": 0.4,
    "answerableRecall": 0.25,
    "correctAbstentions": 1,
    "rows": [
      {
        "q": "refund policy",
        "gold": "refund",
        "predicted": "refund"
      },
      {
        "q": "reimbursement window",
        "gold": "refund",
        "predicted": null
      },
      {
        "q": "parcel arrival",
        "gold": "delivery",
        "predicted": null
      },
      {
        "q": "broken help",
        "gold": "support",
        "predicted": null
      },
      {
        "q": "astronomy telescope",
        "gold": null,
        "predicted": null
      }
    ]
  },
  "treatment": {
    "accuracy": 1,
    "answerableRecall": 1,
    "correctAbstentions": 1,
    "rows": [
      {
        "q": "refund policy",
        "gold": "refund",
        "predicted": "refund"
      },
      {
        "q": "reimbursement window",
        "gold": "refund",
        "predicted": "refund"
      },
      {
        "q": "parcel arrival",
        "gold": "delivery",
        "predicted": "delivery"
      },
      {
        "q": "broken help",
        "gold": "support",
        "predicted": "support"
      },
      {
        "q": "astronomy telescope",
        "gold": null,
        "predicted": null
      }
    ]
  },
  "limitation": "Five development examples. Tags were authored with these concepts in mind; this is not a held-out generalization claim."
}

初始输出在构建时实际计算;按钮会在浏览器重新计算。不涉及模型、GPU 或硬件。

完整实现与测试入口

将下面四个文件下载到同一目录,执行 node check.mjs。检查覆盖三个项目,无需安装依赖或 API Key。

// Node.js 18+ or modern browser. Fixed corpus and labels; no generative model.
export const documents=[
  {id:'refund',text:'Refund policy: ask within thirty days.',tags:['reimbursement','window']},
  {id:'delivery',text:'Shipping delivery usually takes five days.',tags:['parcel','arrival']},
  {id:'support',text:'Contact support for damaged items.',tags:['broken','help']}
];
export const cases=[{q:'refund policy',gold:'refund'},{q:'reimbursement window',gold:'refund'},{q:'parcel arrival',gold:'delivery'},{q:'broken help',gold:'support'},{q:'astronomy telescope',gold:null}];
const words=s=>new Set(s.toLowerCase().match(/[a-z]+/g)||[]);
export function retrieve(query, useTags=false) {
  const q=words(query);
  return documents.map(d=>({id:d.id,score:[...q].filter(w=>words(d.text+(useTags?' '+d.tags.join(' '):'')).has(w)).length}))
    .filter(d=>d.score>0).sort((a,b)=>b.score-a.score||a.id.localeCompare(b.id))[0]?.id||null;
}
export function evaluate(useTags) {
  const rows=cases.map(c=>({...c,predicted:retrieve(c.q,useTags)}));
  return {accuracy:rows.filter(r=>r.predicted===r.gold).length/rows.length,
    answerableRecall:rows.filter(r=>r.gold&&r.predicted===r.gold).length/rows.filter(r=>r.gold).length,
    correctAbstentions:rows.filter(r=>r.gold===null&&r.predicted===null).length,rows};
}
export function run(){return {baseline:evaluate(false),treatment:evaluate(true),
  limitation:'Five development examples. Tags were authored with these concepts in mind; this is not a held-out generalization claim.'}}
查看可执行验收测试
import assert from 'node:assert/strict';
import {run as attention,softmax,attend,full,cached} from './attention.mjs';
import {run as retrieval,retrieve} from './retrieval.mjs';
import {run as control,simulate} from './control.mjs';
assert.ok(attention().passes);assert.throws(()=>softmax([-Infinity,-Infinity]));assert.throws(()=>attend([1,2],[[1]],[[1]]));
assert.equal(retrieval().baseline.accuracy,.4);assert.equal(retrieval().treatment.accuracy,1);assert.equal(retrieve('unseen vocabulary'),null);
const result=control();assert.ok(result.baseline.maxForce<=5);assert.ok(result.delayed.maxForce<=5);assert.equal(simulate({steps:1}).trace[0].x,0);assert.equal(simulate({steps:1}).trace[0].v,.05);assert.throws(()=>simulate({mass:0}));

// Full and cached paths must reject inconsistent shapes, not just the single-query helper.
assert.throws(()=>full([[1,2]],[[1]],[[1]]),/Shape mismatch/);
assert.throws(()=>cached([[1,2]],[],[]),/sequence shape/);

console.log('PASS: 12 capstone checks. Toy arithmetic and invariants only; no GPU or hardware benchmark.');

迁移任务与消融

冻结标签,新增十个未见改写和五个无关问题,重新测量且不在它们上调参。

评分标准

保留文档 ID;报告基线/干预逐题结果;区分误命中与漏检;提供真正留出评测。

四项分别按 0(缺失)、1(需帮助)、2(有独立证据)评分。每项均为 2 才过关,自评不是认证。

参考报告与自己的报告

参考配置:即 run() 中的常量,不使用随机采样。上方展示样例实测结果。先复现,再只改一个因素并记录影响。

词项标签不是 embedding;这不是生成流程或独立 benchmark,不能把开发准确率当真实质量。

Hypothesis:
Code revision / runtime:
Dataset or fixture version:
Baseline:
One-factor intervention:
Raw outputs and acceptance tests:
Negative result / failure case:
What this does NOT establish:
Next falsifiable hypothesis:
← 全部项目
MATHEMATICAL REVIEW · 2026-10-26

假设、参考实现与验收

五条开发查询:基线 2/5,标签辅助 5/5。标签针对这些概念编写。这是工程样例,不是留出泛化或训练 embedding 检索。

已复核实现、不变性及声明的证据边界;保留原有验收测试。

运行前:预测一个边界情况

五条开发查询:基线 2/5,标签辅助 5/5。标签针对这些概念编写。这是工程样例,不是留出泛化或训练 embedding 检索。

提示:隔离假设

固定基线输入,只改变一个参数或边界;同时比较数值与声明单位。单例通过仅验证该样例。

最小可运行算例

将算例及所链接模块保存在同一目录。使用 Node.js 22 或更高版本,然后运行 node project-retrieval.mjs. 无需第三方运行依赖。

import {run} from './project-retrieval-core.mjs';
console.log(run());

测试与迁移

五条开发查询:基线 2/5,标签辅助 5/5。标签针对这些概念编写。这是工程样例,不是留出泛化或训练 embedding 检索。

在下方笔记记录输入、代码版本、期望值和实测值;再构造违反上述假设的反例,解释原结论为何不再成立。

下载完整代码包(.tar.gz) · 完整参考代码与回归检查

预测、检验与证据记录

展开答案前先预测一个结果;练习后记录差异和迁移测试。记录仅存本地,在不同语言版本间共用。

打开记录/导出/清除 →

数学复核范围逐篇记录,不代表完成论文实证复现;可在笔记中记录疑似错误。 复核范围