Token Lab搜索

← 全部实验
混合检索与重排 / 2 OF 5

纯词法检索

Exact query words alone set the ranking.

本地计算 / 模拟

本地教学实验,不调用外部 API。合成示例不能替代生产环境测量。

学习指南与本课目录LEARNING CONTRACT

理解 → 实现 → 研究

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

02 · 预测与配置

技术场景说明、参数名称与参考答案目前为英文。

03 · 检查证据

运行实验后查看结果。

方法与参考资料

Lexical score counts matching query terms (not BM25). Dense score is cosine on supplied 2D vectors, not a live embedding model. RRF combines ranks. Optional reranking uses known relevance labels as an oracle upper-bound, not a trained reranker. Empty query ties preserve document order.

Text / 原始公式
score=w/(k+lexicalRank)+(1−w)/(k+denseRank); DCG=Σ(2^rel−1)/log₂(rank+1)

An oracle reranker leaks labels intentionally; never report it as learned model performance.

Reciprocal Rank Fusion · SIGIR 2009 ↗

练习题

retrieval-2 / 01What does “Lexical only” test?

Exact query words alone set the ranking.

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 02Which computation produces the result in “Lexical only”?

;

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 03What is the baseline configuration for “Lexical only”?

{"query":"KV cache memory","documents":"[\n {\n \"id\": \"D1\",\n \"text\": \"KV cache stores keys and values for generation\",\n \"vector\": [\n 1,\n 0.1\n ],\n \"relevance\": 3\n },\n {\n \"id\": \"D2\",\n \"text\": \"Cache restaurant menu and opening hours\",\n \"vector\": [\n 0.1,\n 1\n ],\n \"relevance\": 0\n },\n {\n \"id\": \"D3\",\n \"text\": \"Grouped query attention reduces memory\",\n \"vector\": [\n 0.95,\n 0.2\n ],\n \"relevance\": 2\n },\n {\n \"id\": \"D4\",\n \"text\": \"KV cache memory footprint depends on sequence length\",\n \"vector\": [\n 0.8,\n 0.3\n ],\n \"relevance\": 3\n },\n {\n \"id\": \"D5\",\n \"text\": \"Tokenization splits input text\",\n \"vector\": [\n 0.4,\n 0.8\n ],\n \"relevance\": 0\n }\n]","x":1,"y":0.1,"weight":1,"k":60,"retrieve":5,"top":3,"rerank":0}

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 04What numerical result should you check for “Lexical only”?

{"Recall@k":0.6666666666666666,"nDCG@k":0.8838695436828513}

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 05How would you run a controlled comparison for “Lexical only”?

Keep the supplied fixture and other settings fixed; change weight. Compare Recall@k and nDCG@k while varying candidate pool and fusion weight.

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 06What failure could invalidate a conclusion from “Lexical only”?

An oracle reranker leaks labels intentionally; never report it as learned model performance.

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 07Is “Lexical only” a benchmark of a deployed language model?

No. Lexical score counts matching query terms (not BM25). Dense score is cosine on supplied 2D vectors, not a live embedding model. RRF combines ranks. Optional reranking uses known relevance labels as an oracle upper-bound, not a trained reranker. Empty query ties preserve document order.

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 08Which evidence should you report for “Lexical only”?

Compare Recall@k and nDCG@k while varying candidate pool and fusion weight. Export inputs, engine, result and method; distinguish synthetic fixtures from observed production data.

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 09How can another researcher reproduce “Lexical only”?

Open retrieval-2, reset the preset, retain the exact inputs and run. The calculation is deterministic for identical inputs.

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
retrieval-2 / 10What is the next validation step after “Lexical only”?

An oracle reranker leaks labels intentionally; never report it as learned model performance. Test the hypothesis on a representative held-out workload and document a baseline, success metric and stopping rule before claiming deployment readiness.

Original teaching answer / local derivation. Method reference: Reciprocal Rank Fusion · SIGIR 2009 ↗

打开实验 →
MATHEMATICAL REVIEW · 2026-10-26

假设、参考实现与验收

加权倒数排名融合从排名 1 开始。给定相关性是 oracle 重排器,不是训练模型。零向量余弦采用软件哨兵值;实际检索索引不得泄漏标签。

已复核引擎公式、场景预设及数值保护。固定种子的合成输入不是生产基准。

查询 → 词法与向量排名 → 加权倒数排名融合 → 可选相关性 oracle 重排 → Top-k → 召回率与 nDCG
机制图:从上到下跟踪每次变换。

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

Exact query words alone set the ranking.

提示:隔离假设

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

最小可运行算例

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

import {calculate,network} from './academy-core.mjs';
const params={
  "query": "KV cache memory",
  "documents": "[\n  {\n    \"id\": \"D1\",\n    \"text\": \"KV cache stores keys and values for generation\",\n    \"vector\": [\n      1,\n      0.1\n    ],\n    \"relevance\": 3\n  },\n  {\n    \"id\": \"D2\",\n    \"text\": \"Cache restaurant menu and opening hours\",\n    \"vector\": [\n      0.1,\n      1\n    ],\n    \"relevance\": 0\n  },\n  {\n    \"id\": \"D3\",\n    \"text\": \"Grouped query attention reduces memory\",\n    \"vector\": [\n      0.95,\n      0.2\n    ],\n    \"relevance\": 2\n  },\n  {\n    \"id\": \"D4\",\n    \"text\": \"KV cache memory footprint depends on sequence length\",\n    \"vector\": [\n      0.8,\n      0.3\n    ],\n    \"relevance\": 3\n  },\n  {\n    \"id\": \"D5\",\n    \"text\": \"Tokenization splits input text\",\n    \"vector\": [\n      0.4,\n      0.8\n    ],\n    \"relevance\": 0\n  }\n]",
  "x": 1,
  "y": 0.1,
  "weight": 1,
  "k": 60,
  "retrieve": 5,
  "top": 3,
  "rerank": 0
};
const result=calculate('retrieval',params);
console.log(result.metrics);

测试与迁移

Exact query words alone set the ranking.

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

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

预测、检验与证据记录

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

打开记录/导出/清除 →

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