mcpField
I
interview-cheatsheet

interview-cheatsheet

github.com/wanshuiyin生产力18.2k367 次安装4 天前更新
代码仓库

关于 interview-cheatsheet

interview-cheatsheet 是生成中文机器学习与 LLM 面试教程的技能,面向准备相关面试的读者。它包含公式推导、PyTorch 实现和 25 道高频题,并在渲染前进行数学与代码审查;默认只检测,不自动提交。

主要功能

  1. 01生成约 600 至 1000 行教程
  2. 02提供公式与推导
  3. 03编写从头实现的 PyTorch 代码
  4. 04包含 25 道分级面试题
  5. 05交叉模型审查数学与代码
  6. 06默认不自动提交更改

适用场景

  1. 01准备 RLHF、DPO 或 PPO 面试
  2. 02梳理 MoE 等机器学习主题
  3. 03复习 KV Cache 与 Speculative Decoding
  4. 04生成可审查的面试学习材料

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/wanshuiyin/auto-claude-code-research-in-sleep --skill interview-cheatsheet

安装后在 Claude Code 中输入/interview-cheatsheet确认已加载。

详细介绍

/interview-cheatsheet — 长篇中文 ML/LLM 面试备考

每个审核时段开始前,请遵循 可选审核者: 解析调用 → .aris/reviewer.json → Claude Code 默认设置(Codex MCP), 并通过规范的辅助程序解析器使用 reviewer_route.py, 保留此时段的层级、新鲜上下文、源文件/图像输入和确定性门控。 下方的 Codex 示例/固定配置仅适用于 backend=codex;其他路由使用各自的 首次调用/回复约定。保存路由和实际返回的身份; 不可用的选项标记为 REVIEW_UNAVAILABLE。根据实际的 模型系列/完成情况/范围对验收进行分类。 将调用中的 reviewer/model/effort 覆盖项传递给需要审核者的子流程。 生成工作进程保持不变。

每次调用生成一份全面的中文备忘单:公式 + 推导 + 从零编写的代码 + 25 道高频题。输出在渲染前须通过跨模型数学/代码审核。默认仅检测:绝不自动提交。

输入

  • <topic>(必填)——范围要足够窄,以便编写一篇 600-1000 行的教程。合适示例:"RLHF / DPO / PPO"、"MoE"、"KV Cache + Speculative Decoding"。不合适示例(范围太广):"all of LLM training"、"diffusion"(应拆分为 Forward Process / Sampling / CFG)。
  • --effort(默认 balanced)——balanced 约 600 行,max 约 1000 行,包含更深入的证明和更多 L3 问题。
  • --byline(默认 "<Your Name>, <Affiliation>")——传递给 /render-html --author。
  • --commit(默认 false)——若为 false(默认值),则在渲染后停止;由用户审核并提交。未经用户明确批准,绝不推送。

风格指南 — 严格遵守(请阅读 docs/tutorials/attention_tutorial.md,这是规范参考)

