完整互动讲义Complete interactive guide

5 册 · 7 官方模块 · 42 双语例子5 volumes · 7 official modules · 42 bilingual examples

别只做一个会回答的 RAG。做一个能证明、能监控的系统。Do not build a RAG that merely answers. Build a system that proves and monitors.

这套讲义逐模块覆盖当前官方仓库,用“岗位知识库问答系统”贯穿摄取、检索、Agent、编排、评估、监控与交付。它假设你先完成 Python 和生成式 AI 入门,但每个工程概念仍从白话解释开始。

This guide covers every current official module through a running Job Knowledge Copilot, spanning ingestion, retrieval, agents, orchestration, evaluation, monitoring, and delivery. It assumes the Python and GenAI foundations while explaining every engineering concept in plain language.

5volumes
7units
42个例子examples
60个术语terms

学完能做什么Observable outcomes

不是“看懂了”,而是能解释、能判断、能交付Not just recognition: explain, judge, and deliver

能画系统图Map the system

画出文档进入、检索、生成、权限、评估和监控的全部边界。

Map document ingestion, retrieval, generation, permissions, evaluation, and monitoring.

能定位故障Localize failures

区分摄取坏、检索坏、回答坏、权限坏和线上漂移。

Separate ingestion, retrieval, answer, permission, and production-drift failures.

能工程交付Engineer delivery

实现幂等编排、版本制品、SLO、报警、降级、备份和回滚。

Implement idempotent orchestration, versioned artifacts, SLOs, alerts, fallback, backup, and rollback.

能讲清作品Explain the portfolio

用基线、失败案例、评估和取舍向面试官证明真实能力。

Prove real ability with baselines, failures, evaluation, and tradeoffs.

30 分钟快速路径30-minute fast path

先搭地图,再回到完整路线Build the map, then take the full route

30 分钟路径每册读一章,先获得从 Agentic RAG 到可展示项目的总图。随后按模块完成 42 个例子与作品任务。

The 30-minute path samples one chapter per volume for the map from Agentic RAG to portfolio delivery. Then complete all 42 examples and project tasks module by module.

边界提醒Boundary

官方仓库公开可读但未声明许可证。本讲义不复制或翻译课程正文、代码、作业和模板;双语解释、例子、误区、自测与项目验收均为原创。课程服务、版本与日程会变化,动手前核对当前官方仓库。

The official repository is publicly readable but declares no license. This guide does not reproduce or translate course prose, code, homework, or templates; all bilingual explanations, examples, misconceptions, checks, and acceptance criteria are original. Services, versions, and schedules change, so verify the current repository before implementation.

第一册 · 模块 1Volume 1 · Module 1

先让检索会计划,也会停Let retrieval plan—and stop

用受控循环理解 Agentic RAG。

Understand Agentic RAG through a bounded loop.

本册作品里程碑Portfolio milestone

交付三轮上限、可回放的研究流程。

Deliver a replayable research flow capped at three rounds.

01

模块 1Module 1

Agentic RAG:让检索计划根据证据变化Agentic RAG

先回答一个白话问题Start with a plain question

普通 RAG 是“搜一次再回答”;当问题需要分解、改写、补查和停止判断时,为什么要让流程根据证据变化?

Basic RAG retrieves once then answers. Why should a flow adapt when a question needs decomposition, rewriting, follow-up retrieval, and a stopping decision?

类比桥梁Analogy bridge

像研究员先列问题、找第一批资料,再根据缺口决定补哪份来源,而不是一次搜索后硬写结论。

Like a researcher who plans questions, reviews initial sources, then fills evidence gaps instead of drafting after one search.

类比边界:类比只帮助识别关系;真正系统仍由数据、代码、接口和运行环境决定。Where it breaks: The analogy only exposes relationships; the real system is determined by data, code, interfaces, and its runtime.

工程上到底发生什么What it means in engineering

Agentic RAG 把查询规划、检索、证据评审、工具调用和停止条件放进受控循环;每一步保留状态、预算、来源与失败出口。

Agentic RAG places query planning, retrieval, evidence review, tool use, and stopping into a bounded loop with state, budget, provenance, and failure exits.

