Token Lab검색

IMPLEMENT → TEST → DEFEND

Evidence retrieval with a measured baseline

Separate retrieval accuracy, answerable recall and correct abstention.

English project edition. Chinese is also available.

Study guide & lesson outlineLEARNING CONTRACT

Understand → implement → investigate

Goal: explain the mechanism in this lesson, reproduce one example and test a failure case. Reading alone does not mark mastery.

Prerequisite & prediction

Study the prerequisite lesson →

Will adding more keywords prove semantic generalization?

Hint 1: identify the mechanism

Who authored the tags, and which questions did they know?

Reveal analysis after predicting

No. The supplied five cases are development examples. Improvement on these cases only validates the intervention on this fixture.

Run the reference implementation

{
  "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."
}

Initial output is computed at build time; the button recomputes it in your browser. No model, GPU or hardware is involved.

Complete implementation & test runner

Download all four files into one folder. Run node check.mjs. The checks exercise all three projects; no installation or API key is required.

// 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.'}}
Inspect executable acceptance tests
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.');

Transfer task & ablation

Freeze tags, collect ten unseen paraphrases and five unrelated queries, then measure again without tuning on them.

Rubric

Preserve document IDs; report baseline/treatment rows; distinguish false matches from missed retrieval; provide a genuinely held-out evaluation.

Score each of the four criteria 0 (missing), 1 (with help), 2 (independent evidence). Passing requires 2 on every criterion. A self-check is not a certification.

Reference report & your report

Reference configuration: exactly the constants in run(); no random sampling. Observed fixture results are shown above. Reproduce first, then change one factor and record its effect.

Lexical tags are not embeddings; this is neither a generation pipeline nor an independent benchmark. Do not report the development accuracy as real-world quality.

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:
← All capstones
MATHEMATICAL REVIEW · 2026-10-26

Assumptions, implementation & acceptance

Five development queries: baseline 2/5 and tag-assisted 5/5 accuracy. Tags were authored for these concepts. This is an engineering fixture, not held-out generalization or trained embedding retrieval.

Implementation, invariants and declared evidence boundary reviewed; existing acceptance tests remain part of the suite.

Before running: predict a boundary case

Five development queries: baseline 2/5 and tag-assisted 5/5 accuracy. Tags were authored for these concepts. This is an engineering fixture, not held-out generalization or trained embedding retrieval.

Hint: isolate the assumption

Keep the baseline input fixed, change one parameter or boundary, and compare both the numerical result and the claimed units. A passing example verifies this fixture only.

Minimal executable example

Save the example and linked modules in one folder. Use Node.js 22 or newer, then run node project-retrieval.mjs. No third-party runtime dependencies.

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

Test and transfer

Five development queries: baseline 2/5 and tag-assisted 5/5 accuracy. Tags were authored for these concepts. This is an engineering fixture, not held-out generalization or trained embedding retrieval.

Record input, code version, expected result and observed result in the notebook below. Then construct a counterexample that violates the assumption above and explain why the original conclusion no longer follows.

Download complete kit (.tar.gz) · Complete reference kit and regression checks

Predict, test and keep evidence

Before revealing an answer, predict one result. After the exercise, record the discrepancy and a transfer test. Saved locally across language editions.

Open notebook / export / clear →

The mathematical review scope is recorded per lesson. It does not establish empirical paper reproduction; report suspected errors in your notes. Review scope