章节骨架(12-14 个章节)
## §0 TL;DR — callout intro line + numbered list of 5-7 takeaways
## §1 直觉 — why this matters; analogy; one-paragraph mental model
## §2 核心公式 — main formula + derivation (variance / scaling / boundary)
## §3 实现细节 — 50-80 line from-scratch PyTorch
## §4-7 变体 / 工程实践 / 常见 bug — variants, comparison tables, footguns
## §8 复杂度 / 资源 — time + memory complexity
## §9 与相关方法对比 — placement in the ecosystem
## §10 25 高频面试题 — L1 (10 必会) + L2 (10 进阶) + L3 (5 顶级 lab), all with <details><summary> collapsible answers
## §A 附录 (optional) — sanity-check output, reference list
约定 — 融入已确立的经验
规则原因示例
标题格式为 ## §N Title,且 §N 后须有空格旧版本曾将 §0TL;DR 粘在一起## §0 TL;DR Cheat Sheet
表格单元格中的数学表达式:使用 \lvert ... \rvert,不要使用 |...|| 在 Markdown 表格中是单元格分隔符,会导致换行$\text{score}_{ij} - m \cdot \lvert i-j \rvert$
带正文列表的提示框:拆分为提示框引导行和单独的列表否则列表的第一项会被提示框吞掉,之后的第 2..N 项会从 1 重新编号> 💡 **Sampler 选择** — 按 NFE/质量排序如下。
- Euler …
- Heun …
提示框前缀仅限:💡 ⚠️ ✅ ❌(其他前缀不会应用对应的样式类)渲染器会将它们映射为 callout-info/warn/good/bad> ⚠️ **FP16 溢出** — 即使除了 √d_k …
数学表达式:行内使用 $...$,独立公式使用 $$...$$,关键公式框使用 $$\boxed{...}$$使用 MathJax CDN;源码中为字面内容—
代码:使用 ```python 围栏,编写真正可运行的 PyTorch 代码审核者会检查代码是否可执行—
个人信息禁用清单:所有者的机构/实验室/中心名称、学位项目所属机构、私有服务器别名、求职背景、/Users/... 路径、具体实验室/公司名称审核者会将其标记为 FAILbyline 应在渲染时通过 --author 传入,不要写入正文
语言:以中文为主,英文技术术语保留原样符合既有的备忘单风格"softmax 饱和"、"vector field"
Eyebrow / 副标题 / 标题命名
字段格式
--eyebrowInterview Prep · <Topic>
--subtitle用一个中文句子描述范围(例如:公式推导 + From-Scratch 代码 + 25 高频题(L1 必会 · L2 进阶 · L3 顶级 lab))
--title<Topic> 面试 Cheat Sheet 或 <Topic> Quick Reference
--langzh-CN
Slug

将 <topic> 转换为用于文件名的 kebab/snake-case <slug>。例如:"RLHF / DPO / PPO" → rlhf_dpo_ppo。

工作流

步骤 1 — 规划结构(不写入文件)

在内部草拟:

  • 12–14 个章节标题
  • 主要公式列表(每个公式附推导概要)
  • 代码块列表(骨架代码 + 演示内容)
  • 按 L1 / L2 / L3 难度排序的 25 道面试题(每题附一句预期答案)
  • 对比表主题(例如“RLHF vs DPO vs IPO vs SimPO”)

如果主题过于宽泛,无法放进一份速查表,请停止并让用户明确范围,然后再开始起草。

步骤 2 — 起草 MD

直接写入 docs/tutorials/<slug>_tutorial.md。遵循风格指南。目标长度:600 行(均衡版)或 1000 行(最长),允许 ±20% 浮动。

步骤 3 — 跨模型数学/代码审查(codex gpt-6-astra xhigh,新线程)

使用 model: gpt-6-astra、config: {model_reasoning_effort: xhigh}、sandbox: read-only 调用 mcp__codex__codex,并使用新线程(绝不使用 codex-reply)。

审查者提示词:

You are reviewing a long-form Chinese interview-prep tutorial on <TOPIC> for math/code/factual correctness and style discipline.

## Files to read (READ-ONLY)
- Draft MD: <MD_PATH>
- Style reference: docs/tutorials/attention_tutorial.md
  (Read this only for STYLE — do NOT score the draft against the reference's content topic.)

## Return JSON with these 10 checks

1. formula_correctness — Independently re-derive each $$ display formula. Flag any error with file:line.
2. code_correctness — For each python block: would it run? Does it implement the stated math? Imports / shapes / device handling consistent?
3. interview_answer_correctness — Each L1/L2/L3 question's <details> answer. Specifically flag wrong year / wrong paper / wrong author / off-by-one indexing / inverted comparison.
4. historical_citations — Paper authors + year + venue. Flag wrong attributions (e.g., "DPO: Rafailov 2023 NeurIPS" must be checkable).
5. table_pipe_escape — Any markdown table cell containing `|x|` math (not `\lvert x \rvert`)? Cite line.
6. callout_list_collision — Any line matching the pattern `^> (?:💡|⚠️|✅|❌) \*\*[^*]+\*\* — (?:- |\d+\. )`? That swallows the list.
7. heading_consistency — All `## §N` and `### N.M` follow style guide (space after §N, no glued chars).
8. section_completeness — Sections §0..§10 (and §A if effort=max) present and non-trivial.
9. length_target — Within ±20% of target (600 for balanced, 1000 for max).
10. personal_info_leak — None of: the owner's institution / lab / center names, degree-program affiliations, private server aliases, job-search or recruitment context, absolute `/Users/...` paths. (Keep the concrete string banlist in local untracked notes — the public SKILL defines only the CATEGORIES; listing the real values here would itself be the leak.)