例子 1 · 问题分解Example 1 · Question decomposition
输入Input
“我适合哪个 AI 岗位,缺什么?”“Which AI role fits me, and what am I missing?”
过程Process
拆成经历证据、岗位要求、差距三个检索问题Split into experience, role requirements, and gap queries
结果 / 验收Result / check
三组证据合并后回答Answer after merging three evidence groups
例子 2 · 查询改写Example 2 · Query rewriting
输入Input
用户说“会做知识库”User says “I can build a knowledge base”
过程Process
改写为 RAG、embedding、检索、评估同义查询Rewrite into RAG, embedding, retrieval, and evaluation queries
结果 / 验收Result / check
召回口语与技术词表达Retrieve both colloquial and technical wording
例子 3 · 证据不足停止Example 3 · Stop on insufficient evidence
输入Input
材料没有线上监控经历No monitoring experience in the material
过程Process
两轮检索仍为空就停止Stop after two empty retrieval rounds
结果 / 验收Result / check
明确缺证据,不虚构经历State missing evidence; do not invent experience
例子 4 · 工具选择Example 4 · Tool selection
输入Input
问题含当前招聘数据Question needs current job-market data
过程Process
选择授权搜索而非只查静态库Choose authorized search, not only the static store
结果 / 验收Result / check
动态事实带来源日期Dynamic facts include source dates
例子 5 · 循环上限Example 5 · Loop cap
输入Input
检索结果反复相似Repeatedly similar retrieval results
过程Process
按重复率与步数终止Terminate by repetition rate and step count
结果 / 验收Result / check
避免无限检索与费用失控Avoid infinite retrieval and runaway cost
例子 6 · 人类确认Example 6 · Human checkpoint
输入Input
准备给外部联系人发总结Ready to send a summary externally
过程Process
Agent 只生成草稿和收件人预览Agent only drafts and previews recipients
结果 / 验收Result / check
用户确认后才外发Send only after user approval
常见误区Common misconception

把“会自己搜很多次”当作聪明;没有预算、停止与证据标准的循环只会更贵地重复错误。

Treating repeated search as intelligence; without budget, stopping, and evidence criteria, the loop repeats mistakes at higher cost.

作品任务Portfolio task

实现岗位知识库的三步 Agentic RAG:计划问题、执行检索、评审证据;最多三轮并保存轨迹。

Implement a three-stage Agentic RAG flow for the job knowledge base: plan, retrieve, and review evidence, capped at three rounds with traces.

验收:Acceptance: 每个回答能回放查询与来源;无证据、重复结果或超预算时有不同停止原因。Every answer replays queries and sources, with distinct stop reasons for no evidence, repetition, or budget.

自测:什么时候普通“检索一次 → 生成”反而比 Agentic RAG 更好?Self-check: When is one-shot retrieve-then-generate better than Agentic RAG?

当问题单一、语料稳定、一次检索召回已足够,或延迟/成本/风险要求路径固定时。自主性只有在动态规划能带来可测收益时才值得增加。

When the question is simple, the corpus stable, one retrieval sufficient, or latency, cost, and risk require a fixed path. Add autonomy only for measured benefit.

对应来源单元:Source unit: 官方模块 1Official module 1

第二册 · 模块 2Volume 2 · Module 2

把文档变成有版本、有权限的证据Turn documents into versioned, authorized evidence

建立摄取、切块、混合检索、过滤与重排。

Build ingestion, chunking, hybrid retrieval, filtering, and reranking.

本册作品里程碑Portfolio milestone

交付 40 问检索评估与来源追踪。

Deliver a 40-query retrieval evaluation with provenance.

02

模块 2Module 2

向量检索:从文档进入到候选证据排序Vector Search

先回答一个白话问题Start with a plain question

文字不同但意思相近时,怎样找到相关内容,又怎样避免“相似”被误写成“正确”?

How do we find semantically related text while avoiding the mistake of treating similarity as correctness?

类比桥梁Analogy bridge

像给每段文字放到一张语义地图;距离近代表话题接近,不代表来源最新、可信或有权限。

Place passages on a semantic map: proximity suggests topic similarity, not recency, authority, or permission.

类比边界:类比只帮助识别关系;真正系统仍由数据、代码、接口和运行环境决定。Where it breaks: The analogy only exposes relationships; the real system is determined by data, code, interfaces, and its runtime.

工程上到底发生什么What it means in engineering

摄取、解析、切块、embedding、向量/关键词检索、过滤、融合和重排是独立环节;索引必须保存来源、版本和访问元数据。

Ingestion, parsing, chunking, embeddings, vector/keyword retrieval, filtering, fusion, and reranking are separate stages; the index stores provenance, version, and access metadata.

例子 1 · 分块边界Example 1 · Chunk boundary
输入Input
长文档中的资格条件与例外Eligibility rule and exception in a long document
过程Process
按标题/段落切块并保留少量重叠Chunk by headings/paragraphs with limited overlap
结果 / 验收Result / check
规则与例外能同块或相邻召回Rule and exception retrieve together or adjacently
例子 2 · 混合检索Example 2 · Hybrid retrieval
输入Input
查询“报错 E1042”Query “error E1042”
过程Process
关键词命中代码,向量补充语义说明Keyword matches code; vector adds semantic explanation
结果 / 验收Result / check
精确标识和自然语言都不丢Exact identifiers and natural language both survive
例子 3 · 元数据过滤Example 3 · Metadata filtering
输入Input
只问 2026 生效政策Ask only for policy effective in 2026
过程Process
先按日期/版本过滤再相似检索Filter date/version before similarity search
结果 / 验收Result / check
旧政策不进入候选Obsolete policy never enters candidates
例子 4 · 重排序Example 4 · Reranking
输入Input
向量 Top 20 候选Top 20 vector candidates
过程Process
交叉编码器/规则重排前五Rerank top five with a cross-encoder or rules
结果 / 验收Result / check
更相关证据进入生成上下文More relevant evidence enters generation context
例子 5 · 权限过滤Example 5 · Permission filtering
输入Input
用户只能看自己的材料User may see only their own material
过程Process
检索前在服务层应用 ACLApply ACL in the service before retrieval
结果 / 验收Result / check
相似但越权片段不可见Similar unauthorized chunks remain invisible
例子 6 · 索引更新Example 6 · Index refresh
输入Input
源文档被修改A source document changes
过程Process
按内容 hash 增量重嵌入并删除旧版本Re-embed by content hash and remove old version
结果 / 验收Result / check
查询只返回当前可追溯版本Queries return only the current traceable version
常见误区Common misconception

只调 chunk size 和 top-k,完全不建立“真实问题—相关证据”的检索评估集。

Tuning chunk size and top-k without a query-to-relevant-evidence evaluation set.

作品任务Portfolio task

为 30 份项目材料建立混合检索:可重复摄取、版本过滤、ACL、重排与 40 条检索评测。

Build hybrid retrieval for 30 project documents with repeatable ingestion, version filters, ACL, reranking, and 40 retrieval evaluations.

验收:Acceptance: Recall@k、MRR/命中位置和空查询表现有记录;任何候选能回到源文件与段落。Recall@k, rank position/MRR, and empty-query behavior are recorded; every candidate traces to file and paragraph.

自测:向量相似度 0.92 能证明片段支持答案吗?Self-check: Does vector similarity 0.92 prove that a passage supports the answer?

不能。相似度只反映所用表示中的接近程度。还要检查内容是否直接支持主张、版本是否当前、来源是否可信、用户是否有权限。

No. Similarity only measures closeness in the chosen representation. Check entailment, version, source authority, and user permission.

对应来源单元:Source unit: 官方模块 2Official module 2

第三册 · 模块 3Volume 3 · Module 3

让数据管线失败得可见、恢复得可靠Make pipeline failures visible and recovery reliable

用编排管理状态,不把业务逻辑锁进平台。

Use orchestration for state without trapping business logic.

本册作品里程碑Portfolio milestone

交付可恢复的候选发布工作流。

Deliver a recoverable candidate-release workflow.

03

模块 3Module 3

AI 编排:把摄取、评估与发布变成可恢复流程AI Orchestration with Kestra

先回答一个白话问题Start with a plain question

当一次项目需要定时摄取、建索引、跑评估、发布和失败重试时,怎样让每一步可见、可恢复?

When a project schedules ingestion, indexing, evaluation, release, and retries, how do we make every step visible and recoverable?

类比桥梁Analogy bridge

像机场调度:航班有依赖、资源、重试和人工放行,不能靠一条长脚本祈祷跑完。

Like airport operations: dependencies, resources, retries, and human clearance cannot be managed by one hopeful long script.

类比边界:类比只帮助识别关系;真正系统仍由数据、代码、接口和运行环境决定。Where it breaks: The analogy only exposes relationships; the real system is determined by data, code, interfaces, and its runtime.

工程上到底发生什么What it means in engineering

DAG/工作流定义依赖,任务保持幂等,制品带版本;编排器负责调度与状态,不把核心业务逻辑锁死在平台配置里。

A DAG defines dependencies, tasks stay idempotent, and artifacts are versioned. The orchestrator schedules and tracks state without trapping core business logic in platform config.

例子 1 · 每日摄取Example 1 · Daily ingestion
输入Input
每日新增岗位文档Daily new job documents
过程Process
检测变更→解析→索引→评估Detect change → parse → index → evaluate
结果 / 验收Result / check
只有评估通过才标为当前索引Mark the index current only after evaluation passes
例子 2 · 失败重试Example 2 · Failure retry
输入Input
embedding 服务 503Embedding service returns 503
过程Process
有界重试并从失败批次续跑Bounded retry and resume failed batch
结果 / 验收Result / check
已成功批次不重复计费Successful batches are not billed twice
例子 3 · 幂等运行Example 3 · Idempotent run
输入Input
同一文档被事件触发两次The same document event fires twice
过程Process
以内容 hash 作为任务键Use content hash as task key
结果 / 验收Result / check
只生成一份索引记录Only one index record is produced
例子 4 · 人工门禁Example 4 · Human gate
输入Input
新索引检索分下降New index lowers retrieval quality
过程Process
工作流暂停并展示差异Pause the flow and show the diff
结果 / 验收Result / check
负责人决定发布或回滚Owner chooses release or rollback
例子 5 · 秘密隔离Example 5 · Secret isolation
输入Input
模型与数据库凭证Model and DB credentials
过程Process
使用编排器 secret 引用与最小权限身份Use secret references and least-privilege identities
结果 / 验收Result / check
日志和配置不含明文秘密Logs and configs contain no plaintext secrets
例子 6 · 平台退出Example 6 · Platform exit
输入Input
需要更换编排器Need to change orchestrators
过程Process
业务步骤封装成独立 CLI/APIKeep business steps in independent CLI/API units
结果 / 验收Result / check
新平台只重写调度层Only scheduling is rewritten
常见误区Common misconception

把 YAML 配置写得很复杂就认为流程可靠,却没有幂等、制品版本和失败恢复测试。