Return JSON:
{
  "verdict": "PASS | WARN | FAIL",
  "checks": {<check_name>: "pass|warn|fail with one-line note + file:line if applicable"},
  "blocking_issues": ["..."],
  "warnings": ["..."]
}

Verdict: PASS = all pass, WARN = at most cosmetic issues (length slight off / cosmetic style), FAIL = any math/code/factual error OR personal-info leak OR table-pipe / callout-list bug.
步骤 4 — 修复并循环审查(无硬性上限——根据进展判断)

针对每个 FAIL 问题编辑 MD。然后使用新线程(绝不复用 threadId)重新调用 codex。直到结果为 PASS,或 WARN 且没有 FAIL 项时停止。

没有硬性轮次上限。 请改用以下经验法则:

  • ✅ 继续推进:如果每轮的 FAIL 项都在缩减且具体、可枚举(例如,修正引文年份、偏差一位、单行代码错误)。说明审查者的反馈有价值——让问题逐步收敛。
  • ⛔ 停止并报告:如果同一问题反复出现(检测到循环),FAIL 项转变为需要用户输入的架构或范围问题,或者审查轮次超过约 6 轮仍未收敛。

大多数教程会在 3–5 轮内收敛。如果仍在发现实质性错误,进行 5–6 轮也没问题——Video Generation 教程(2026 年 5 月)进行了 5 轮,最后 2 轮发现了真正的引文错误,以及对 Sora 补丁大小的不当归因,避免这些问题最终发布。

步骤 5 — 通过 /render-html 渲染

直接调用(不要将 /render-html 作为子技能调用;直接调用其 Python 脚本,以便清楚掌控):

python3 skills/render-html/scripts/render_html.py docs/tutorials/<slug>_tutorial.md \
  --template academic \
  --out docs/tutorials/<slug>_tutorial.html \
  --title "<Topic> 面试 Cheat Sheet" \
  --subtitle "<one-line scope summary>" \
  --eyebrow "Interview Prep · <Topic>" \
  --author "<byline>" \
  --lang zh-CN

render_html.py 会自动运行自身的 13 项 codex 审查。如果审查 FAIL,请修复 MD(通常是数学/代码审查者遗漏的表格竖线或提示框列表问题),然后重新渲染。注意,render_html.py 本身会为渲染阶段审计写入 <slug>_tutorial.review.json。

步骤 6 — 合并审计记录

两项审查都通过后,将数学/代码审查历史与渲染审查历史合并到 docs/tutorials/<slug>_tutorial.review.json:

{
  "skill": "interview-cheatsheet",
  "source": "docs/tutorials/<slug>_tutorial.md",
  "source_sha256_prefix": "<16-char prefix>",
  "output": "docs/tutorials/<slug>_tutorial.html",
  "topic": "<TOPIC>",
  "effort": "balanced | max",
  "byline": "<author string>",
  "math_code_review": {
    "verdict": "PASS",
    "rounds": [
      {"run": 1, "verdict": "...", "thread_id": "...", "issue": "...", "fix": "..."},
      ...
    ]
  },
  "render_review": {
    "verdict": "PASS",
    "rounds": [...]
  },
  "summary": "<one-line: N-round math/code review + M-round render review settled at PASS>",
  "rendered_at": "<YYYY-MM-DD>"
}
步骤 7 — 停止并向用户报告