Mistaking complex YAML for reliability without idempotency, artifact versioning, or recovery tests.

作品任务Portfolio task

编排一条“摄取→索引→检索评估→人工门禁→发布”的候选流程,并故意在每步制造一次失败。

Orchestrate ingestion → indexing → retrieval evaluation → human gate → release, deliberately failing each stage once.

验收:Acceptance: 失败可从最近安全点恢复,不重复副作用;每次运行有输入、输出、版本和负责人。Failures resume from the last safe point without duplicate effects; every run records input, output, version, and owner.

自测:为什么不应把所有 Python 业务逻辑直接写进编排平台的内联脚本?Self-check: Why avoid placing all Python business logic in orchestrator inline scripts?

那会把测试、复用和迁移能力绑在平台里。更稳的是业务步骤有独立入口与测试,编排器只负责依赖、参数、调度和状态。

It traps testing, reuse, and migration in the platform. Keep business steps independently callable and tested; let the orchestrator manage dependency, parameters, schedule, and state.

对应来源单元:Source unit: 官方模块 3Official module 3

第四册 · 模块 4–5Volume 4 · Modules 4–5

评估告诉你坏没坏,监控告诉你何时坏Evaluation says whether; monitoring says when

从固定数据集走到线上质量、漂移和成本信号。

Move from fixed datasets to live quality, drift, and cost signals.

本册作品里程碑Portfolio milestone

交付 80 题门槛、SLO、仪表盘和报警手册。

Deliver an 80-case gate, SLOs, dashboard, and alert runbook.

04

模块 4Module 4

评估:分别测检索、回答、系统与业务结果Evaluation

先回答一个白话问题Start with a plain question

RAG 演示回答过一个问题,怎样证明它面对真实问题仍能稳定找到证据并忠实回答?

A RAG demo answers one question. How do we prove it consistently retrieves evidence and answers faithfully on real questions?

类比桥梁Analogy bridge

像验收医院:不能只看医生一次答对,还要分别测分诊、检查、诊断、用药和患者结果。

Like evaluating a hospital: triage, tests, diagnosis, treatment, and outcomes must be measured separately.

类比边界:类比只帮助识别关系;真正系统仍由数据、代码、接口和运行环境决定。Where it breaks: The analogy only exposes relationships; the real system is determined by data, code, interfaces, and its runtime.

工程上到底发生什么What it means in engineering

建立带相关证据和期望行为的数据集;检索用 recall/rank,生成用忠实度/相关性,系统再看延迟、成本、拒答和安全。

Build a dataset with relevant evidence and expected behavior; measure recall/rank for retrieval, faithfulness/relevance for generation, then latency, cost, abstention, and safety for the system.

例子 1 · 检索命中Example 1 · Retrieval hit
输入Input
问题与标注相关段落Question with labeled relevant passage
过程Process
检查 passage 是否进入 top-kCheck whether passage appears in top-k
结果 / 验收Result / check
发现回答错是检索没找到Find that the answer failed at retrieval
例子 2 · 忠实度Example 2 · Faithfulness
输入Input
答案与实际检索上下文Answer and retrieved context
过程Process
逐主张检查是否被证据支持Check each claim against evidence
结果 / 验收Result / check
流畅但新增数字被判失败Fluent invented numbers fail
例子 3 · 拒答评估Example 3 · Abstention evaluation
输入Input
知识库外问题Out-of-scope question
过程Process
期望返回“无证据”Expect “no evidence”
结果 / 验收Result / check
拒答正确也计为成功Correct abstention counts as success
例子 4 · 对抗样本Example 4 · Adversarial case
输入Input
文档含提示注入Document contains prompt injection
过程Process
检查系统是否仍只当数据Check that it remains data only
结果 / 验收Result / check
工具策略不被外部文本改变Tool policy is unchanged
例子 5 · 成对比较Example 5 · Pairwise comparison
输入Input
旧提示与新提示输出Old and new prompt outputs
过程Process
盲评顺序随机化Blind comparison with randomized order
结果 / 验收Result / check
减少位置和版本偏见Reduce position and version bias
例子 6 · 统计波动Example 6 · Statistical variation
输入Input
同一版本多次运行Repeated runs of one version
过程Process
报告均值、分布与置信区间Report mean, distribution, and confidence interval
结果 / 验收Result / check
不把一次提升当规律One improvement is not treated as a law
常见误区Common misconception

用 LLM judge 一个总分覆盖全部质量;评判模型也会偏,且总分会掩盖安全退化。

Using one LLM-judge score for all quality; judges are biased and aggregate scores hide safety regressions.

作品任务Portfolio task

构建 80 题评估集:常规、空证据、冲突、过时、注入和权限场景;建立组件级与端到端报告。

Build an 80-question set covering normal, no-evidence, conflict, stale, injection, and permission cases, with component and end-to-end reports.

验收:Acceptance: 任何变更都能定位是检索、生成、权限还是性能变化;关键安全项不得被平均分抵消。Every change localizes retrieval, generation, permission, or performance effects; critical safety failures cannot be averaged away.

自测:回答完全正确,但检索到的是过时政策;这次评估应算通过吗?Self-check: The answer is correct, but retrieval used an obsolete policy. Should the evaluation pass?

不能按可靠系统通过。它可能只是偶然答对,证据链和版本控制已失败;应分别记录答案正确与来源/检索失败。

Not as a reliable system. It may be accidentally correct while provenance and version control failed. Record answer correctness separately from source/retrieval failure.

对应来源单元:Source unit: 官方模块 4Official module 4
05

模块 5Module 5

监控:上线后观察质量、漂移、成本与用户后果Monitoring

先回答一个白话问题Start with a plain question

没有标准答案的线上请求里,怎样尽早发现 RAG 变差,而不是等用户投诉?

Without ground truth for every live request, how do we detect RAG degradation before complaints?

类比桥梁Analogy bridge

像驾驶仪表盘:油量、温度、警报和路线偏差一起看,单看发动机“还在转”不够。

Like a dashboard: fuel, temperature, alarms, and route deviation matter; “the engine is running” is insufficient.

类比边界:类比只帮助识别关系;真正系统仍由数据、代码、接口和运行环境决定。Where it breaks: The analogy only exposes relationships; the real system is determined by data, code, interfaces, and its runtime.

工程上到底发生什么What it means in engineering

记录脱敏轨迹,监控请求/错误/p95/token/成本、检索分数与空结果、引用覆盖、反馈和分布漂移;用抽样人工审核补足弱信号。

Log redacted traces; monitor requests, errors, p95, tokens, cost, retrieval scores, empty results, citation coverage, feedback, and drift, supplemented by sampled human review.

例子 1 · 服务健康Example 1 · Service health
输入Input
API 请求API requests
过程Process
监控错误率与 p95Monitor error rate and p95
结果 / 验收Result / check
依赖故障立即报警Dependency failure alerts quickly
例子 2 · 检索漂移Example 2 · Retrieval drift
输入Input
新文档加入后 top-k 分数下降Top-k scores fall after new documents
过程Process
比较分数/空结果/评估集Compare scores, empty rate, and eval set
结果 / 验收Result / check
定位索引污染Identify index contamination
例子 3 · 成本异常Example 3 · Cost anomaly
输入Input
平均 token 突增两倍Average tokens double
过程Process
按版本和路径切片Slice by version and route
结果 / 验收Result / check
发现摘要步骤失效Find broken summarization
例子 4 · 引用覆盖Example 4 · Citation coverage
输入Input
答案句子与引用Answer sentences and citations
过程Process
统计事实句有支持的比例Measure supported factual-sentence ratio
结果 / 验收Result / check
无引用增长触发抽查Rising uncited claims trigger review
例子 5 · 用户反馈Example 5 · User feedback
输入Input
点赞/纠错/放弃Upvote, correction, abandonment
过程Process
结合任务类型而非只看满意度Join feedback with task type
结果 / 验收Result / check
避免受幸存者偏差误导Avoid survivorship bias
例子 6 · 隐私日志Example 6 · Privacy-safe logs
输入Input
包含简历与联系人Resumes and contacts
过程Process
哈希标识、字段脱敏、短保留Hash IDs, redact fields, keep briefly
结果 / 验收Result / check
能诊断且不保存全文秘密Diagnose without retaining full secrets
常见误区Common misconception

把所有 prompt、文档和回答原文永久存日志,监控系统反而成为最大数据泄露源。

Permanently logging prompts, documents, and answers until monitoring becomes the largest data-leak source.

作品任务Portfolio task

为服务定义 SLO、仪表盘和报警:可用性、p95、空检索、引用覆盖、单请求成本与评估抽样。

Define SLOs, dashboards, and alerts for availability, p95, empty retrieval, citation coverage, per-request cost, and sampled evaluation.

验收:Acceptance: 每个报警有负责人、诊断入口和处置;脱敏与保留期经测试。Every alert has an owner, diagnostic route, and response; redaction and retention are tested.

自测:用户点赞率上升,能证明模型质量提高吗?Self-check: Does a higher upvote rate prove model quality improved?

不能单独证明。用户组成、任务难度、界面提示和选择性反馈都可能变化。要结合固定评估、分组请求、纠错率和人工抽样。

Not alone. User mix, task difficulty, UI, and selective feedback may change. Combine fixed evals, sliced traffic, correction rates, and human samples.

对应来源单元:Source unit: 官方模块 5Official module 5

第五册 · 模块 6–7Volume 5 · Modules 6–7

把工程边界装进真正能演示的作品Package engineering boundaries into a demonstrable project

最佳实践只保留有风险证据的部分,最终项目展示成功与失败。

Keep best practices backed by risk evidence and demonstrate both success and failure.

本册作品里程碑Portfolio milestone

交付可重建、可评估、可监控、可讲述的端到端作品。

Deliver a reproducible, evaluable, observable, explainable project.

06

模块 6Module 6

最佳实践:可靠性、安全、性能与成本的系统清单Best Practices (Optional)

先回答一个白话问题Start with a plain question