不要运行 git add / git commit / git push。报告:

✅ /interview-cheatsheet "<TOPIC>" complete.

  Files:
    docs/tutorials/<slug>_tutorial.md          (<lines> lines, <bytes> bytes)
    docs/tutorials/<slug>_tutorial.html        (<bytes> bytes, <TOC> TOC entries)
    docs/tutorials/<slug>_tutorial.review.json

  Math/code review:  PASS after <N> rounds (<thread IDs>)
  Render review:     PASS after <M> rounds
  Length:            <actual> lines (target <effort>)

  Issues caught + fixed during review:
    - <one line per non-trivial fix>

  Suggested commit message:
    docs(tutorials): add <Topic> cheat sheet (rendered via /render-html)

  ⚠️ Did NOT auto-commit — user reviews and pushes manually.
  Also update docs/tutorials/README.md to add the new row.

更新索引

教程通过后,可以选择在 docs/tutorials/README.md 中追加一行:

| **<Topic> 面试 Cheat Sheet** | [`<slug>_tutorial.md`](<slug>_tutorial.md) | [`<slug>_tutorial.html`](https://wanshuiyin.github.io/Auto-claude-code-research-in-sleep/tutorials/<slug>_tutorial.html) | <one-line topic list> |

向用户建议添加该行;如果用户想自行整理,就让他们自己编辑。

关键不变量(ARIS 规则内置于此)

不变量执行方式
执行者 != 审查者系列Claude 起草;gpt-6-astra 审查(数学/代码阶段);gpt-6-astra 再次审查(渲染阶段)
每次审查调用使用新线程步骤 3 和渲染阶段自身的检查都使用 mcp__codex__codex,而非 codex-reply
Codex 推理级别 = xhigh在步骤 3 的审查者配置中硬编码
个人信息脱敏数学/代码审查者和渲染审查者都会检查;禁用名单见风格指南
将经验教训编码为规则风格指南和审查检查 5、6 中均包含表格竖线与提示框列表的冲突规则
不允许静默失败如果审查 FAIL,且 FAIL 集合不再缩减(循环),或约 6 轮后仍未收敛,则停止并报告——不要推送

不适用情形

  • 主题过于宽泛——先拆分为更小的范围
  • 主题不属于 ML/LLM 核心领域——此风格指南假设内容包含数学 + 代码 + 中文;一般主题应使用其他格式或直接撰写
  • 已有想要编辑的草稿——直接使用 Edit;此技能用于从零生成
  • 不需要 HTML 输出——单独调用 /render-html 或跳过步骤 5

参考调用

/interview-cheatsheet "RLHF / DPO / PPO"
/interview-cheatsheet "MoE (Mixture-of-Experts)" — effort: max
/interview-cheatsheet "KV Cache + Speculative Decoding"
/interview-cheatsheet "Long-context: RoPE / YaRN / NTK / MLA"
/interview-cheatsheet "Distributed Training (DDP / FSDP / ZeRO / TP / PP)"
/interview-cheatsheet "Quantization (GPTQ / AWQ / INT4 / FP8 / SmoothQuant)"

参考样式文件

  • 规范样式:docs/tutorials/attention_tutorial.md + .html
  • 次级样式:docs/tutorials/flow_matching_tutorial.md + .html
  • 审核审计格式:docs/tutorials/attention_tutorial.review.json

来源

摘自两篇试点教程(Attention + Flow Matching,2026 年 5 月)。两篇均通过了跨模型审核;Attention 教程经过了 3 轮审核,期间发现了表格竖线冲突和提示块列表冲突,这些问题从渲染结果中并不明显。如今,这些经验已纳入样式指南和审核检查项 5+6,确保后续教程不会重蹈覆辙。

评论

支持 Markdown