当原型已经能回答问题,哪些工程措施能把“偶尔成功”变成可维护服务?

Once a prototype answers questions, which engineering practices turn occasional success into a maintainable service?

类比桥梁Analogy bridge

像把家庭厨房升级为餐厅:卫生、备份、库存、峰值流量和责任分工都必须标准化。

Like turning a home kitchen into a restaurant: hygiene, backup, inventory, peak load, and ownership need standards.

类比边界:类比只帮助识别关系;真正系统仍由数据、代码、接口和运行环境决定。Where it breaks: The analogy only exposes relationships; the real system is determined by data, code, interfaces, and its runtime.

工程上到底发生什么What it means in engineering

配置分层、缓存、批处理、异步、限额、熔断、降级、秘密、备份、数据生命周期、测试和运行手册要围绕明确 SLO。

Layer configuration, caching, batching, async work, quotas, circuit breakers, fallback, secrets, backups, data lifecycle, tests, and runbooks around explicit SLOs.

例子 1 · 缓存边界Example 1 · Cache boundary
输入Input
相同公开问答Repeated public question
过程Process
缓存检索候选并带索引版本Cache candidates with index version
结果 / 验收Result / check
更新索引自动失效Index updates invalidate cache
例子 2 · 批量 embeddingExample 2 · Embedding batches
输入Input
一万新片段Ten thousand new chunks
过程Process
按供应商限额分批并可续跑Batch by provider quota with resume
结果 / 验收Result / check
费用可估且失败不重做全部Cost is predictable; failure does not redo all
例子 3 · 熔断降级Example 3 · Circuit breaker
输入Input
模型服务持续 503Persistent model 503
过程Process
达到阈值后暂停调用并返回检索结果Stop calls and return retrieval results after threshold
结果 / 验收Result / check
保护依赖与预算Protect dependency and budget
例子 4 · 数据删除Example 4 · Data deletion
输入Input
用户要求删除材料User requests deletion
过程Process
删源、索引、缓存和备份策略记录Delete source/index/cache and document backup policy
结果 / 验收Result / check
可证明完成或说明保留义务Prove completion or explain retention duty
例子 5 · 灾难恢复Example 5 · Disaster recovery
输入Input
向量库损坏Vector store corruption
过程Process
从版本化源文档与配置重建Rebuild from versioned documents and config
结果 / 验收Result / check
不依赖不可恢复的黑盒索引No dependence on an unrecoverable black-box index
例子 6 · 运行手册Example 6 · Runbook
输入Input
凌晨空检索率报警Nighttime empty-retrieval alert
过程Process
按检查索引版本→摄取→权限顺序排查Check index version → ingestion → permissions
结果 / 验收Result / check
值班者无需猜系统结构On-call staff need not guess system structure
常见误区Common misconception

把“最佳实践”复制成很长清单,却没有按本项目风险和 SLO 排优先级。

Copying a long best-practice checklist without prioritizing this project’s risks and SLOs.

作品任务Portfolio task

做上线准备评审:逐项给证据、负责人和截止日,只修阻断当前 SLO 的最高风险。

Run a launch-readiness review with evidence, owner, and due date per item, fixing the highest risks that block current SLOs.

验收:Acceptance: 每个“已完成”都有测试或运行证据;未完成项有明确风险接受人。Every “done” item has test or runtime evidence; every open risk has an explicit accepting owner.

自测:为什么缓存完整 LLM 回答可能比缓存检索结果风险更大?Self-check: Why can caching full LLM answers be riskier than caching retrieval candidates?

完整回答包含模型版本、提示、权限和当时来源的组合。任一变化都可能使缓存内容过时或越权;候选检索也要版本化,但更容易重新生成并验证答案。

A full answer binds model, prompt, permission, and source state. Any change can make it stale or unauthorized. Retrieval candidates also need versioning but allow regeneration and verification.

对应来源单元:Source unit: 官方模块 6Official module 6
07

模块 7Module 7

端到端项目:把知识库问答做成可展示作品End-to-End Project Example (Optional)

先回答一个白话问题Start with a plain question

怎样把文档、检索、Agent、评估、监控和界面整合成面试时能演示、能被追问的完整项目?

How do we combine documents, retrieval, agents, evaluation, monitoring, and UI into a portfolio project that survives interview questions?

类比桥梁Analogy bridge

像毕业作品展:不只摆成品,还要展示草图、测试、失败修复和为什么这样设计。

Like a graduation exhibition: show the artifact, sketches, tests, failures, and design decisions.

类比边界:类比只帮助识别关系;真正系统仍由数据、代码、接口和运行环境决定。Where it breaks: The analogy only exposes relationships; the real system is determined by data, code, interfaces, and its runtime.

工程上到底发生什么What it means in engineering

项目从问题卡和数据边界开始,经模块化实现、固定评估、容器化、演示数据、监控与 README;真实秘密和私人数据不进入仓库。

Start with problem and data boundaries, then modular implementation, fixed evaluation, containers, demo data, monitoring, and README; no real secrets or private data enter the repository.

例子 1 · 问题卡Example 1 · Problem card
输入Input
目标用户与知识库Target user and knowledge base
过程Process
定义问题、错误成本与禁止用途Define task, error costs, and prohibited uses
结果 / 验收Result / check
项目不是“做一个 RAG”空话The project is not the vague “build a RAG”
例子 2 · 架构图Example 2 · Architecture diagram
输入Input
摄取到回答的组件Components from ingestion to answer
过程Process
标数据、版本、权限和故障Mark data, versions, permissions, and failures
结果 / 验收Result / check
面试时能解释每条边Every edge is explainable in an interview
例子 3 · 演示脚本Example 3 · Demo script
输入Input
三个成功与两个失败场景Three success and two failure scenarios
过程Process
固定演示数据并预期输出Fix demo data and expected behavior
结果 / 验收Result / check
失败处理也能现场展示Failure handling is demonstrable
例子 4 · 测试证据Example 4 · Test evidence
输入Input
检索、回答、攻击与 E2ERetrieval, answer, attack, and E2E tests
过程Process
CI 生成版本化报告CI generates a versioned report
结果 / 验收Result / check
改动是否退化一眼可见Regressions are visible
例子 5 · 部署包Example 5 · Deployment package
输入Input
API、UI、索引构建器API, UI, and index builder
过程Process
容器和配置示例一键启动One-command start via containers and example config
结果 / 验收Result / check
评审者从空环境可重建A reviewer rebuilds from a clean environment
例子 6 · 项目叙述Example 6 · Project story
输入Input
一次检索退化事故One retrieval regression
过程Process
用问题—证据—选择—验证复盘Explain problem, evidence, choice, and verification
结果 / 验收Result / check
90 秒讲清真实贡献与取舍Explain real contribution and tradeoffs in 90 seconds
常见误区Common misconception

为了演示顺滑只保留成功路径,面试官一问“服务挂了或没搜到怎么办”就暴露项目只是拼装。

Keeping only the happy path for a smooth demo; one question about outages or empty retrieval reveals a stitched prototype.

作品任务Portfolio task

交付 Job Knowledge Copilot V1:公开/自建演示数据、混合检索、受控 Agent、80 题评估、监控面板、容器与 README。

Deliver Job Knowledge Copilot V1 with public/self-authored demo data, hybrid retrieval, bounded agent, 80-case eval, monitoring dashboard, containers, and README.

验收:Acceptance: 新评审者 15 分钟内启动;演示五场景;每个数字可追溯;失败可诊断;无秘密与私人数据。A new reviewer starts it in 15 minutes, runs five scenarios, traces every number, diagnoses failures, and finds no secrets or private data.

自测:作品集最有说服力的是“用了多少技术”还是“如何证明它可靠”?Self-check: What is more persuasive in a portfolio: how many technologies were used or how reliability was proven?

是后者。清楚的问题、基线、失败案例、评估、监控、取舍和可复现步骤,比技术名堆叠更能证明你理解项目。

The latter. Clear framing, baselines, failures, evaluation, monitoring, tradeoffs, and reproducibility prove understanding better than a technology list.

对应来源单元:Source unit: 官方模块 7Official module 7

新手术语表Beginner glossary

先用自己的话说一遍,再看定义Say it in your own words before checking

RAGRetrieval-augmented generation

先检索外部证据,再基于证据生成。

Retrieve external evidence before generation.

Agentic RAGAgentic RAG

根据证据动态规划、补查和停止的 RAG。

RAG that plans, follows up, and stops from evidence.

查询规划Query planning

把复杂问题拆成可检索子问题。

Decomposing a complex question into retrievable subqueries.

查询改写Query rewriting

用更适合检索的表达重写用户问题。

Rephrasing a user question for retrieval.

摄取Ingestion

把源资料读取、解析并送入索引流程。

Reading and parsing source material into indexing.

解析Parsing

从文件格式中提取结构化正文与元数据。

Extracting structured text and metadata from files.

切块Chunking

把长文档切成可检索片段。

Splitting long documents into retrievable passages.

重叠Overlap

相邻块共享的少量上下文。

Limited context shared by adjacent chunks.

EmbeddingEmbedding

内容的数值向量表示。

A numeric vector representation of content.

向量检索Vector search

按向量距离查找语义相近候选。

Finding semantically close candidates by vector distance.

关键词检索Keyword search

按词、短语或标识精确匹配。

Exact matching by words, phrases, or identifiers.

混合检索Hybrid search

融合关键词与向量检索结果。

Combining keyword and vector retrieval.

Top-kTop-k

取排序最前的 k 个候选。

Selecting the highest-ranked k candidates.

元数据过滤Metadata filtering

按日期、来源、版本或权限筛选。

Filtering by date, source, version, or permission.

重排序Reranking

对候选做更精细相关性排序。

Refining candidate relevance order.

ACLAccess control list

定义谁能访问哪些资源的规则。

Rules defining who can access which resources.

内容哈希Content hash

由内容计算的标识,用于检测变化与去重。

An identifier computed from content for change detection.

来源追踪Provenance

记录内容来自何处、哪个版本。

Tracking where content came from and its version.

引用Citation

把回答主张连接到源片段。

Linking answer claims to source passages.

拒答Abstention

证据不足时明确不生成结论。

Explicitly withholding an answer without evidence.

状态State

流程继续所需的当前事实和进度。

Current facts and progress needed to continue a flow.

工具Tool

受控查询或执行动作的接口。

A controlled interface for querying or acting.

停止条件Stopping condition

循环结束的可执行规则。

An executable rule for ending a loop.

预算Budget

步骤、token、时间或费用上限。

A cap on steps, tokens, time, or cost.

轨迹Trace

一次任务中查询、调用、结果和决策记录。

A record of queries, calls, results, and decisions.

编排Orchestration

按依赖调度任务并跟踪状态。

Scheduling tasks by dependency and tracking state.

DAGDirected acyclic graph

表示无循环任务依赖的有向图。

A directed graph of non-cyclic task dependencies.

任务Task

编排流程中可独立执行和重试的单元。

An independently executable and retryable workflow unit.

幂等Idempotency

重复执行不会重复产生副作用。

Repeated execution does not duplicate side effects.

制品Artifact

流程产出的模型、索引、报告或文件。

A model, index, report, or file produced by a flow.

人工门禁Human gate

发布或高风险动作前的人工决定点。

A human decision point before release or high-risk action.

Recall@kRecall@k

相关证据出现在前 k 个候选的比例。

Fraction of relevant evidence appearing in top k.

MRRMean reciprocal rank

首个相关结果排名倒数的平均。

Mean reciprocal rank of the first relevant result.

忠实度Faithfulness

回答主张是否被检索证据支持。

Whether answer claims are supported by retrieved evidence.

相关性Relevance

结果是否回答了用户实际问题。

Whether the result addresses the actual question.

评估集Evaluation set

代表真实与失败场景的固定样本。

A fixed set representing real and failure scenarios.

RubricRubric

把主观质量拆成可评分维度。

Criteria that decompose subjective quality.

LLM JudgeLLM judge

用模型按规则评判输出的评估方式。

Using a model to score outputs by criteria.

成对比较Pairwise comparison

在两个输出之间做相对选择。

Choosing relatively between two outputs.

回归测试Regression test

检查改动是否破坏已知行为。

Checking whether a change breaks known behavior.

SLOService level objective

服务对延迟、可用性等的明确目标。

An explicit target for latency, availability, and more.

p95 延迟p95 latency

95% 请求不超过的耗时。

The latency not exceeded by 95% of requests.

错误率Error rate

请求或任务失败的比例。

The proportion of failed requests or tasks.

漂移Drift

输入、检索或结果分布随时间变化。

A change over time in input, retrieval, or output distribution.

引用覆盖Citation coverage

事实主张有来源支持的比例。

The proportion of factual claims backed by sources.

结构化日志Structured log

以固定字段记录事件的日志。

Event logs stored in a fixed field structure.

脱敏Redaction

删除或遮盖不必要敏感信息。

Removing or masking unnecessary sensitive information.

保留期Retention period

数据被保存的允许时长。

The allowed duration for retaining data.

缓存Cache

为加速保存的可失效副本。

An invalidatable copy stored for speed.

熔断器Circuit breaker

依赖持续失败时暂时停止调用。

Temporarily stopping calls after persistent dependency failure.

降级Fallback

主路径不可用时提供能力更低的安全路径。

A safer lower-capability path when the primary path fails.

批处理Batching

把多个项目合并为一批执行。

Combining multiple items into one execution batch.

数据生命周期Data lifecycle

数据从收集、使用、保存到删除的过程。

The path from collection and use through retention and deletion.

备份Backup

用于恢复的独立数据副本。

An independent data copy for recovery.

灾难恢复Disaster recovery

重大故障后重建服务与数据的计划。

A plan to rebuild service and data after major failure.

运行手册Runbook

报警发生时可执行的诊断与处置步骤。

Executable diagnosis and response steps for an alert.

影子部署Shadow deployment

新版本并行运行但不影响用户。

Running a new version in parallel without user impact.

金丝雀发布Canary release

先向小范围流量发布新版本。

Releasing a new version to limited traffic first.

回滚Rollback

恢复到最近已知可用版本。

Restoring the last known-good version.

模型卡Model card

记录模型用途、评估和限制。

Documentation of model use, evaluation, and limits.

来源覆盖矩阵Source coverage matrix

每个来源单元都有去处Every source unit has a destination

来源与版权边界Source and license boundary

来源为 DataTalksClub《llm-zoomcamp》。当前主目录有 7 个模块,其中 6、7 标注可选;本讲义仍完整覆盖。公开可读不等于开放许可,因此只做原创知识重构与事实性署名链接。

Source: DataTalksClub llm-zoomcamp. The current tree has seven modules; modules 6 and 7 are marked optional but remain fully covered. Public readability is not an open license, so this is an original conceptual reconstruction with factual attribution links.

打开官方来源Open official source · retrieved 2026-07-20 · commit 9357a77503cf · no declared license