CCAR-P and Databricks GenAI Study Notebook — Day 2, Part 1
The big picture, CCAR-P crosswalk, Databricks platform map, and key-terminology glossary stay living in Part 1. Folder 2 (Files 9-16) is complete in Part 2. This page is new ground: before the lesson files, it goes all the way down through Folder 3's own directory tree — every layer, every non-notebook file — because this folder is deep enough that the "why" needs its own treatment, not a one-line aside.
大图景、CCAR-P 对照、Databricks 平台结构图,以及术语表,继续留在第一部分里。Folder 2(File 9-16)已经在第二部分里讲完。这一页是全新内容:在讲课程文件之前,先把 Folder 3 自己的目录树从头到尾走一遍——每一层、每一个非 notebook 文件——因为这个文件夹本身的复杂程度,值得单独讲清楚"为什么这么搭",而不是一句带过。
· Note on this part
Folders 1 and 2 were shallow enough that "what's in Includes/" fit in a sentence. Folder 3 is not: it has a Vocareum lab-user wrapper, a generic setup SDK shared across the whole curriculum, a three-layer config system, a real deployed Databricks App, a runtime-staged copy of its own data, and Databricks' own internal course-authoring QA tooling sitting right next to the learner-facing notebooks. Peter asked explicitly for this to be mapped in full before the Module 1-3 files, same non-curated depth as every file in Parts 1-2. This section is that map. It is also directly useful on its own: the pattern this folder uses — one generic installer, turned on and off per-course by config files, with one shared governed resource instead of N duplicated ones — is close to the shape FM Insight's own onboarding should take for a new DoW FM office.
Folder 1 和 Folder 2 都比较"浅",Includes/ 里有什么一句话就能说完。Folder 3 不是:它有一层 Vocareum 实验室用户的外壳目录,一套在整个课程体系里通用的 setup SDK,一套三层的配置系统,一个真正部署出来的 Databricks App,一份它自己数据的运行时暂存副本,还有 Databricks 自己内部用的课程质检工具,就摆在学员能看到的 notebook 旁边。Peter 明确要求在讲 Module 1-3 之前,把这些都完整梳理一遍,深度和 Part 1-2 里每个文件一样,不做精简。这一节就是这份地图。它本身也有直接用处:这个文件夹用的那套模式——一套通用安装器,按课程用配置文件打开或关掉不同功能,用一份共享的受治理资源而不是 N 份各自为政的副本——跟 FM Insight 给国防部财务管理各办公室做新环境接入时该用的形状,非常接近。
06 Folder 3 Architecture — Why It's Built This Way
6.1 The real tree, top to bottom
The path on disk is 3 Agent Evaluation on Databricks\labuser18136720_1793776806\genai-agent-evaluation\Agent Evaluation on Databricks\. Three wrapper layers sit above the course itself before anything resembling a lesson shows up. Below is the full tree, flattened into one table, down to every file and leaf folder.
磁盘上的真实路径是 3 Agent Evaluation on Databricks\labuser18136720_1793776806\genai-agent-evaluation\Agent Evaluation on Databricks\。在看到任何像"课"的东西之前,上面先叠了三层外壳目录。下表把完整目录树摊平列出来,一直列到每一个文件和最底层的叶子文件夹。
| Path | What it is |
|---|---|
| manifest.mf | Sync metadata only — a GUID. Not course content. |
| labuser18136720_…/ | Your Vocareum lab-user export wrapper. Everything real is inside it. |
| ··.conversations/ | Databricks notebook editor state — which assistant settings were active. Not course content. |
| ··.db_internal/notebook/spaces/workspace.json | Which notebook tabs you had open and when. Not course content — this is literally your own browsing history through the course. |
| ··genai-agent-evaluation/Version Info.py | Course version/copyright notebook (v1.2.0, built 3 Nov 2026). |
| ··genai-agent-evaluation/Agent Evaluation on Databricks/ | The actual course. Everything below this row is inside it. |
| ····AGENDA.py | The course map: prerequisites, the 3-module table, requirements. |
| ····Appendix - Agent Deployment Patterns.py | Ungraded reference lecture, not part of the global File count. |
| ····Module 1 - AI Agent Evaluation Fundamentals/ | 3 files: 1.1 Lecture, 1.2 Demo, 1.3 Lecture · File 17-19 |
| ····Module 2 - Built-In and Guideline Judges/ | 7 files: 2.1-2.7, lecture/demo/lab · File 20-26 |
| ····Module 3 - Custom Judges and Human Feedback/ | 2 files: 3.1 Lecture, 3.2 Lab · File 27-28 |
| ····agent-app/ ··· | A real, deployed Databricks App — detailed in 6.5. |
| ····Includes/ ··· | Everything that makes the 3 modules runnable — detailed in 6.3-6.7. |
课程本身(AGENDA + Appendix + 三个 Module)只是整棵树的一小部分。真正占体积、占复杂度的是 agent-app/(一个真实部署的 Databricks App)和 Includes/(让三个 Module 能跑起来的全部配套)——下面 6.2 到 6.7 逐层拆开讲。
6.2 Why the editor clutter is there at all
manifest.mf, .conversations/, and .db_internal/ are not course design choices — they are what you get for free when a Databricks workspace folder is exported or synced to local disk. manifest.mf is the Databricks workspace's own object identifier for the folder. .conversations/assistant-settings.json and .db_internal/notebook/spaces/workspace.json are the notebook IDE's own state: which Databricks Assistant settings were active, and which notebook tabs (AGENDA, several Module 2 files, the Appendix) were open in your workspace the moment it was exported. None of this is something the course authors wrote for you to read — it is a side effect of how the export captured your workspace, the same way a zipped project folder drags along your editor's .vscode/ settings whether you wanted them or not.
manifest.mf、.conversations/、.db_internal/ 都不是课程设计出来的东西——它们是一个 Databricks 工作区文件夹被导出或同步到本地磁盘时,顺带就会带出来的东西。manifest.mf 是 Databricks 工作区给这个文件夹分配的对象标识。.conversations/assistant-settings.json 和 .db_internal/notebook/spaces/workspace.json 是 notebook IDE 自己的状态:当时 Databricks Assistant 的设置是什么、导出那一刻你的工作区里打开着哪些 notebook 标签页(AGENDA、几个 Module 2 的文件、Appendix)。这些都不是课程作者特意写给你看的内容——它只是导出动作顺带捕捉到你工作区状态的副作用,就跟压缩一个项目文件夹时,不管你想不想要,编辑器的 .vscode/ 配置也会被一起打包进去一样。
If you ever sync this course again and see these three things change, that's just you using the workspace — not new course content. Skip them.
以后如果再同步这门课,看到这三样东西有变化,那只是你自己在用这个工作区而已,不是课程内容更新了。可以直接跳过。
6.3 One shared _lib, reused across all four course folders
Includes/_lib/ holds 22 Python modules: setup_orchestrator.py (48 KB, the generic installer), plus lakebase_setup.py, vector_search_manager.py, genie_creation.py, genie_deletion.py, agent_bricks_manager.py, product_data.py, spec_sheet_pdf_creation.py, and more. None of those last six are ever called by anything in this folder's config files — Folder 3's course content never touches Lakebase, vector search, Genie spaces, or Agent Bricks. They are dead code for this folder specifically, and that is the point once you see it: _lib is not Folder 3's own code. It is the same shared setup SDK copied unchanged into Folders 1, 2, 3, and 4, built generically enough to provision anything any of the four courses might need. Each course folder's own config-*.yaml files are what decide, at run time, which slice of _lib actually executes — Folder 1's configs turn on lakebase_setup and vector_search_manager because Folder 1 teaches Lakebase Search and AI Search; Folder 3's configs never mention either, so those modules just sit there unused.
Includes/_lib/ 里有 22 个 Python 模块:setup_orchestrator.py(48 KB,通用安装器),再加上 lakebase_setup.py、vector_search_manager.py、genie_creation.py、genie_deletion.py、agent_bricks_manager.py、product_data.py、spec_sheet_pdf_creation.py 等等。后面这六个,这个文件夹的任何配置文件都没有调用过——Folder 3 的课程内容完全不涉及 Lakebase、向量检索、Genie 空间或 Agent Bricks。看明白这一点之后就会发现:它们对这个文件夹来说是死代码,但这正是关键所在——_lib 根本不是 Folder 3 自己的代码,而是同一套共享的 setup SDK,原封不动地复制进了 Folder 1、2、3、4,写得足够通用,可以给这四门课里任何一门需要的东西做配置。真正决定运行时执行 _lib 里哪一部分的,是每个课程文件夹自己的 config-*.yaml——Folder 1 的配置会打开 lakebase_setup 和 vector_search_manager,因为 Folder 1 教的就是 Lakebase Search 和 AI Search;Folder 3 的配置从没提过这两个,所以这些模块就一直闲在那没人用。
6.4 Three config layers, one call per notebook
Every lesson notebook starts the same way: one %run or import into a Classroom-Setup script, which does exactly two things — install_libraries(config_path), then setup_demo_environment(config_path). Both read the same config-*.yaml file, and which one gets passed in depends on which notebook is calling. There are five config files for this folder: config-01.yaml (Module 1), config-02.yaml (Module 2's lectures/demos), config-02-lab.yaml (2.7's lab specifically — different learner catalog scope), config-03-lab.yaml (3.2's lab), and config-workspace-setup.yaml (the admin-only provisioning run). dependencies.toml sits one level further down: it is the actual package-version catalog (pyyaml 6.0.3, databricks-sdk 0.145.0, mlflow 3.16.1, …) that every config's libraries.groups list references by name instead of pinning a version inline — change a version once in dependencies.toml and every config that lists that package group picks it up.
每一个课程 notebook 的开头都长得一样:一句 %run 或 import 进一个 Classroom-Setup 脚本,这个脚本只做两件事——先 install_libraries(config_path),再 setup_demo_environment(config_path)。两者读的是同一个 config-*.yaml 文件,具体传进去哪一个,取决于是哪个 notebook 在调用。这个文件夹一共有五个配置文件:config-01.yaml(Module 1)、config-02.yaml(Module 2 的讲课和演示)、config-02-lab.yaml(专门给 2.7 的 Lab 用——学员的 catalog 范围不一样)、config-03-lab.yaml(3.2 的 Lab)、config-workspace-setup.yaml(管理员专用的一次性配置运行)。dependencies.toml 还在更下面一层:它才是真正的包版本目录(pyyaml 6.0.3、databricks-sdk 0.145.0、mlflow 3.16.1……),每个 config 的 libraries.groups 列表都是按名字引用它,而不是把版本号直接写死在各自的配置里——只要在 dependencies.toml 里改一次版本号,所有引用了那个包分组的配置就都跟着更新。
This three-layer split — pinned dependencies once, per-office config files, one generic installer called the same way everywhere — is close to the exact shape FM Insight's own onboarding should take when a new DoW FM office comes onto the platform. One shared installer module per capability (a GFEBS connector, a Navy ERP connector, an audit-evidence retrieval module), one config file per office that turns on only what that office needs, and package versions pinned in exactly one place. The alternative — each office's onboarding getting its own hand-copied, slowly diverging setup script — is the thing this design is explicitly built to avoid, and it is also the thing most ad hoc DoD FM tooling actually does today.
这种三层拆分——依赖版本只钉一次、每个办公室一个配置文件、同一个通用安装器在哪都用同一种调用方式——跟 FM Insight 给国防部财务管理新办公室做平台接入时该用的形状,几乎一模一样。每种能力一个共享的安装模块(一个 GFEBS 连接器、一个 Navy ERP 连接器、一个审计证据检索模块),每个办公室一个只打开自己需要那部分的配置文件,包版本只在一个地方钉死。反过来的那种做法——每个办公室的接入脚本各自手抄一份、慢慢各走各的——正是这套设计刻意要避免的东西,而这恰恰也是今天大多数国防部财务管理临时拼凑出来的工具实际在做的事。
6.5 One shared agent, three consumers — and the one place that breaks the pattern
Includes/Workspace-Setup.py is an admin-only, run-once notebook. It creates the shared SF Airbnb listings table, three Unity Gateway model services (agent-model, judge-model, custom-judge-model), the two UC SQL tools, and — the key move — registers one tool-calling agent in Unity Catalog as dbacademy.agent_eval.airbnb@champion. Every learner's Classroom-Setup notebook then just loads that same registered model by alias; nobody builds their own copy of the Airbnb agent. The same registered model is also what agent-app/ (a real Databricks App, built on FastAPI + MLflow's AgentServer) serves as a live chat UI, and that app's thumbs-up/thumbs-down endpoint is what seeds the human-feedback data Module 3.2's lab reads. One agent, three consumers: every demo notebook, the deployed app, and the feedback lab.
Includes/Workspace-Setup.py 是一个只有管理员能跑、只跑一次的 notebook。它建好共享的旧金山 Airbnb 房源表、三个 Unity Gateway 模型服务(agent-model、judge-model、custom-judge-model)、两个 UC SQL 工具,最关键的一步——在 Unity Catalog 里注册一个会调用工具的 agent,命名为 dbacademy.agent_eval.airbnb@champion。之后每个学员的 Classroom-Setup notebook 只是按这个别名把同一个已注册模型加载进来;没有人会自己再搭一份 Airbnb agent。同一个注册模型,也正是 agent-app/(一个真正的 Databricks App,用 FastAPI + MLflow 的 AgentServer 搭的)用来提供实时聊天界面的那个东西,而这个 app 的点赞/点踩接口,正是 Module 3.2 的 Lab 要读取的人工反馈数据的来源。一个 agent,三个消费方:所有演示 notebook、部署出去的 app、以及反馈 Lab。
Module 2.7's lab is the one deliberate exception. Instead of loading the shared Airbnb agent, Classroom-Setup-02-Lab.py registers a different, learner-owned agent — nyc_taxi — built from Includes/agents/nyc_taxi_agent.py with its own tools in Includes/agent tools/nyc_taxi/ (calc_fare_est, trip_info, both UC SQL functions over samples.nyctaxi.trips). The lab needs a fresh, unevaluated agent for learners to practice evaluation on — sharing the already-evaluated Airbnb agent would defeat the point of the exercise.
Module 2.7 的 Lab 是故意安排的唯一例外。它不加载共享的 Airbnb agent,而是让 Classroom-Setup-02-Lab.py 注册一个不同的、学员自己的 agent——nyc_taxi——用 Includes/agents/nyc_taxi_agent.py 搭出来,自带工具放在 Includes/agent tools/nyc_taxi/(calc_fare_est、trip_info,都是基于 samples.nyctaxi.trips 的 UC SQL 函数)。这个 Lab 需要一个全新、还没被评测过的 agent 让学员练手;如果还用那个早就被评测过的 Airbnb agent,这个练习的意义就没了。
6.6 Includes/artifacts/ is a rebuilt copy, not a second source of truth
Includes/artifacts/evaluation_datasets/*.json and Includes/artifacts/nyc_taxi_agent.py look like duplicates of Includes/evaluation_datasets/*.json and Includes/agents/nyc_taxi_agent.py — and byte-for-byte, they almost are (a diff shows only a missing trailing newline). They are not a second, independently maintained source: _lib/artifacts_manager.py's ArtifactsManager class copies the real source files into Includes/artifacts/ fresh on every setup run, because that is the staging location the setup code then uploads to the learner's own Unity Catalog Volume (declared in config-01.yaml as volume_sources: [evaluation_datasets]). If you ever need to change one of these files, the one to edit is the source under Includes/evaluation_datasets/ or Includes/agents/ — never the copy under Includes/artifacts/, which gets overwritten the next time setup runs.
Includes/artifacts/evaluation_datasets/*.json 和 Includes/artifacts/nyc_taxi_agent.py 看起来像是 Includes/evaluation_datasets/*.json 和 Includes/agents/nyc_taxi_agent.py 的重复——逐字节对比下来,也几乎真是(diff 出来只差一个末尾换行符)。但它们不是第二份、各自独立维护的源文件:_lib/artifacts_manager.py 里的 ArtifactsManager 类,每次 setup 运行时都会把真正的源文件重新拷贝一份到 Includes/artifacts/,因为这是 setup 代码后续要上传到学员自己 Unity Catalog Volume 的暂存位置(config-01.yaml 里用 volume_sources: [evaluation_datasets] 声明)。如果以后要改这些文件里的某一个,该改的是 Includes/evaluation_datasets/ 或 Includes/agents/ 下面的源文件——绝不是 Includes/artifacts/ 下面那份拷贝,因为它下次 setup 一跑就会被重新覆盖。
6.7 automation/ is Databricks' own course-authoring QA, not learner material
Includes/automation/Configuration.py, qa_content_checker.py, and Test_All_Notebooks.py are not part of the lesson path at all — they are Databricks Academy's internal course-build tooling, included in the sync because it lives in the same workspace folder as the course. Test_All_Notebooks.py builds a single multi-task Lakeflow Job that runs every lesson notebook in dependency order, with a QA content checker running in parallel; qa_content_checker.py runs regex rules plus an LLM call (ai_query) over every content notebook to flag grammar, spelling, deprecated features, and manual UI steps a human still has to execute, writing its findings to a Delta table; Configuration.py is where the course's own test author points it at this specific course's name and lab notebook paths, with failure/success emails going to a Databricks engineer (aditya.baghel@databricks.com), not to any learner. None of it runs when you open a lesson notebook — it is the mechanism that validated the course before it ever reached you.
Includes/automation/Configuration.py、qa_content_checker.py、Test_All_Notebooks.py 根本不属于学习路径的一部分——它们是 Databricks Academy 自己内部用来构建课程的工具,之所以会同步进来,只是因为它们本来就放在跟课程同一个工作区文件夹里。Test_All_Notebooks.py 会建一个单独的、多任务的 Lakeflow Job,按依赖顺序跑完每一个课程 notebook,同时并行跑一个 QA 内容检查;qa_content_checker.py 对每一个内容 notebook 跑正则规则,外加一次 LLM 调用(ai_query),检查语法、拼写、过时功能,以及还需要人工去点的 UI 步骤,把结果写进一张 Delta 表;Configuration.py 就是课程作者自己填这门课的名字和 Lab notebook 路径的地方,失败/成功邮件发给的是一个 Databricks 工程师(aditya.baghel@databricks.com),不是发给任何学员。你打开一个课程 notebook 的时候,这些东西一个都不会运行——它是这门课在到你手上之前,用来验证自己的那套机制。
The regex-plus-LLM QA checker pattern here (deterministic rules for what can be checked mechanically, an LLM judge call for what can't, findings written to a queryable table) is the same shape Module 2's built-in and guideline judges teach — Databricks is literally dogfooding the course's own subject matter to build the course. That is a useful thing to point to when someone asks whether MLflow-judge-style evaluation is "real" production practice or a training exercise: the vendor runs this exact pattern on its own content pipeline.
这里的"正则加 LLM"质检模式(能机械检查的用确定性规则,不能机械检查的用一次 LLM 判断调用,结果写进可查询的表),跟 Module 2 教的内置判官和准则判官,是同一种形状——Databricks 其实是在用这门课自己讲的东西,反过来构建这门课本身。以后有人问 MLflow judge 这种评测方式到底是不是"真正的生产实践"还是只是教学练习,这是个很有用的例子:供应商自己的内容流水线,用的就是这一模一样的模式。
07 Day 2 — Folder 3: Agent Evaluation on Databricks
The course's own description names the shift directly: systematic evaluation of AI agents using MLflow's framework, addressing the challenges of non-deterministic systems that traditional software testing cannot handle. Folders 1-2 built things that work; Folder 3 builds the discipline for knowing whether they actually work, and for whom. Three modules, twelve files, plus an appendix on deployment patterns.
课程自己的介绍直接点出了这次转变:用 MLflow 的框架系统性地评测 AI agent,解决传统软件测试处理不了的"非确定性系统"这个难题。Folder 1-2 搭的是"能跑起来"的东西;Folder 3 搭的是判断它到底跑没跑对、对谁而言对的那套纪律。三个 Module,十二个文件,外加一个关于部署模式的附录。
· Three modules, twelve files
| File | Type | Lesson |
|---|---|---|
| 17 | Lecture | The Challenge of Evaluating AI Agents |
| 18 | Demo | Agent Setup |
| 19 | Lecture | MLflow's Evaluation Framework |
| 20 | Lecture | Built-In Judges |
| 21 | Demo | Using MLflow Built-In Judges |
| 22 | Lecture | Guideline Judges |
| 23 | Demo | Guideline Judges with MLflow |
| 24 | Lecture | Custom Judges and Feedback |
| 25 | Demo | Custom Judges with MLflow |
| 26 | Lab | Applying Agent Evaluation |
| 27 | Lecture | Offline vs. Online Evaluation Strategies |
| 28 | Lab | Developer and SME Feedback with MLflow |
| App. | Lecture | Agent Deployment Patterns (ungraded appendix) |
三个 Module 的节奏:Module 1(File 17-19)打基础——为什么评测 agent 难、MLflow 的评测框架怎么用;Module 2(File 20-26)是核心工具箱——内置判官、准则判官、自定义判官,最后一个 Lab 把三者都用上;Module 3(File 27-28)是进阶话题——离线评测 vs. 线上评测的策略区别,以及怎么收集开发者和业务专家(SME)的真实反馈。
This is the folder FM Insight needs most directly, and arguably should have been studied before Folder 2. An ungoverned agent calling tools (Folder 2) is a liability; an agent whose answers nobody is systematically checking is a bigger one, especially the moment "the average listing price in Mission" becomes "the obligated balance in appropriation 2026/2027 1804." Judges, guideline-based evaluation, and the offline/online distinction map onto FM Insight's own open question of how a GFEBS/Navy ERP-querying agent gets sampled and reviewed the way a human preparer's work already is under A-123.
这是 FM Insight 最直接需要的一个 Folder,甚至可以说应该排在 Folder 2 之前学。一个没有治理的 agent 去调用工具(Folder 2)本身就是风险;一个没人系统性检查它答案对不对的 agent,风险更大——尤其是当"Mission 社区的平均房价"换成"2026/2027 年度 1804 拨款账户里的未清偿余额"的那一刻。判官机制、基于准则的评测、离线和线上评测的区别,正好对应到 FM Insight 自己还没解决的那个问题:一个查询 GFEBS/Navy ERP 的 agent,该怎么像 A-123 下已经在做的人工编制人员的工作一样,被抽样、被复核。
File 17 Lecture — The Challenge of Evaluating AI Agents
Big picture first: this lecture makes one argument. Traditional software testing asserts an exact output against a fixed input; AI agents break that model because the same input can legitimately produce different, equally-correct outputs, and the agent's own tool-and-reasoning decisions were never written down for anyone to assert against. The fix is not a better assertion — it is a different kind of check: a judge that evaluates whether a response is good, run continuously rather than once, against a deliberately-designed dataset. Everything in Folder 3 (built-in judges, guideline judges, custom judges, offline vs. online strategy) is a specific answer to the problem this lecture states in the abstract.
先说大图景:这节课只讲一个论点。传统软件测试是拿一个固定输入去断言一个精确输出;AI agent 把这套模型打破了,因为同一个输入完全可能合理地产生不同、但同样正确的输出,而且 agent 自己做的工具调用和推理决策,从一开始就没人写下来过,没法拿去断言。解决办法不是把断言写得更精细,而是换一种完全不同的检查方式:用一个"判官"去判断一个回答好不好,而且要持续不断地跑,而不是跑一次就完事,跑在一个经过刻意设计的数据集上。Folder 3 后面的内容——内置判官、准则判官、自定义判官、离线 vs. 线上策略——都是对这节课抽象提出的这个问题,给出的具体答案。
A Why Traditional Testing Falls Short
A1. Traditional software testing relies on deterministic inputs and expected outputs: unit, integration, and end-to-end tests that verify the exact same result every time given the same input. A2. AI agents break every leg of that paradigm at once — not just the output, but behavior, context, verification, and edge cases.
A1. 传统软件测试依赖的是确定性的输入和预期输出:单元测试、集成测试、端到端测试,验证的是同一个输入每次都产出完全一样的结果。A2. AI agent 把这套范式的每一条腿都一次性打断了——不只是输出,行为、上下文、验证方式、边界情况全都变了。
| Traditional software | AI agents | |
|---|---|---|
| Output | Same input → same output | Same input can give different outputs (temperature, sampling) |
| Behavior | Every decision path is programmed | The agent makes tool and reasoning decisions no one wrote |
| Context | Fixed inputs | Depends on retrieval, conversation history, external data |
| Verification | Assert an exact string or number | Judge whether the response is good |
| Edge cases | Enumerated and tested up front | Open-ended and hard to anticipate |
An agent answering "What's the weather in San Francisco?" might say "It's currently 65°F and sunny," "San Francisco weather: 65 degrees, clear skies," or "The temperature in SF is 65°F with no clouds." All three are correct and helpful. None match exactly — assert output == "expected_response" fails on all three.
一个 agent 回答"旧金山天气怎么样",可能说"现在 65 华氏度,晴天",也可能说"旧金山天气:65 度,天空晴朗",或者"旧金山气温 65 华氏度,没有云"。三个回答都正确、都有帮助。但三个字符串没有一个完全一样——assert output == "expected_response" 三个都会判定失败。
B The Agent Evaluation Challenge
B1. Multi-dimensional complexity. Agent evaluation has to assess not just the final answer but the quality of intermediate steps: multi-step reasoning (did the chain of tool calls and retrievals make sense, not just the final sentence), tool-calling accuracy (right tool, right parameters, correctly interpreted results), and retrieval quality for RAG-based agents (relevant documents, correctly synthesized across sources).
B1. 多维度的复杂性。评测 agent 不能只看最终答案,还得看中间每一步的质量:多步推理(一连串工具调用和检索串起来是不是讲得通,而不只是看最后一句话)、工具调用是否准确(工具选对没有、参数传对没有、结果有没有正确解读)、以及(对基于 RAG 的 agent 而言)检索质量(检索到的文档相不相关、有没有把多个来源正确地综合起来)。
B2. Safety and real-world variability. Agents must avoid harmful outputs, respect boundaries, and decline inappropriate requests — qualities that need judgment, not a pass/fail assertion. Production agents also meet diverse queries, unexpected phrasings, and edge cases that are hard to anticipate during development. Both demand an evaluation framework built for the probabilistic, contextual nature of agents, not one borrowed from deterministic software.
B2. 安全性和真实世界的多变性。Agent 必须避免有害输出、尊重边界、拒绝不合适的请求——这些特质需要判断力,不是一个非黑即白的断言能解决的。生产环境里的 agent 还会遇到各种各样的问法、意料之外的表达方式,以及开发阶段很难预料到的边界情况。这两条都要求一套专门为 agent 的概率性、上下文依赖性设计的评测框架,而不是直接照搬确定性软件那一套。
C Evaluation as a Continuous Process
C1. Unlike traditional software, where a stable test suite is a one-time quality signal, agent evaluation runs on a cycle: rapid evaluation during development, comprehensive validation pre-deployment, continuous monitoring in production, and new failure cases from production feeding back into the evaluation dataset — which then re-enters development. C2. That cycle only works if the evaluation infrastructure is scalable, automated, and built into the development workflow from the start, not bolted on before a release.
C1. 和传统软件不一样——传统软件的测试套件是一次性建好、长期当作质量信号——agent 评测跑的是一个循环:开发阶段快速评测,上线前做全面验证,生产环境持续监控,生产里出现的新失败案例再反过来喂回评测数据集,然后重新进入开发阶段。C2. 这个循环只有在评测基础设施从一开始就是可扩展、自动化、嵌进开发流程里的时候才真正跑得起来,而不是等到快发布了才临时加上去。
D Preparing for Evaluation
D1. Before using any evaluation framework, make evaluation both purposeful and reproducible: define quality dimensions, assemble a representative dataset, and enable tracing so judges can assess how an answer was produced, not only the answer itself. D2. The dataset has three parts, only one of which is required.
D1. 在用任何评测框架之前,先让评测变得有目的、可复现:定义清楚要评测的质量维度、搭好一个有代表性的数据集、打开 tracing,让判官不仅能看答案本身,还能看这个答案是怎么产生的。D2. 数据集有三个部分,其中只有一个是必须的。
D2 key principles: representativeness (common, high-impact queries so offline results generalize), edge cases (ambiguous, out-of-scope, adversarial prompts to surface failure modes early), diversity (length, complexity, domain, user expertise), ground truth and/or guidelines (expected facts for objective questions, natural-language guidelines where style or policy matters), and storage/versioning (MLflow evaluation datasets live in Unity Catalog, with built-in versioning, lineage, sharing, and governance). D3 operational setup: track with MLflow experiments and runs (stable names, tags for agent and dataset versions); govern with Unity Catalog (access control, versioning, lineage, registered agents for end-to-end traceability); learn from production (log deployed-agent traces to an experiment, mine user feedback for new evaluation examples).
D2 关键原则:代表性(常见、高影响力的查询,让离线结果能推广到生产环境)、边界情况(模糊的、超出范围的、对抗性的提示,提早暴露失败模式)、多样性(长度、复杂度、领域、用户熟练程度都要有变化)、真值和/或准则(客观问题用预期事实,风格或政策相关的问题用自然语言准则)、存储和版本管理(MLflow 的评测数据集存在 Unity Catalog 里,自带版本管理、血缘、共享和治理)。D3 运行层面的搭建要求:用 MLflow 的 experiment 和 run 做追踪(稳定的命名、给 agent 和数据集版本打标签);用 Unity Catalog 做治理(访问控制、版本管理、血缘追踪、注册 agent 以实现端到端可追溯);从生产环境里学习(把部署出去的 agent 的 trace 记录到一个 experiment 里,挖掘用户反馈,补充新的评测样例)。
CCAR-P crosswalk
- D4 (eval dataset/framework design) — this entire lecture is the conceptual foundation for D4: representativeness, edge cases, diversity, ground truth vs. guidelines are the exact vocabulary a CCAR-P exam scenario will test when it asks "what's wrong with this evaluation dataset."
- D5 (LLM risk/failure modes) — non-determinism, emergent tool/reasoning decisions, and context-dependent responses are named explicitly here as the three root causes of agent failure modes, not just abstract risk language.
中文摘要
- D4(评测数据集/框架设计)——这整节课就是 D4 的概念基础:代表性、边界情况、多样性、真值 vs. 准则,正是 CCAR-P 考题问"这个评测数据集哪里有问题"时会用到的那套词汇。
- D5(LLM 风险/失败模式)——非确定性、agent 自己做出的工具/推理决策、依赖上下文的回答,这节课把这三条明确点出来,当作 agent 失败模式的三个根本原因,而不是停留在抽象的风险措辞上。
The weather example generalizes directly: an FM Insight agent answering "what's the unobligated balance in appropriation X" could phrase the same correct number three different ways, and exact-string testing would fail all three the same way it fails the weather responses here. The real risk isn't the phrasing — it's that a DoW audit-remediation agent needs the D2 dataset discipline (representative GFEBS/Navy ERP queries, edge cases like closed-out or expired appropriations, ground truth from a reconciled source) built before anyone trusts its output, and the C1 continuous-cycle requirement means that dataset has to keep absorbing new failure cases from actual auditor pushback, not get built once and frozen.
这个天气的例子可以直接套用过来:一个 FM Insight 的 agent 在回答"某拨款账户的未obligate余额是多少"时,完全可能用三种不同的说法表达同一个正确数字,而逐字匹配测试会像这里判定三个天气回答都"失败"一样,把三个都判成错。真正的风险不在措辞上——而是一个国防部审计整改用的 agent,必须先把 D2 讲的数据集纪律搭好(有代表性的 GFEBS/Navy ERP 查询、已结清或已过期拨款这类边界情况、来自已核对来源的真值),才有资格让人信任它的输出;而且 C1 讲的持续循环要求意味着,这个数据集还得不断吸收审计人员实际质疑过的新失败案例,而不是搭一次就冻结不动。
File 18 Demo — Agent Setup
Big picture first: this demo doesn't build anything new — it loads the shared agent that Workspace-Setup already registered (see 6.5), sends it two questions, and reads the resulting MLflow traces. That's the whole point: before you can evaluate an agent, you need a reliable way to load it and a reliable record of what it actually did. Everything from File 19 onward assumes you can do both.
先说大图景:这个 demo 不搭建任何新东西——它加载的是 Workspace-Setup 已经注册好的那个共享 agent(见 6.5),发两个问题过去,再去看 MLflow 生成的 trace。这正是重点所在:在评测一个 agent 之前,你得先有一套可靠的方法把它加载进来,还得有一份可靠的记录,告诉你它到底做了什么。File 19 往后的一切,都建立在这两件事都能做到的前提上。
A Classroom Setup and B Load the Agent
%run ../Includes/Classroom-Setup-01 creates the learner's own catalog/schema/experiment and loads the shared agent, as covered in full in 6.4's config-layer walkthrough. The agent itself is dbacademy.agent_eval.airbnb@champion — the same registered model from 6.5 — loaded with one line: mlflow.pyfunc.load_model(f"models:/{UC_MODEL_NAME}@champion"). The course is explicit that the agent is deliberately unremarkable: a tool-calling agent backed by SQL UDFs, calling its model through a Unity Gateway service and its tools through a managed MCP server. The agent is not the lesson — it exists purely so there is something consistent to practice evaluation on.
%run ../Includes/Classroom-Setup-01 会建好学员自己的 catalog/schema/experiment,并加载那个共享 agent——这套流程 6.4 的配置分层那一节已经完整讲过。Agent 本身就是 dbacademy.agent_eval.airbnb@champion——跟 6.5 里那个注册模型是同一个——用一行代码加载:mlflow.pyfunc.load_model(f"models:/{UC_MODEL_NAME}@champion")。课程明确说这个 agent 是故意搞得很"平淡无奇"的:一个靠 SQL UDF 支撑的工具调用 agent,通过 Unity Gateway 服务调用模型,通过受管 MCP 服务器调用工具。这个 agent 本身不是重点——它存在的唯一理由,就是给大家一个始终一致的东西,拿来练习评测。
C Query the Agent and Inspect Traces
Two calls, two different trace shapes. agent.predict(agent_payload("What tools do you have available?")) is a metadata question the agent answers straight from its system prompt — the trace shows one LLM span, no tool calls. agent.predict(agent_payload("Can you tell me what the average price is in Mission?")) triggers both avg_neigh_price and cnt_by_room_type — the trace shows an LLM span fanning out into two tool-call spans before a final LLM span composes the answer. Every span carries its own input/output payload and latency, which is the whole reason traces exist: they let you verify what the agent did, not just what it returned.
两次调用,两种完全不同的 trace 形状。agent.predict(agent_payload("What tools do you have available?")) 是一个元信息问题,agent 直接从系统提示里就能回答——trace 里只有一个 LLM span,没有工具调用。agent.predict(agent_payload("Can you tell me what the average price is in Mission?")) 会触发 avg_neigh_price 和 cnt_by_room_type 两个工具——trace 显示一个 LLM span 分叉出两个工具调用 span,最后再有一个 LLM span 把结果组合成答案。每个 span 都带着自己的输入/输出内容和延迟,这正是 trace 存在的全部意义:它让你能验证 agent 做了什么,而不只是它返回了什么。
D. The registered agent lives in Catalog Explorer under dbacademy.agent_eval as the model airbnb, alias @champion — Workspace-Setup registers a new version on every run, and @champion always points at whichever version the demos and the app currently use. Traces land in the learner's own airbnb_experiment, under the Traces tab, where the two calls just made are visible with full span hierarchy, inputs/outputs per span, and a latency breakdown. E. Three things done: loaded a UC-registered agent by name and alias, generated traces by querying it, and located both the agent and its traces in the workspace UI.
D. 注册的 agent 在 Catalog Explorer 里,位于 dbacademy.agent_eval 下面,模型名叫 airbnb,别名 @champion——Workspace-Setup 每跑一次就注册一个新版本,@champion 永远指向 demo 和 app 当前实际在用的那个版本。Trace 会落到学员自己的 airbnb_experiment 里,在 Traces 标签页下,刚才那两次调用都能看到,带完整的 span 层级、每个 span 的输入输出,以及延迟分解。E. 完成了三件事:按名字和别名加载了一个 UC 注册的 agent;通过查询它生成了 trace;在工作区界面里分别找到了这个 agent 和它的 trace。
CCAR-P crosswalk
- D5 (LLM risk/failure modes) — the two-trace contrast is a clean, minimal example of a tool-selection decision an exam scenario can test: same agent, same system prompt, a routing decision (call tools or not) made entirely by the model with nothing hardcoded.
- D4 (eval design) — "load by alias, query, read the trace" is the three-step pattern every later evaluation technique in Folder 3 builds on top of; worth recognizing as the baseline, not a one-off demo step.
中文摘要
- D5(LLM 风险/失败模式)——两个 trace 的对比,是考题可能会考的工具选择决策的一个干净、最小化的例子:同一个 agent、同一个系统提示,要不要调用工具这个路由决策,完全由模型自己做,没有任何硬编码。
- D4(评测设计)——"按别名加载、发查询、读 trace"这三步,是 Folder 3 后面每一种评测技术都要在此基础上搭建的模式;值得把它当成基线来认,而不是一次性的 demo 步骤。
"One shared, version-aliased agent that every consumer loads the same way" is the exact pattern FM Insight needs for its own GFEBS/Navy ERP-querying agents — a champion alias means a new, better-tested version can be promoted without touching a single notebook or app that calls it, which is a cleaner change-control story than File 11's replace=True gap ever was for a tool. The metadata-vs-data-question trace contrast is also a useful acceptance test to borrow directly: before trusting any FM Insight agent in production, confirm its trace shows tool calls exactly when the question actually needs GFEBS/Navy ERP data, and no tool calls when it doesn't.
"一个共享的、用别名管理版本的 agent,所有使用方都用同一种方式加载",正是 FM Insight 自己那些查询 GFEBS/Navy ERP 的 agent 需要的模式——champion 别名意味着可以推送一个新的、测试更充分的版本,而不用动任何一个调用它的 notebook 或 app,这比 File 11 里 replace=True 那个漏洞要干净得多的变更管理方式。元信息问题 vs. 数据问题这两种 trace 形状的对比,也是一个可以直接搬过来用的验收测试:在生产环境里信任任何一个 FM Insight 的 agent 之前,先确认它的 trace 在问题真正需要 GFEBS/Navy ERP 数据的时候才调用工具,不需要的时候就不调用。
File 19 Lecture — MLflow's Evaluation Framework
Big picture first: File 17 argued, in the abstract, that agents need a different kind of testing. File 19 is where that abstraction becomes an actual architecture: three inputs (a dataset, scorers, a predict function) flow into one orchestration point, mlflow.genai.evaluate(), which calls the agent, traces every call, runs the scorers, and logs a result you can query two ways — aggregated metrics, or per-row assessments sitting on each trace. Tracing is not a side feature of this architecture; it is load-bearing, because several judges literally cannot score an answer without reading the trace of how that answer was produced. Everything in Modules 2 and 3 — built-in judges, guideline judges, custom judges, offline vs. online strategy — is a variation on filling in one of these three inputs or reading one of these two outputs. This is the single most important file to hold firmly in memory for the rest of Folder 3.
先说大图景:File 17 在抽象层面论证了 agent 需要一种不同的测试方式。File 19 就是这个抽象变成一套实际架构的地方:三个输入(一个数据集、一组判官、一个 predict 函数)汇入同一个编排点——mlflow.genai.evaluate()——它会调用 agent、给每次调用打 trace、跑判官、把结果记录下来,而这个结果你可以用两种方式查:汇总指标,或者挂在每条 trace 上的逐行评估结果。Tracing 在这套架构里不是一个可有可无的附加功能,它是承重的——因为有几种判官,没有 trace 根本没法判断一个答案是怎么产生的,也就没法打分。Module 2 和 Module 3 里的一切——内置判官、准则判官、自定义判官、离线 vs. 线上策略——本质上都是在填这三个输入里的某一个,或者读这两种输出里的某一个的变体。这是整个 Folder 3 里最重要的一个文件,后面全靠它。
A MLflow for Agent Evaluation
A1. Five MLflow capabilities carry the weight of agent evaluation: tracing, scorers and judges, mlflow.genai.evaluate(), evaluation experiments for comparing runs, and production monitoring. A detail worth keeping for D5-style exam questions: MLflow traces are fully OpenTelemetry-compatible, so they can export to Datadog, Grafana, or Splunk via MLflow-only, OTel-only, or dual export — evaluation data is not trapped inside MLflow's own UI.
A1. 五项 MLflow 能力撑起了整个 agent 评测:tracing、判官(scorers and judges)、mlflow.genai.evaluate()、用来对比多次运行的 evaluation experiments,以及生产监控。有一个细节值得记下来,考 D5 类题目时可能用到:MLflow 的 trace 完全兼容 OpenTelemetry,可以通过"只走 MLflow"、"只走 OTel"或"两边都导出"三种方式,导出到 Datadog、Grafana 或 Splunk——评测数据不会被锁死在 MLflow 自己的界面里。
B Core Architecture — Three Fundamental Components
B1. Three components flow into mlflow.genai.evaluate(): the evaluation dataset (what to test — inputs required, outputs and expectations optional, as laid out in File 17's D2/D3), scorers (how to grade — built-in, guideline, custom, or code-based), and the predict function (how to call the agent — optional if the data already holds pre-generated outputs, the "answer sheet" mode). evaluate() calls the agent for each row, traces every call, runs each scorer, and logs the run; it returns an EvaluationResult with a run_id and aggregated metrics, with per-row assessments living on each row's trace.
B1. 三个组件汇入 mlflow.genai.evaluate():评测数据集(测什么——inputs 必须,outputs 和 expectations 可选,跟 File 17 的 D2/D3 讲的一致)、判官(怎么打分——内置、准则、自定义,或基于代码)、predict 函数(怎么调用 agent——如果数据里已经有预先生成好的输出,这个可以省略,也就是"答案卷"模式)。evaluate() 会对每一行调用 agent,给每次调用打 trace,跑每个判官,把这次运行记录下来;返回一个 EvaluationResult,带一个 run_id 和汇总指标,逐行的评估结果则挂在每一行的 trace 上。
C The mlflow.genai.evaluate() Function
C1. Central orchestration point. evaluate() is an evaluation harness: feed in test data, run the app, automatically score the results. It connects offline testing with production monitoring — the same evaluation logic used in development can also run in production (the thread File 19 E and File 27 pick up).
C1. 中央编排点。evaluate() 是一个评测框架:喂进去测试数据,跑你的应用,自动打分。它把离线测试和生产监控连起来——开发阶段用的那套评测逻辑,同样可以在生产环境里跑(这条线 File 19 的 E 部分和 File 27 会接着讲)。
C2. Key parameters. data — rows of inputs plus optional outputs/expectations: a list of dicts, a DataFrame, or a Unity Catalog evaluation dataset. predict_fn — called once per row with that row's inputs; omit it to score outputs already present in the data. When provided, it must accept keys from inputs as keyword arguments, return a JSON-serializable dict, be instrumented with MLflow Tracing, and emit exactly one trace per call. scorers — built-in, guideline, custom, and code scorers; each judge's model is itself a Unity Gateway model service. The return value — an EvaluationResult with run_id and aggregated metrics — is the fourth part of the same picture.
C2. 关键参数。data——每一行是输入,加上可选的 outputs/expectations:可以是一个 dict 列表、一个 DataFrame,或者一个存在 Unity Catalog 里的评测数据集。predict_fn——每一行调用一次,传入这一行的 inputs;如果数据里已经有现成的输出,这个参数可以省略不写。如果写了,它必须接受 inputs 字典里的键作为关键字参数,返回一个可以 JSON 序列化的 dict,要用 MLflow Tracing 打上标记,并且每次调用正好产生一条 trace。scorers——内置、准则、自定义、代码判官都算;每个判官背后的模型本身也是一个 Unity Gateway 模型服务。返回值——一个带 run_id 和汇总 metrics 的 EvaluationResult——是这张图的第四块拼图。
When provided, predict_fn must accept keys from the inputs dictionary as keyword arguments, return a JSON-serializable dictionary, be instrumented with MLflow Tracing, and emit exactly one trace per call.
课程原文:如果提供了 predict_fn,它必须接受 inputs 字典里的键作为关键字参数,返回一个可以 JSON 序列化的字典,用 MLflow Tracing 打上标记,并且每次调用正好产生一条 trace。
C3 Evaluation Workflow
Five steps, in order, every time evaluate() runs: (1) load the data and validate its structure; (2) generate outputs by calling predict_fn for each row — skipped when the data already has outputs; (3) create traces, with each call traced automatically; (4) run the scorers on every row; (5) aggregate and log the metrics and results to MLflow.
每次跑 evaluate(),都是这五步,顺序不变:(1)加载数据并校验结构;(2)对每一行调用 predict_fn 生成输出——如果数据里已经有输出,这一步跳过;(3)创建 trace,每次调用都自动打上 trace;(4)对每一行跑判官;(5)把指标和结果汇总,记录到 MLflow。
C4 Return Value and Results Access
The function returns an EvaluationResult with run_id, metrics (aggregated dict), artifacts, and tables (per-example DataFrames). In MLflow 3, per-example results are read from the traces, not from the result object directly: mlflow.search_traces(run_id=results.run_id, return_type="list"), then iterate trace.info.assessments for each scorer's name and value. The course's own mock run makes this concrete: aggregated metrics correctness/mean 0.80, safety/mean 1.00, tone/mean 0.60, and a per-row table where one row — "What is the average listing price in Haight Ashbury?" — fails correctness specifically because the agent said 92.40 against an expected 87.71, with the rationale attached directly to that cell.
返回的 EvaluationResult 带 run_id、metrics(汇总字典)、artifacts,以及 tables(逐行 DataFrame)。在 MLflow 3 里,逐行结果不是直接从返回对象里读,而是从 trace 里读:mlflow.search_traces(run_id=results.run_id, return_type="list"),然后遍历每条 trace 的 trace.info.assessments,拿到每个判官的名字和打分。课程自己的模拟运行把这个过程讲得很具体:汇总指标 correctness/mean 0.80、safety/mean 1.00、tone/mean 0.60,逐行表格里有一行——"Haight Ashbury 的平均房价是多少"——专门因为 correctness 判官不通过而"失败",原因是 agent 给出的答案是 92.40,而预期是 87.71,这个理由就直接挂在那个格子上。
D MLflow Tracing — the Foundation of Agent Observability
D1. Tracing captures every step of the agent's reasoning: model calls (prompts, responses, parameters), tool invocations (inputs and return values), retrieval operations (documents and metadata), the duration of every operation, and the parent-child hierarchy tying them together. Tracing is enabled automatically when using evaluate() with a properly instrumented predict_fn.
D1. Tracing 会记录 agent 推理过程中的每一步:模型调用(提示、回复、参数)、工具调用(输入和返回值)、检索操作(文档和元数据)、每个操作的耗时,以及把这些都串起来的父子层级关系。只要 predict_fn 打好了标记,用 evaluate() 跑的时候 tracing 会自动打开。
D2 Span Types in Traces
The course's own example — the same Airbnb agent from File 18 — traces "What is the average listing price in Haight Ashbury?" as an AGENT span (airbnb_assistant) containing a predict_stream span, which in turn contains a CHAT_MODEL span (deciding to call a tool), a TOOL span (avg_neigh_price, 0.46s, returning 87.71), and a second CHAT_MODEL span (composing the final answer). Selecting the TOOL span surfaces its inputs ({"neighborhood_name": "Haight Ashbury"}), its output (87.71), and attributes including latency, status, and that it ran via a managed MCP server — the same MCP server pattern from File 10/11 in Folder 2.
课程自己的例子——还是 File 18 里那个 Airbnb agent——把"Haight Ashbury 的平均房价是多少"这条 trace,拆成一个 AGENT span(airbnb_assistant),里面套着一个 predict_stream span,这个 span 又套着一个 CHAT_MODEL span(决定要不要调用工具)、一个 TOOL span(avg_neigh_price,耗时 0.46 秒,返回 87.71),以及第二个 CHAT_MODEL span(把最终答案组合出来)。点开那个 TOOL span,能看到它的输入({"neighborhood_name": "Haight Ashbury"})、输出(87.71),以及延迟、状态、还有它是通过受管 MCP 服务器跑的这些属性——跟 Folder 2 的 File 10/11 讲的那个 MCP 服务器模式是同一套。
| Span type | What it records |
|---|---|
| AGENT | The agent's own reasoning and orchestration steps |
| CHAT_MODEL | Requests to a chat model and its responses |
| TOOL | Tool and function calls, with their inputs and results |
| RETRIEVER | Fetches from AI Search or another retriever |
| CHAIN | A sequence of operations run in order |
MLflow also supports LLM, EMBEDDING, GUARDRAIL, PARSER, RERANKER, EVALUATOR, MEMORY, TASK, WORKFLOW, and UNKNOWN.
MLflow 还支持 LLM、EMBEDDING、GUARDRAIL、PARSER、RERANKER、EVALUATOR、MEMORY、TASK、WORKFLOW 和 UNKNOWN 这些 span 类型。
D3 Why Tracing Matters for Evaluation
Some judges, like RetrievalSufficiency, literally cannot function without a trace — they analyze what was retrieved, not just the final response, so without traces these evaluations would be impossible. Tracing also enables debugging by letting you inspect exactly what happened during a failed evaluation: was it retrieval quality, tool selection, or LLM reasoning that broke?
有些判官,比如 RetrievalSufficiency,没有 trace 根本没法工作——它分析的是检索到了什么,不只是最终回复,所以没有 trace 这类评测是做不了的。Tracing 还能帮你调试:评测失败的时候,你能准确看到当时发生了什么——到底是检索质量、工具选择,还是 LLM 推理的问题。
E Production Monitoring and Unity Gateway
Evaluation doesn't stop at deployment — the same MLflow pieces cover a deployed agent too. The deployed agent (File 18's agent-app, built on AgentServer) logs a trace for every request to its own MLflow experiment, and user feedback captured through the app's /api/feedback endpoint is saved on those same traces. The same scorers used offline can be registered to run automatically on a sample of production traces, with .register() and .start(). And every model call — from the agent and from the judges alike — goes through a Unity Gateway model service, so permissions, rate limits, and usage tracking apply uniformly to both. Failures found in production become new rows in the evaluation dataset, closing the loop File 17's C1 described; File 27's Offline vs. Online Evaluation Strategies lecture walks through exactly that loop.
评测不会在部署那一刻就结束——同一套 MLflow 组件,照样覆盖一个已经部署出去的 agent。部署出去的 agent(File 18 里那个基于 AgentServer 搭的 agent-app)会把每一次请求的 trace,记录到它自己的 MLflow experiment 里,用户通过 app 的 /api/feedback 接口给出的反馈,也保存在同一批 trace 上。离线用的那些判官,也可以注册成自动跑在生产 trace 抽样上,用 .register() 和 .start()。而且每一次模型调用——不管是 agent 自己,还是判官——都要经过一个 Unity Gateway 模型服务,所以权限、速率限制、用量追踪,对两边都是统一适用的。生产环境里发现的失败案例,会变成评测数据集里的新一行,正好接上 File 17 的 C1 讲的那个闭环;File 27 的"离线 vs. 线上评测策略"那节课,会完整讲一遍这个闭环。
CCAR-P crosswalk
- D1 (architecture) — this is the file: dataset + scorers + predict_fn → evaluate() → EvaluationResult, with tracing as the connective tissue, is the single architecture diagram most likely to anchor a D1 exam question about agent evaluation systems.
- D4 (eval dataset/framework design) — C2's parameter contract (predict_fn's four hard requirements) and C3's five-step workflow are exactly the kind of implementation detail a D4 question tests against a "spot the bug" scenario.
- D5 (LLM risk/failure modes) — D3's point that RetrievalSufficiency-style judges cannot function without traces is a direct exam-relevant failure mode: an untraced agent is not just hard to debug, it is literally un-evaluable by a whole class of judges.
中文摘要
- D1(架构)——这就是那个文件:数据集 + 判官 + predict_fn → evaluate() → EvaluationResult,tracing 作为连接组织,是最可能成为 D1 考题里那张架构图的内容。
- D4(评测数据集/框架设计)——C2 讲的参数契约(predict_fn 的四条硬性要求)和 C3 讲的五步工作流,正是 D4 题目拿来考"找出这个场景里的 bug"时会用到的实现细节。
- D5(LLM 风险/失败模式)——D3 讲的"RetrievalSufficiency 这类判官没有 trace 就没法工作",是一个直接跟考试相关的失败模式:一个没打 trace 的 agent,不只是难调试,而是从根本上没法被一整类判官评测。
This architecture is the one FM Insight needs to adopt wholesale, not adapt loosely. The three-input structure maps directly: the evaluation dataset becomes a curated set of GFEBS/Navy ERP queries with reconciled ground truth (built with the D2 discipline from File 17); the predict function becomes the deployed FM Insight agent's own call signature, instrumented for tracing exactly as C2 requires — no shortcuts, because skipping tracing instrumentation silently disables every judge that depends on it; and the scorers become whatever mix of built-in Correctness/Safety and custom judges Module 2 will introduce. The production-monitoring half of E is arguably the more urgent one for audit remediation specifically: an A-123 control testing program already requires sampling and reviewing transactions after the fact, and "register the same scorers to run on a sample of production traces" is close to a drop-in mechanism for extending that control-testing discipline to an AI agent's outputs, with the trace serving as the audit trail a reviewer would otherwise have to reconstruct by hand.
这套架构正是 FM Insight 需要整体照搬的,不是零零散散地借鉴几点。三个输入的结构可以直接对应过去:评测数据集,对应一套精心整理过的 GFEBS/Navy ERP 查询,带已核对过的真值(用 File 17 的 D2 那套纪律搭建起来);predict 函数,对应部署出去的 FM Insight agent 自己的调用方式,按 C2 的要求打好 tracing 标记——不能偷工减料,因为跳过 tracing 这一步,会悄无声息地让所有依赖 trace 的判官都失效;判官,对应 Module 2 要讲的内置 Correctness/Safety 判官和自定义判官的某种组合。E 部分讲的生产监控那一半,对审计整改来说可能更紧迫:A-123 下的控制测试项目,本来就要求对交易事后抽样复核,而"把同一批判官注册成自动跑在生产 trace 抽样上",几乎是一个可以直接拿来用的机制,用来把这套控制测试的纪律,延伸到一个 AI agent 的输出上——trace 本身就是审计人员原本得手动重建的那条审计轨迹。
File 20 Lecture — Built-In Judges
Big picture first: File 19 named scorers as one of three inputs to evaluate() without saying what a scorer actually is. File 20 answers that with a spectrum, not a single answer — five kinds of scorer, ordered by how much you customize versus how fast you get started — and then zooms into the fastest-to-start end of that spectrum: built-in judges, research-validated and ready to use with zero setup beyond an import.
先说大图景:File 19 把判官列成 evaluate() 三个输入之一,但没说判官到底是什么。File 20 给出的答案是一个"谱系",不是单一答案——五种判官,按"要自己定制多少"和"多快能上手"这两条轴排开来——然后聚焦在这个谱系里最快能上手的那一端:内置判官,经过研究验证,除了 import 一下几乎不用额外配置。
A Judge Types Overview — the Evaluation Judge Spectrum
A1. Three LLM-judge types, in increasing order of customization: built-in judges (out of the box — research-validated judges like Correctness and Safety for a quick quality baseline), guideline judges (natural language — pass/fail rules you write in plain English with Guidelines, for tone/policy/style), and custom LLM judges (fully custom — your own instructions and output type with make_judge(), for domain-specific quality). Two non-LLM scorer types sit alongside them: code-based scorers (deterministic Python checks with @scorer, no LLM call — exact match, format validation, latency) and third-party scorers (external metrics from open-source evaluation frameworks your team already trusts).
A1. 三种 LLM 判官,按"定制程度"从低到高排列:内置判官(开箱即用——像 Correctness、Safety 这种经过研究验证的判官,拿来做一个快速的质量基线)、准则判官(自然语言——用 Guidelines 写成的、用普通英文表达的通过/不通过规则,适合语气、政策、风格这类要求)、自定义 LLM 判官(完全定制——用 make_judge() 写自己的指令和输出类型,适合特定领域的质量判断)。另外还有两种不靠 LLM 的判官:代码判官(用 @scorer 装饰的确定性 Python 检查,不调用 LLM——精确匹配、格式校验、延迟检查)和第三方判官(来自开源评测框架、团队已经信任的外部指标)。
B Built-In Judges for Common Criteria
B1. MLflow's built-in judges aren't generic LLM calls wearing a judge costume — they're research-validated: developed through extensive research, validated against human expert judgment, and optimized for a specific evaluation criterion. That validation is the entire value proposition over writing your own prompt from scratch.
B1. MLflow 的内置判官不是披了个"判官"外壳的通用 LLM 调用——它们是经过研究验证的:经过大量研究开发出来,拿人类专家的判断去验证过,而且是针对某个具体评测维度优化过的。这种经过验证的保证,正是它比自己从零写一个 prompt 更有价值的地方。
| Judge | What it checks | What it needs |
|---|---|---|
Correctness | The response is factually correct against the ground truth | expectations |
Safety | The response is free of harmful, offensive, or unsafe content | Nothing extra |
RelevanceToQuery | The response directly addresses the user's query | Nothing extra |
RetrievalGroundedness | The response is grounded in the retrieved context, not hallucinated | Traces with RETRIEVER spans |
RetrievalSufficiency | The retrieved context has enough information for the ground-truth answer | expectations and RETRIEVER spans |
RetrievalRelevance | The retrieved documents are relevant to the query | Traces with RETRIEVER spans |
Read that table by its third column, not its first: Correctness and RetrievalSufficiency need expectations (ground truth) to run at all; Safety, RelevanceToQuery, RetrievalGroundedness, and RetrievalRelevance need none. This is File 19's D3 point in concrete form — three of the six need a trace with RETRIEVER spans, so a predict_fn that isn't fully instrumented silently breaks half this table.
这张表要按第三列来读,不是第一列:Correctness 和 RetrievalSufficiency 必须有 expectations(真值)才能跑;Safety、RelevanceToQuery、RetrievalGroundedness、RetrievalRelevance 什么都不需要。这正是 File 19 的 D3 讲的那个点的具体体现——六个里有三个需要带 RETRIEVER span 的 trace,所以一个没打全标记的 predict_fn,会悄无声息地让这张表里一半的判官失效。
The course also names a fuller list without detailing it: Guidelines and ExpectationsGuidelines (which are really the Section C guideline-judge family surfacing early), plus multi-turn scorers like ConversationCompleteness and UserFrustration for evaluating an entire conversation rather than one turn.
课程还点了一个更完整的列表,但没展开讲:Guidelines 和 ExpectationsGuidelines(其实就是 File 22 要讲的准则判官家族提前露了个脸),再加上像 ConversationCompleteness、UserFrustration 这类多轮对话判官,评测的是整段对话,不是单独一轮。
B3 Example Usage Pattern — Four Steps
The course's interactive four-step walkthrough, the complete pattern every built-in-judge evaluation follows: (1) define the agent — a traced function accepting inputs keys as kwargs; MLflow applies @mlflow.trace automatically if it isn't already traced. (2) choose a scorer — import and instantiate a built-in judge, optionally overriding its model. (3) build the evaluation dataset — records of inputs plus optional expectations with ground-truth facts. (4) evaluate — pass data, agent, and scorers into mlflow.genai.evaluate(); results log automatically.
课程这个交互式的四步走流程,是每一次用内置判官做评测都会走的完整模式:(1)定义 agent——一个打了 trace 的函数,接受 inputs 里的键作为关键字参数;如果没打标记,MLflow 会自动套上 @mlflow.trace。(2)选判官——import 并实例化一个内置判官,可以选择性地换掉它默认用的模型。(3)搭评测数据集——每条记录是 inputs 加上可选的 expectations,里面放真值事实。(4)跑评测——把数据、agent、判官一起传进 mlflow.genai.evaluate();结果自动记录下来。
CCAR-P crosswalk
- D4 (eval dataset/framework design) — the "what it needs" column is the exam-relevant detail: a scenario question that gives you a judge and a dataset without
expectationsis testing whether you noticeCorrectnesscan't run without ground truth. - D1 (architecture) — the judge spectrum (built-in → guideline → custom, plus code-based and third-party) is the full taxonomy a D1 question is likely to ask you to place a given evaluation need into.
中文摘要
- D4(评测数据集/框架设计)——"需要什么"这一列是跟考试最相关的细节:如果题目给你一个判官和一个没有
expectations的数据集,考的就是你能不能看出Correctness没有真值根本跑不起来。 - D1(架构)——判官谱系(内置 → 准则 → 自定义,加上代码判官和第三方判官)是 D1 题目最可能要求你把某个具体评测需求,归位到哪个类型里的那套完整分类。
The "what it needs" column is the single most actionable row in this file for FM Insight: before anyone can even run Correctness against a GFEBS/Navy ERP-querying agent, there has to be a reconciled, authoritative ground-truth source for expectations — which is exactly the reconciliation discipline audit remediation is already building for other reasons (Fund Balance with Treasury, intragovernmental eliminations). That reconciled data doubles as the agent's evaluation ground truth almost for free. Safety and RelevanceToQuery, needing nothing extra, are the two judges FM Insight could turn on today, before any ground-truth dataset exists, as a baseline floor on any agent already in a pilot.
"需要什么"这一列,是这个文件里对 FM Insight 最能直接拿去用的一行:在任何人能对一个查询 GFEBS/Navy ERP 的 agent 跑 Correctness 之前,必须先有一个已核对过、权威的真值来源,给 expectations 用——而这正是审计整改本来就在为了别的原因(跟财政部的资金余额核对、政府间消除分录)而建的那套核对纪律。这份已经核对好的数据,几乎可以免费拿来当 agent 的评测真值用。Safety 和 RelevanceToQuery 什么都不需要,是 FM Insight 今天就能打开的两个判官,在还没有任何真值数据集之前,就可以先给任何试点中的 agent 加一道底线。
File 21 Demo — Using MLflow Built-In Judges
Big picture first: this demo is File 20's four-step pattern, executed twice back to back with two different judges, then once more with both judges combined. The point it's actually making, past the mechanics, is in Section D — combining scorers isn't a convenience, it changes the shape of the run: one set of traces instead of two, which means half the LLM calls to the agent and a single unified comparison view instead of two runs you'd have to line up by hand.
先说大图景:这个 demo 就是把 File 20 的四步模式,用两个不同的判官各跑一遍,再把两个判官合在一起跑第三遍。它真正要讲的点,超出机械步骤本身,在 D 部分——把判官合并起来跑不只是图个方便,它改变了这次运行的"形状":只生成一套 trace,而不是两套,意味着对 agent 的 LLM 调用减半,而且得到的是一个统一的对比视图,不用自己手动把两次运行的结果对齐。
A Classroom Setup
%run ../Includes/Classroom-Setup-02 — the second of the four per-module setup scripts covered in full in 6.4, loading the same shared agent plus the correctness_eval_endpoint and safety_eval_endpoint Unity Gateway services and populating the learner's volume with correctness_eval.json and safety_eval.json from the Includes/artifacts staging copy (6.6).
%run ../Includes/Classroom-Setup-02——6.4 完整讲过的四个按模块划分的 setup 脚本里的第二个,加载同一个共享 agent,再加上 correctness_eval_endpoint 和 safety_eval_endpoint 两个 Unity Gateway 服务,并把 correctness_eval.json 和 safety_eval.json 从 Includes/artifacts 这个临时副本(6.6)放进学员自己的 volume 里。
B Correctness Evaluation
B1. Correctness(model=correctness_eval_endpoint) — the judge's model is specified as databricks:/dbacademy.agent_eval.judge-model, the same shared Unity Gateway service from 6.5, not a hardcoded model name: every judge call goes through Unity Gateway, where permissions, rate limits, and usage tracking apply exactly as File 19 E described. The dataset loads from /Volumes/{catalog_name}/{schema_name}/agent_vol/correctness_eval.json, each entry holding inputs (the query) and expectations.expected_facts. B2. The call itself is File 19's three parameters exactly: data=eval_dataset, predict_fn=lambda input: agent.predict({"input": input}), scorers=[correctness_eval]. B3. The returned EvaluationResult exposes run_id, metrics (aggregated), and result_df (per-row scores and rationales) — clicking any row opens the full trace, which is the File 19 C4 pattern made literal in the UI rather than via mlflow.search_traces().
B1. Correctness(model=correctness_eval_endpoint)——判官的模型指定为 databricks:/dbacademy.agent_eval.judge-model,就是 6.5 讲过的那个共享 Unity Gateway 服务,不是写死的模型名字:每一次判官调用都会经过 Unity Gateway,权限、速率限制、用量追踪都会按 File 19 E 讲的那样生效。数据集从 /Volumes/{catalog_name}/{schema_name}/agent_vol/correctness_eval.json 加载,每条记录带 inputs(查询内容)和 expectations.expected_facts。B2. 这次调用本身,就是 File 19 讲的那三个参数:data=eval_dataset、predict_fn=lambda input: agent.predict({"input": input})、scorers=[correctness_eval]。B3. 返回的 EvaluationResult 带 run_id、metrics(汇总)和 result_df(逐行打分和理由)——点开任何一行就能打开完整 trace,这正是 File 19 C4 讲的那套模式,在界面上具体落地的样子,不用再手写 mlflow.search_traces()。
C Safety Evaluation
C1. Safety(model=safety_eval_endpoint) needs no ground truth: the safety dataset only holds inputs, no expected_facts, because the judge checks the response in isolation — making it easy to build adversarial test cases that probe the agent's guardrails without needing a "correct answer" to compare against. C2. Same evaluate() call shape, swap in safety_eval_dataset and [safety_eval]. C3. Safety scores are binary — yes (safe) or no (unsafe) — with a rationale naming which safety category was flagged, if any; the course's own framing is explicit that the thing worth looking for is cases where the agent was tricked into producing harmful content despite its system prompt.
C1. Safety(model=safety_eval_endpoint) 不需要真值:安全数据集只有 inputs,没有 expected_facts,因为这个判官是单独评判这条回复本身的——这让构造对抗性测试案例变得容易,不需要先有一个"正确答案"去比对。C2. evaluate() 的调用形式完全一样,只是换成 safety_eval_dataset 和 [safety_eval]。C3. Safety 的打分是二元的——yes(安全)或 no(不安全)——理由会指出触发了哪个安全类别(如果有的话);课程原文明确说,真正值得关注的,是那些 agent 被诱导、在系统提示的约束之下仍然产出了有害内容的案例。
D Evaluating Multiple Scorers at Once
Passing scorers=[safety_eval, correctness_eval] in a single call changes the shape of the run, not just the convenience: one set of traces is generated instead of two (fewer LLM calls to the agent, since each row is only predicted once), all judge scores land side-by-side in the same results dataframe, and the MLflow UI shows one unified comparison view across dimensions instead of two runs to reconcile by hand. The course names this the recommended pattern for production evaluation pipelines assessing multiple quality dimensions simultaneously.
在一次调用里传入 scorers=[safety_eval, correctness_eval],改变的不只是方便程度,而是这次运行的"形状":只生成一套 trace,不是两套(对 agent 的 LLM 调用也更少,因为每一行只被预测一次),所有判官的打分都落到同一个结果 dataframe 里、并排放着,MLflow 界面显示的是一个跨维度的统一对比视图,不需要自己手动去对齐两次运行的结果。课程把这个模式定为生产环境评测管道的推荐做法——需要同时评估多个质量维度的时候。
E Conclusion
Four things done: configured built-in Correctness and Safety judges pointed at a Unity Gateway model service; loaded evaluation datasets from a UC volume and ran evaluate() against each; inspected per-row results including scores, rationales, and traces; and combined both scorers into a single run.
完成了四件事:配置了指向 Unity Gateway 模型服务的内置 Correctness 和 Safety 判官;从 UC volume 加载评测数据集,并分别对每个跑了 evaluate();查看了逐行结果,包括打分、理由和 trace;把两个判官合并成一次运行。
CCAR-P crosswalk
- D4 (eval dataset/framework design) — the correctness dataset needing
expected_factswhile the safety dataset needs onlyinputsis the exact concrete pairing a D4 scenario question is built from: two datasets, same agent, different required shape. - D3 (integration/protocol choice) — routing every judge call through a named Unity Gateway endpoint rather than a hardcoded model string is a protocol/integration choice worth recognizing on its own, independent of what the judge evaluates.
中文摘要
- D4(评测数据集/框架设计)——correctness 数据集需要
expected_facts,而 safety 数据集只需要inputs,这正是 D4 场景题最典型的素材:同一个 agent,两个数据集,要求的结构却不一样。 - D3(集成/协议选择)——把每一次判官调用都路由到一个命名的 Unity Gateway 端点,而不是写死一个模型字符串,本身就是一个值得单独认出来的协议/集成选择,跟判官评测的是什么内容无关。
Section D's combined-scorers pattern is directly reusable: any FM Insight agent evaluation should default to one evaluate() call with every applicable judge, not one call per judge, both to halve the load on the agent and to get a single reconciled view auditors could review rather than several runs they'd have to cross-reference themselves. The Safety-needs-no-ground-truth point also matters operationally: it's the one judge FM Insight can run against adversarial, deliberately out-of-scope GFEBS/Navy ERP queries today, as a guardrail check, independent of how mature the Correctness ground-truth dataset is.
D 部分讲的"合并判官"这个模式,可以直接拿去用:任何 FM Insight agent 的评测,都应该默认用一次 evaluate() 调用,把所有适用的判官都放进去,而不是每个判官单独跑一次——一方面能把对 agent 的负载减半,另一方面能得到一份审计人员可以直接复核的、已经对齐好的结果,而不是几份需要自己交叉核对的运行结果。"Safety 不需要真值"这一点在操作层面也很有用:这是 FM Insight 今天就能拿来跑的一个判官,针对那些故意超出范围、带对抗性的 GFEBS/Navy ERP 查询做护栏检查,不用等 Correctness 的真值数据集有多成熟。
File 22 Lecture — Guideline Judges
Big picture first: File 20's table showed Correctness needs expectations.expected_facts — ground truth that is objectively checkable. Guideline judges answer a different question: what about requirements that aren't facts at all, but rules — "must be professional," "must mention the 30-day window," "must not use slang"? The move is to let a domain expert write the rule in plain English instead of asking an engineer to encode it, and then split that idea in exactly two directions: one rule applied uniformly to every row, or a different rule per row.
先说大图景:File 20 的表里讲过,Correctness 需要 expectations.expected_facts——这是可以客观核查的真值。准则判官要回答的是另一个问题:那些根本不是"事实"、而是"规则"的要求怎么办——"必须专业"、"必须提到 30 天这个期限"、"不能用俚语"?解决办法是让业务专家直接用普通英文写规则,不用让工程师把它翻译成代码,然后把这个想法朝两个方向各展开一种:同一条规则套用到每一行,或者每一行用不同的规则。
A Two Types of Guideline Judges
A1. Guidelines() applies the same rules to every row — ideal for tone, style, formatting, and compliance that should hold uniformly across the whole dataset. ExpectationsGuidelines() applies different rules per example, read from each row's own expectations.guidelines field — ideal for scenario-specific criteria that genuinely differ row to row.
A1. Guidelines() 把同一套规则套用到每一行——适合语气、风格、格式、合规性这类应该在整个数据集上统一生效的要求。ExpectationsGuidelines() 每个例子用不同的规则,从每一行自己的 expectations.guidelines 字段里读——适合那些真的是逐行不同的场景化标准。
| Global guidelines | Per-row guidelines | |
|---|---|---|
| Scorer | Guidelines() | ExpectationsGuidelines() |
| Rules | The same rules for every row | Different rules for each example |
| Use for | Tone, style, formatting, compliance | Scenario-specific criteria |
A2 Implementation Patterns
Global: Guidelines(name="professional_tone", guidelines=["The response must use professional language", "The response must not use slang", "The response must address the user respectfully"], model="databricks:/catalog.schema.judge-model"), passed to scorers=[tone_guidelines] once for the whole run. Per-row: each record carries its own rules inside expectations.guidelines — e.g. a refund-policy row requiring the response mention the 30-day window and the receipt requirement, a support-contact row requiring a contact method and conciseness — and the scorer is instantiated with no arguments at all: scorers=[ExpectationsGuidelines()], since the rules travel with the data, not the judge.
全局用法:Guidelines(name="professional_tone", guidelines=["The response must use professional language", "The response must not use slang", "The response must address the user respectfully"], model="databricks:/catalog.schema.judge-model"),整次运行只传一次,放进 scorers=[tone_guidelines]。逐行用法:每条记录自己把规则带在 expectations.guidelines 里——比如一条退款政策的记录,要求回复提到 30 天窗口和保留收据的要求;一条联系客服的记录,要求给出联系方式并保持简洁——而判官实例化的时候不带任何参数:scorers=[ExpectationsGuidelines()],因为规则是跟着数据走的,不是跟着判官走的。
B Advantages and Best Practices
B1. Why guideline judges. Accessible to experts (domain experts write rules without coding), fast to iterate (change a rule without changing code), interpretable (the rules document what you expect, in plain language anyone can read), and flexible (rules capture complex, context-dependent requirements that a code-based scorer can't express cleanly).
B1. 为什么要用准则判官。对专家友好(业务专家不用写代码就能写规则)、迭代快(改规则不用改代码)、可解释(规则本身就用普通语言写清楚了你期望什么,谁都能看懂)、灵活(能表达代码判官很难干净表达的那种复杂、依赖上下文的要求)。
B2. Writing effective guidelines — the one rule that matters most: refer to inputs as "the request" and outputs as "the response," because the LLM judge automatically extracts request/response data from the trace using exactly that vocabulary. Recommended phrasing: "The response must …" (required), "The response must not …" (prohibited), "The response may optionally …" (suggested, not required). Be specific and concrete — "the response must cite the source document" beats "the response should be credible" — write guidelines that can be objectively verified, focus on observable attributes, leave as little ambiguity as possible, and test each guideline against multiple examples before trusting it.
B2. 怎么写好的准则——最关键的一条规则:把输入称为"the request",把输出称为"the response",因为 LLM 判官会用正好这套词汇,从 trace 里自动抽取 request/response 数据。推荐的措辞方式:"The response must …"(必须)、"The response must not …"(禁止)、"The response may optionally …"(建议但不强制)。要具体、要能落地——"回复必须引用来源文档"比"回复应该让人觉得可信"要好得多——写的准则要能被客观验证,聚焦在可观察的属性上,尽量减少歧义,而且在信任一条准则之前,先拿多个例子测一遍。
Writing a guideline as "the question must be clear" instead of "the request must be clear" isn't a style nitpick — it can silently fail to bind to the trace data the judge is actually extracting. The request/response vocabulary is a hard requirement, not a suggestion.
把准则写成"这个问题必须清楚"而不是"the request must be clear",不只是用词习惯的问题——它可能会悄无声息地没对上判官实际从 trace 里抽取的数据。request/response 这套词汇是硬性要求,不是建议。
CCAR-P crosswalk
- D4 (eval dataset/framework design) — "global vs. per-row" is a design decision with a concrete tell: if a scenario's rules genuinely vary row to row, forcing them into a single global Guidelines() judge is the bug a D4 question is testing for.
- D1 (architecture) — guideline judges are the second rung of File 20's judge spectrum; recognizing when a requirement belongs here (a rule) rather than in built-in judges (a fact check) or custom judges (full flexibility) is itself a D1-level architectural judgment.
中文摘要
- D4(评测数据集/框架设计)——"全局 vs. 逐行"是一个有具体破绽的设计决策:如果某个场景的规则本来就是逐行不同的,硬塞进一个全局的 Guidelines() 判官,正是 D4 题目要考的那个 bug。
- D1(架构)——准则判官是 File 20 判官谱系的第二级;能判断一个要求到底该归在这里(一条规则),还是归在内置判官(事实核查)或自定义判官(完全自由)里,本身就是 D1 级别的架构判断力。
This is the judge type that covers the parts of FM Insight's audit-remediation work that aren't fact-checkable at all. "The response must cite the specific USSGL account and TAS/BETC it used," "the response must not state a balance without naming its source system," "the response must flag when an appropriation is closed or expired" are all guidelines, not correctness checks — there's no single expected_facts to compare against, just a rule about what a defensible answer must contain. Per-row ExpectationsGuidelines() maps cleanly onto the reality that a GFEBS query and a Navy ERP query may need different disclosure rules even when both return "a balance."
这是覆盖 FM Insight 审计整改工作里那些根本没法用"事实核查"来判断的部分的判官类型。"回复必须引用它用到的具体 USSGL 账户和 TAS/BETC"、"回复不能不说明来源系统就直接给出一个余额"、"回复必须标注某个拨款账户是否已结清或已过期"——这些都是准则,不是正确性检查——没有一个单一的 expected_facts 可以拿来比对,只有一条关于"一个站得住脚的答案必须包含什么"的规则。逐行的 ExpectationsGuidelines() 正好对应一个现实情况:GFEBS 查询和 Navy ERP 查询即便都返回"一个余额",可能也需要不同的披露规则。
File 23 Demo — Guideline Judges with MLflow
Big picture first: this demo makes File 22's abstract distinction concrete by deliberately choosing a guideline that's easy to verify by eye — "the response should be in Spanish" — so the pass/fail boundary is unambiguous, then layers in a second concept File 17 and 19 only mentioned in passing: evaluating data that already has outputs, with predict_fn omitted entirely, the "answer sheet" mode.
先说大图景:这个 demo 把 File 22 讲的抽象区别变得具体,故意选了一条肉眼就能判断对错的准则——"回复应该是西班牙语"——让通过/不通过的边界完全没有争议,然后叠加上 File 17、19 只是顺带提过的第二个概念:评测已经带有 outputs 的数据,predict_fn 整个省略掉,也就是"答案卷"模式。
A-B Setup and Three Datasets
%run ../Includes/Classroom-Setup-02 — the same setup as File 21. Three datasets, each demonstrating a different pattern: guidelines_eval.json (inputs only — the agent generates outputs at evaluation time), guidelines_eval_pre_gen.json (pre-generated inputs and outputs — no agent call needed), and guidelines_eval_row_level.json (per-row guidelines living in each row's own expectations field).
%run ../Includes/Classroom-Setup-02——和 File 21 一样的 setup。三个数据集,各演示一种不同的模式:guidelines_eval.json(只有 inputs——agent 在评测时现场生成输出)、guidelines_eval_pre_gen.json(预先生成好的 inputs 和 outputs——不需要调用 agent)、guidelines_eval_row_level.json(逐行的准则,放在每一行自己的 expectations 字段里)。
C Global Guidelines Evaluation
C1. Guidelines(name="spanish", guidelines=["The response should be in Spanish"], model=guidelines_endpoint) — deliberately chosen so the agent, which answers in English, fails both inputs; evaluate(data=guidelines_dataset, predict_fn=lambda input: agent.predict({"input": input}), scorers=[language_guideline]) runs the full agent call. C2. Results inspected the File 21 way: run_id, metrics, result_df. C3-C4. The same judge against guidelines_eval_pre_gen.json, this time with predict_fn omitted entirely — the dataset already has outputs, so evaluation skips agent invocation completely. One row's pre-generated response is in Spanish (pass), the other in English (fail), proving the judge grades whatever text sits in outputs regardless of where it came from.
C1. Guidelines(name="spanish", guidelines=["The response should be in Spanish"], model=guidelines_endpoint)——故意选了这条规则,因为 agent 是用英文回答的,两条输入都会不通过;evaluate(data=guidelines_dataset, predict_fn=lambda input: agent.predict({"input": input}), scorers=[language_guideline]) 跑的是完整的 agent 调用。C2. 查看结果的方式和 File 21 一样:run_id、metrics、result_df。C3-C4. 同一个判官,换成 guidelines_eval_pre_gen.json,这次 predict_fn 整个省略——数据集里已经有 outputs 了,所以评测完全跳过了调用 agent 这一步。其中一行预先生成的回复是西班牙语(通过),另一行是英文(不通过),说明判官评判的就是 outputs 里实际放着的文本,不管它是哪来的。
Omitting predict_fn is the mechanism behind "re-score a batch of old production responses with a new judge" or "evaluate a human-written answer sheet" — neither needs the agent re-run. This is the same evaluate() call shape from File 19 C1, just with one parameter dropped, not a different function.
省略 predict_fn 正是"用一个新判官重新给一批历史生产回复打分"或者"评测一份人工写的答案卷"背后的机制——这两种情况都不需要重新跑 agent。这还是 File 19 C1 讲的那套 evaluate() 调用形式,只是少传了一个参数,不是换了个新函数。
D Per-Row Guidelines with ExpectationsGuidelines
D1. ExpectationsGuidelines(name="expected_guidelines", model=guidelines_endpoint) is instantiated with no rules of its own — it reads each row's own expectations.guidelines list, enabling scenario-specific evaluation in one run instead of running a separate evaluation per rule set. The course is explicit about a requirement easy to miss: ExpectationsGuidelines requires an outputs field, passed either directly in the dataset or via a trace containing them — this demo passes them directly. D2. Each row is scored against its own guidelines; a row that fails shows which specific guideline it violated, not just a pass/fail bit.
D1. ExpectationsGuidelines(name="expected_guidelines", model=guidelines_endpoint) 实例化的时候不带任何自己的规则——它读的是每一行自己的 expectations.guidelines 列表,让场景化的评测能在一次运行里完成,不用针对每套规则单独跑一次。课程明确点出一个容易漏掉的要求:ExpectationsGuidelines 需要一个 outputs 字段,可以直接放在数据集里,也可以通过包含它的 trace 传进去——这个 demo 是直接传的。D2. 每一行都按自己的准则打分;不通过的那一行,会显示具体违反了哪一条准则,不是一个简单的通过/不通过标志。
E Conclusion
Three things done: applied global Guidelines against uniform criteria (a Spanish-language requirement); evaluated pre-generated outputs with no agent call by omitting predict_fn; and used ExpectationsGuidelines for per-row, scenario-specific criteria.
完成了三件事:用全局 Guidelines 跑了统一标准的评测(西班牙语要求);省略 predict_fn,评测了预先生成好的输出,不用调用 agent;用 ExpectationsGuidelines 做了逐行、场景化的评测。
CCAR-P crosswalk
- D4 (eval dataset/framework design) — the "answer sheet" mode (no predict_fn, outputs already present) is the exact design the course uses to let an exam question test whether you can evaluate historical or human-written responses without re-running an agent.
- D3 (integration/protocol choice) —
ExpectationsGuidelines' hard requirement for anoutputsfield (direct or via trace) is a protocol detail worth holding onto independent of what the guidelines say.
中文摘要
- D4(评测数据集/框架设计)——"答案卷"模式(不传 predict_fn,outputs 已经有了)正是课程用来让考题测试"能不能不重跑 agent 就评测历史或人工写的回复"这个能力的设计。
- D3(集成/协议选择)——
ExpectationsGuidelines对outputs字段的硬性要求(直接给,或通过 trace 给),是一个值得记住的协议细节,跟准则写的是什么内容无关。
The answer-sheet pattern is the practical path to standing up FM Insight evaluation on day one: before any agent is deployed, every historical NFR response, every closed audit sample, every reconciliation memo a human already wrote can be loaded as pre-generated outputs and scored against guidelines today — "does this memo cite its source system," "does this response name the TAS/BETC it used" — building confidence in the judges and the guideline wording before a single AI agent answer is ever evaluated. That sequencing (judge first, agent-generated answers second) is a defensible, low-risk way to introduce evaluated AI into an audit-remediation workflow that's already under DODIG scrutiny.
答案卷这个模式,是第一天就能把 FM Insight 评测搭起来的实际路径:在任何 agent 部署之前,每一份历史的 NFR 回复、每一个已结案的审计样本、每一份人工已经写好的核对备忘录,今天就可以当作预先生成的 outputs 加载进来,拿准则去打分——"这份备忘录有没有引用它的来源系统"、"这份回复有没有点明它用的 TAS/BETC"——在还没有任何一个 AI agent 的答案被评测之前,就先把判官本身和准则的措辞打磨到有信心。这种顺序(先把判官立起来,再去评 agent 生成的答案)对于一个已经处在 DODIG 审查之下的审计整改工作流来说,是一种站得住脚、风险较低的引入"被评测的 AI"的方式。
File 24 Lecture — Custom Judges and Feedback
Big picture first: this file closes out File 20's spectrum from the two custom ends — code-based scorers (@scorer, deterministic, no LLM) and custom LLM judges (make_judge(), your own instructions and output type) — and then names the one structure every judge type in Folder 3, built-in through custom, actually returns: a Feedback object with a value, a rationale, and metadata. The rationale is not decoration; it is the reason a judge's output is debuggable at all.
先说大图景:这个文件从两个"完全自定义"的方向,把 File 20 的判官谱系收尾——代码判官(@scorer,确定性,不调用 LLM)和自定义 LLM 判官(make_judge(),自己写指令和输出类型)——然后点出一个事实:从内置判官到自定义判官,Folder 3 里每一种判官类型实际返回的,都是同一种结构:一个带 value、rationale、metadata 的 Feedback 对象。Rationale 不是装饰性的东西;它是让判官的输出能够被调试的根本原因。
A Code-Based Scorers
A1. The @scorer decorator converts a Python function into a reusable evaluation component. The function can accept any combination of inputs (dict — the app's raw input), outputs (any — the app's raw output), expectations (dict — ground truth), and trace (the complete mlflow.entities.Trace, every span and metadata). This is the imperative approach: evaluation logic written directly in Python, full control over scoring, data access, and error handling — use it when criteria are expressible as deterministic code (format checks, length validation, keyword matching, schema verification).
A1. @scorer装饰器把一个 Python 函数变成一个可复用的评测组件。这个函数可以接受 inputs(dict——应用的原始输入)、outputs(任意类型——应用的原始输出)、expectations(dict——真值)、trace(完整的 mlflow.entities.Trace,所有 span 和元数据)这几个参数的任意组合。这是"命令式"的方式:评测逻辑直接用 Python 写出来,打分、数据访问、错误处理全都由你自己完全掌控——适合那种能写成确定性代码的标准(格式检查、长度校验、关键词匹配、schema 校验)。
Two return styles: with a Feedback object — Feedback(value="yes", rationale=f"Response length ({word_count} words) is appropriate") — gives full interpretability, you can see why a row passed or failed; or a primitive return — just return "yes" if 20 <= wc <= 100 else "no" — more concise for straightforward pass/fail, but with no rationale for the decision.
两种返回方式:返回一个 Feedback 对象——Feedback(value="yes", rationale=f"Response length ({word_count} words) is appropriate")——能完全解释清楚,你能看到为什么某一行通过或不通过;或者返回一个基本值——直接 return "yes" if 20 <= wc <= 100 else "no"——对简单的通过/不通过判断更简洁,但没有任何理由说明这个判断是怎么来的。
B Custom LLM Judges
B1. When to use them. Domain-specific criteria unique to the application, nuanced assessments beyond what built-in judges capture, proprietary standards such as regulations and compliance rules, and multi-signal logic that combines several data sources.
B1. 什么时候用。应用特有的领域标准、超出内置判官能力范围的细微判断、专有标准(比如法规和合规规则)、以及要综合多个数据来源的多信号逻辑。
B2. make_judge() lets you define criteria in natural language; MLflow handles the LLM invocation, response parsing, and Feedback generation automatically — the declarative approach, the mirror image of @scorer's imperative one. Two patterns: a pass/fail judge with feedback_value_type=Literal["yes", "no"], a name, and instructions templated with {{inputs}}/{{outputs}}/{{expectations}}; or a multi-category judge with a custom Literal type — e.g. Literal["excellent", "acceptable", "poor"] — using structured outputs to enforce the category set. Both @scorer and make_judge() work identically in offline evaluation (evaluate()) and in production monitoring (ScorerScheduleConfig) — the same judge logic, no rewrite needed to move from development to production.
B2. make_judge() 让你用自然语言定义标准;MLflow 自动处理 LLM 调用、解析响应、生成 Feedback——这是"声明式"的方式,正好跟 @scorer 的"命令式"方式相对。两种模式:通过/不通过判官,用 feedback_value_type=Literal["yes", "no"],加一个 name 和带模板变量 {{inputs}}/{{outputs}}/{{expectations}} 的 instructions;或者多类别判官,用自定义的 Literal 类型——比如 Literal["excellent", "acceptable", "poor"]——靠结构化输出强制限定在这几个类别里。@scorer 和 make_judge() 在离线评测(evaluate())和生产监控(ScorerScheduleConfig)里的用法完全一样——同一套判官逻辑,从开发阶段搬到生产阶段不用重写。
C Feedback Objects and Rationales
C1. Every MLflow judge — built-in, guideline, code-based, or custom LLM — returns a structured Feedback object, never a bare scalar underneath. The course's own anatomy diagram walks through a concrete make_judge()-built judge, response_completeness: it reads inputs, outputs, expectations, and optionally the full trace; it's defined with instructions templated against {{inputs}}/{{outputs}}, a feedback_value_type of Literal["complete", "partial", "incomplete"], and a model pointing at a Unity Gateway model service (dbacademy.agent_eval.custom-judge-model — the same pattern as every judge model in this course); and it returns a Feedback with name="response_completeness", value="complete", a human-readable rationale, and source=LLM_JUDGE. For @scorer, source is auto-populated as CODE; for make_judge(), as LLM_JUDGE — set manually only when calling your own LLM inside a @scorer. The Feedback attaches to the trace as an assessment, read in the MLflow UI or with search_traces() — the exact mechanism from File 19 C4.
C1. 不管是内置判官、准则判官、代码判官,还是自定义 LLM 判官——每一个 MLflow 判官底层返回的都是一个结构化的 Feedback 对象,从来不是一个裸的标量值。课程自己的这张解剖图,完整走了一遍一个用 make_judge() 搭的判官 response_completeness:它读 inputs、outputs、expectations,以及需要时读完整的 trace;定义它的时候用了模板化的 instructions(里面有 {{inputs}}/{{outputs}})、一个 Literal["complete", "partial", "incomplete"] 的 feedback_value_type、以及一个指向 Unity Gateway 模型服务的 model(dbacademy.agent_eval.custom-judge-model——跟这门课里每一个判官模型用的是同一套模式);返回的是一个 Feedback,带 name="response_completeness"、value="complete"、一段人读得懂的 rationale,以及 source=LLM_JUDGE。对 @scorer 来说,source 会自动填成 CODE;对 make_judge() 来说,自动填成 LLM_JUDGE——只有在 @scorer 里面自己调用 LLM 的时候,才需要手动设置。Feedback 会作为一个评估结果挂到 trace 上,可以在 MLflow 界面里看,也可以用 search_traces() 读——跟 File 19 C4 讲的是同一套机制。
C2. Why rationales matter. Debugging — see why a response failed, not just that it failed. Judge validation — check that the judge's own reasoning is sound, not just that its verdict matches expectations. Pattern finding — themes that repeat across rationales point to systematic issues, not one-off failures. Communication — explain results to stakeholders who weren't in the room for the evaluation design. Practical workflow: read rationales for all failures to find patterns, spot-check rationales for passes to confirm the judge is reasoning correctly (not just getting lucky), extract common rationale phrases to categorize failure types, and share representative rationales when discussing evaluation with teams.
C2. 为什么 rationale 很重要。调试——能看到一个回复为什么失败,不只是知道它失败了。判官验证——核查判官自己的推理是不是合理,不只是看结论对不对。找规律——rationale 里反复出现的主题,指向的是系统性的问题,不是一次性的偶然失败。沟通——向那些没参与评测设计的相关人员解释评测结果。实际工作流:读所有失败案例的 rationale 找规律,抽查通过案例的 rationale 确认判官的推理是真的合理(不是蒙对了),从常见的 rationale 措辞里提炼出失败类型的分类,在跟团队讨论评测结果时分享有代表性的 rationale。
CCAR-P crosswalk
- D1 (architecture) — "every judge returns a Feedback object" is the unifying architectural fact across all four judge types in Folder 3; a D1 question that asks "what does a judge actually return" is testing exactly this, not the judge-specific scoring logic.
- D5 (LLM risk/failure modes) — C2's point that rationales let you "spot-check passes to ensure the judge is reasoning correctly" names a real failure mode directly: a judge reaching the right verdict for the wrong reason, which only a rationale review catches.
中文摘要
- D1(架构)——"每个判官都返回一个 Feedback 对象"是贯穿 Folder 3 所有四种判官类型的统一架构事实;D1 考题问"判官到底返回什么",考的就是这一点,不是某个具体判官的打分逻辑。
- D5(LLM 风险/失败模式)——C2 讲的"抽查通过案例的 rationale,确认判官推理是否合理",直接点出了一个真实的失败模式:判官得出了正确的结论,但理由是错的,只有复核 rationale 才能发现这一点。
Code-based scorers are the quiet workhorse for FM Insight: a @scorer checking that a response's cited TAS/BETC matches a valid, open appropriation, or that a dollar figure ties to the correct fiscal year format, is a deterministic, zero-LLM-cost check that should run on every evaluation alongside any LLM judge — exactly the kind of exact-match, format-validation use case the course names. The rationale discipline in C2 is directly transferable to the A-123 control-testing documentation FM Insight already produces: a judge's rationale, read and categorized the way the course recommends, is functionally a machine-generated first draft of the "explanation of deficiency" narrative a control tester would otherwise write by hand.
代码判官对 FM Insight 来说是个不起眼但很顶用的工具:用一个 @scorer 检查回复里引用的 TAS/BETC 是不是对应一个有效、未结清的拨款账户,或者一个金额数字是不是对应正确的财年格式,这是一个确定性、不用调用 LLM、不花钱的检查,应该跟任何 LLM 判官一起、在每次评测里都跑一遍——这正是课程点出的精确匹配、格式校验这类场景。C2 讲的"重视 rationale"这套纪律,可以直接搬到 FM Insight 已经在做的 A-123 控制测试文档上:一个判官的 rationale,按课程推荐的方式去读、去分类,本质上就是一份机器生成的"缺陷说明"初稿——否则这份说明得由控制测试人员手工写出来。
File 25 Demo — Custom Judges with MLflow
Big picture first: this demo builds the exact judge from File 24's anatomy diagram, response_completeness, then goes one step further than File 24 even mentioned — a second custom judge whose instructions contain {{trace}} instead of {{inputs}}/{{outputs}}, which hands the judge the entire span tree and lets it use tool calling to inspect span data directly. That's the first time in Folder 3 a judge reasons over the trace's structure, not just its final text.
先说大图景:这个 demo 搭的,正是 File 24 解剖图里那个判官——response_completeness——然后往前走了一步,连 File 24 都没提到的一步:第二个自定义判官,它的 instructions 里放的是 {{trace}},不是 {{inputs}}/{{outputs}},这会把整个 span 树交给判官,让它用工具调用的方式直接去检查 span 数据。这是 Folder 3 里第一次出现一个判官推理的是 trace 的结构本身,不只是最后那段文本。
A-B Setup and Dataset
Same Classroom-Setup-02. custom_eval.json deliberately has no expectations — there is no ground truth to check against, because this judge isn't assessing factual correctness, it's assessing whether a response is structurally complete.
同样是 Classroom-Setup-02。custom_eval.json 故意不带 expectations——没有真值可以比对,因为这个判官不是在评判事实对不对,而是在评判一个回复的结构是否完整。
C Standard Custom Judge — Response Completeness
make_judge(name="response_completeness", instructions=coherent_instructions, feedback_value_type=Literal["complete", "partial", "incomplete"], model=custom_eval_endpoint) — coherent_instructions comes pre-loaded from the agent eval config (another instance of the config-layer pattern from 6.4), templated against {{inputs}}/{{outputs}}. C1-C2. Same evaluate() shape as every file before it. The course flags an easy-to-miss consequence explicitly: because feedback_value_type is a Literal (categorical, not numeric), metrics comes back as an empty {} — MLflow can't average "complete"/"partial"/"incomplete" into a number. A boolean feedback type, used next in Section D, does produce a mean.
make_judge(name="response_completeness", instructions=coherent_instructions, feedback_value_type=Literal["complete", "partial", "incomplete"], model=custom_eval_endpoint)——coherent_instructions 是提前从 agent eval 的配置里加载好的(又是 6.4 讲的那套配置分层模式的一个实例),用 {{inputs}}/{{outputs}} 做模板。C1-C2. evaluate() 的调用形式跟前面每一个文件都一样。课程明确点出一个容易忽略的后果:因为 feedback_value_type 是一个 Literal(分类型,不是数值型),返回的 metrics 是一个空的 {}——MLflow 没法把"complete"/"partial"/"incomplete" 平均成一个数字。D 部分接下来要用的布尔反馈类型,才会真的产生一个均值。
D Trace-Based Custom Judge — Tool Usage
make_judge(name="tool_usage_validator", instructions=tool_usage_instructions, feedback_value_type=bool, model=custom_eval_endpoint). When instructions contain {{trace}}, the judge receives the full trace object and uses tool calling to inspect span data (inputs, outputs, tool calls, timing) directly — the model parameter becomes optional in this mode, since the judge's reasoning can lean on the structured span data itself. D1. gen_trace_data() wraps each agent call in its own mlflow.start_span(span_type=SpanType.AGENT), tags the trace with session and user metadata, and runs three queries. D2. mlflow.search_traces(locations=[experiment_id], filter_string=f"metadata.\`mlflow.trace.session\` = '{session_id}'") finds those three traces by session; calling tool_usage_judge(trace=trace) directly on one trace returns a Feedback with a boolean value and a rationale — a judge called like a function, not routed through evaluate(). D3-D4. evaluate(data=session_traces, scorers=[tool_usage_judge]) runs the same judge over all three at once; because feedback_value_type=bool, metrics now has a real mean — 1.0 meaning every trace passed.
make_judge(name="tool_usage_validator", instructions=tool_usage_instructions, feedback_value_type=bool, model=custom_eval_endpoint)。当 instructions 里带 {{trace}} 的时候,判官拿到的是完整的 trace 对象,并且直接用工具调用的方式去检查 span 数据(输入、输出、工具调用、时间)——这种模式下 model 参数变成可选的,因为判官的推理可以直接依赖结构化的 span 数据本身。D1. gen_trace_data() 把每一次 agent 调用包在它自己的 mlflow.start_span(span_type=SpanType.AGENT) 里,给 trace 打上 session 和用户的元数据,跑了三条查询。D2. mlflow.search_traces(locations=[experiment_id], filter_string=f"metadata.\`mlflow.trace.session\` = '{session_id}'") 按 session 把这三条 trace 找出来;直接对一条 trace 调用 tool_usage_judge(trace=trace),会返回一个带布尔 value 和 rationale 的 Feedback——判官被当作一个函数直接调用,没有经过 evaluate()。D3-D4. evaluate(data=session_traces, scorers=[tool_usage_judge]) 一次性对这三条跑同一个判官;因为 feedback_value_type=bool,metrics 这次有了一个真正的均值——1.0 表示三条全部通过。
feedback = tool_usage_judge(trace=trace) is easy to overlook as a detail, but it's a real capability: any make_judge() judge can be called like a plain function outside evaluate() entirely, for a quick one-off check or inside custom orchestration code — not only as a scorer in a batch run.
feedback = tool_usage_judge(trace=trace) 这个细节很容易被忽略,但它是一个真实存在的能力:任何用 make_judge() 搭的判官,都可以在 evaluate() 之外,像一个普通函数那样直接被调用——用来做一次快速的单独检查,或者嵌入到自己写的编排代码里,不只是作为批量运行里的一个判官而已。
E Conclusion
Three things done: created a standard custom judge with Literal feedback types; built a trace-based judge analyzing agent tool usage via {{trace}}; generated traces with session metadata and evaluated them both individually (direct call) and in batch (through evaluate()).
完成了三件事:用 Literal 反馈类型创建了一个标准的自定义判官;搭了一个通过 {{trace}} 分析 agent 工具使用情况的、基于 trace 的判官;生成了带 session 元数据的 trace,并分别用直接调用(单条)和 evaluate()(批量)两种方式对它们做了评测。
CCAR-P crosswalk
- D4 (eval dataset/framework design) — the Literal-vs-bool metrics gap (empty dict vs. a real mean) is the single most exam-ready gotcha in this file: a question could hand you a categorical judge and ask why
results.metricsis empty. - D1 (architecture) — trace-based judges (
{{trace}}, optional model, tool-calling over spans) are architecturally distinct from every other judge type covered so far, and worth recognizing as their own category rather than a variant of make_judge().
中文摘要
- D4(评测数据集/框架设计)——Literal 和 bool 在 metrics 上的差异(空字典 vs. 真正的均值),是这个文件里最像考题的一个坑:题目可能给你一个分类型判官,问你为什么
results.metrics是空的。 - D1(架构)——基于 trace 的判官(
{{trace}}、可选的 model、对 span 做工具调用)跟目前讲过的其他判官类型,架构上是不一样的,值得把它当成独立的一类来认,不只是 make_judge() 的一个变体。
Trace-based judges are the right tool for exactly the FM Insight concern File 18's crosswalk raised: confirming an agent called tools when the question actually needed GFEBS/Navy ERP data, and didn't when it didn't. A tool_usage_validator-style judge with {{trace}} and feedback_value_type=bool can check that directly against the span tree — did the agent call the right tool, with the right parameters, before answering — producing a clean pass-rate metric auditors could cite, rather than a categorical judgment that resists aggregation the way Section C's completeness judge does.
基于 trace 的判官,正是解决 File 18 crosswalk 里提到的那个 FM Insight 关切的合适工具:确认 agent 在问题真正需要 GFEBS/Navy ERP 数据的时候调用了工具,不需要的时候没调用。一个带 {{trace}} 和 feedback_value_type=bool 的 tool_usage_validator 式判官,可以直接针对 span 树做这个检查——agent 有没有在给出答案之前,用正确的参数调用了正确的工具——产出一个干净的通过率指标,可以直接给审计人员引用,而不是像 C 部分的完整性判官那样,是一个很难汇总的分类判断。
File 26 Lab — Applying Agent Evaluation
Big picture first: every demo in Module 2 ran against the same shared, already-tested airbnb@champion agent from Workspace-Setup (6.5). This lab deliberately doesn't — Classroom-Setup-02-Lab registers a brand-new NYC Taxi agent, unevaluated, specifically so the learner is practicing evaluation on something that hasn't already been proven to pass. That's not incidental: a lab evaluating a pre-validated agent would teach nothing about what to do when a judge actually fails.
先说大图景:Module 2 里每一个 demo,跑的都是同一个已经测试过的共享 agent——6.5 里 Workspace-Setup 注册的 airbnb@champion。这个 Lab 故意不这么做——Classroom-Setup-02-Lab 注册了一个全新的、还没评测过的 NYC Taxi agent,就是为了让学员练习评测的对象,不是一个已经被证明能通过的东西。这不是随意的安排:如果 Lab 评测的是一个已经验证好的 agent,根本学不到判官真的不通过的时候该怎么办。
A-B Setup and Testing the Agent
%run ../Includes/Classroom-Setup-02-Lab loads this fresh nyc_taxi agent, backed by the two SQL-UDF tools from 6.5's agent tools folder (calc_fare_est, trip_info). B1. Two exploratory calls establish what the agent actually does before any judge touches it: a trip-info query ("average trip distance from zip 10001 to 10002") that should exercise get_trip_info, and a fare-calculation query ("estimated fare for a 5.2 mile trip with a base fare of $3.50") that should exercise calculate_fare_estimate. This is File 18's pattern, repeated deliberately: look at what the agent does before measuring whether it does it well.
%run ../Includes/Classroom-Setup-02-Lab 会加载这个全新的 nyc_taxi agent,背后是 6.5 讲过的那个 agent tools 文件夹里的两个 SQL-UDF 工具(calc_fare_est、trip_info)。B1. 两次探索性的调用,是在任何判官介入之前,先搞清楚这个 agent 到底会做什么:一次是行程信息查询("从 10001 到 10002 的平均行程距离"),应该会触发 get_trip_info;一次是费用计算查询("5.2 英里、起步价 3.50 美元的预估车费"),应该会触发 calculate_fare_estimate。这正是 File 18 的模式,故意重复了一遍:先看 agent 做了什么,再去衡量它做得好不好。
C Built-In Judges Implementation
C1. The evaluation dataset pairs two NYC Taxi queries with expected_facts — notably, one of them includes a facts item that isn't about correctness at all: "Response includes 'Are there any additional questions I can help with?'", a verbatim-phrase requirement smuggled into a Correctness check. C2. Correctness(model=correctness_eval_endpoint) and Safety(model=safety_endpoint) — the same shared Unity Gateway judge services every prior file used. C3. evaluate(data=eval_dataset_builtin, predict_fn=..., scorers=[correctness_eval, safety_eval]) — File 21 D's combined-scorers pattern, applied immediately by default rather than built up step by step. C4. Results read the standard way: run_id, metrics, result_df.
C1. 评测数据集把两条 NYC Taxi 查询和 expected_facts 配对——值得注意的是,其中一条的事实项,根本跟"正确性"无关:"Response includes 'Are there any additional questions I can help with?'",这是把一个逐字匹配的措辞要求,悄悄塞进了 Correctness 检查里。C2. Correctness(model=correctness_eval_endpoint) 和 Safety(model=safety_endpoint)——跟前面每一个文件用的是同一套共享 Unity Gateway 判官服务。C3. evaluate(data=eval_dataset_builtin, predict_fn=..., scorers=[correctness_eval, safety_eval])——File 21 D 讲的"合并判官"模式,这里直接默认就这么用,不是一步步搭起来的。C4. 结果按标准方式读:run_id、metrics、result_df。
Requiring a verbatim closing phrase inside an expected_facts list conflates two different questions: "is the information correct" and "did it use this exact wording." A fact-based judge can only check the former reliably; the latter is what File 22's Guidelines ("the response must end with...") is actually built for. This lab's own dataset is a worked example of a design choice to notice, not necessarily copy.
在 expected_facts 列表里要求一句逐字匹配的结尾措辞,把两个不同的问题混在了一起:"信息对不对"和"用词是不是一字不差"。基于事实的判官只能可靠地检查前一个问题;后一个问题,正是 File 22 的 Guidelines("回复必须以……结尾")真正要解决的。这个 Lab 自己的数据集,是一个值得注意、但不一定该照抄的设计选择的实例。
C5 Update and Iterate
This is the lab's real payload: when the vague default system prompt ("You are an expert in answering questions regarding NYC Taxi data") fails to produce the expected facts, the fix is editing Includes/artifacts/configs/nyc_taxi_agent_config.yaml — the per-run staging copy from 6.6, not a source file — and re-registering the agent with a new alias, @challenger rather than @champion. The registration snippet repeats File 11/6.5's pattern exactly: load the YAML config, build resources=[DatabricksFunction(...)] from its tool names, mlflow.pyfunc.log_model(python_model=AGENT_PY, model_config=CONFIG_YAML, ...), then set_registered_model_alias(alias="challenger") and reload with models:/{UC_MODEL_NAME}@challenger. The choice of challenger over champion is the point: this new version hasn't earned promotion yet, it has only been registered for testing — exactly the champion/challenger pattern a production ML system uses before swapping which version actually serves traffic.
这是整个 Lab 真正的核心:当那个含糊的默认系统提示("你是回答 NYC Taxi 数据相关问题的专家")没能产出预期的事实时,解决办法是编辑 Includes/artifacts/configs/nyc_taxi_agent_config.yaml——6.6 讲过的那个按运行生成的临时副本,不是源文件——然后用一个新的别名重新注册这个 agent:@challenger,不是 @champion。注册这段代码,跟 File 11/6.5 的模式完全一样:加载 YAML 配置,从工具名字搭出 resources=[DatabricksFunction(...)],mlflow.pyfunc.log_model(python_model=AGENT_PY, model_config=CONFIG_YAML, ...),然后 set_registered_model_alias(alias="challenger"),再用 models:/{UC_MODEL_NAME}@challenger 重新加载。选 challenger 而不是 champion 这一点才是重点:这个新版本还没有赢得"晋升",它只是被注册出来供测试——这正是生产环境的机器学习系统在真正切换"由哪个版本服务流量"之前,会用的那套 champion/challenger 模式。
D Guideline Judges Implementation
D1. The global-guidelines dataset deliberately contains only inputs, no expectations at all — because Guidelines() carries its rules at the judge level, not the row level, per File 22's A1 distinction. D2. professional_guideline = Guidelines(name="professional_response", guidelines=["The response should be professional and courteous", "The response should include specific numerical values when providing calculations or statistics", "The response should clearly indicate when it's using NYC taxi data"], model=guidelines_endpoint) — three rules, none of them fact-checkable, all of them exactly what a guideline judge is for. D3. Same evaluate() shape, run against this judge alone.
D1. 全局准则的数据集故意只带 inputs,完全没有 expectations——因为按 File 22 A1 讲的区别,Guidelines() 的规则是挂在判官这一级的,不是挂在每一行上的。D2. professional_guideline = Guidelines(name="professional_response", guidelines=["The response should be professional and courteous", "The response should include specific numerical values when providing calculations or statistics", "The response should clearly indicate when it's using NYC taxi data"], model=guidelines_endpoint)——三条规则,没有一条是能靠事实核查的,全都正是准则判官该管的事。D3. 跟之前一样的 evaluate() 调用形式,单独针对这个判官跑一次。
E Comprehensive Evaluation Analysis
E1. The two prior runs' results are printed side by side — builtin_results and guidelines_results — making the point visible rather than stated: a correctness/safety run and a guidelines run measure genuinely different things, and comparing their metrics directly isn't meaningful (a correctness score and a guideline pass rate aren't the same unit). E2. The actual payoff: one evaluate() call combining [correctness_eval, professional_guideline] against eval_dataset_builtin — a fact-check judge and a rule-based judge, in the same run, exactly as File 21 D described for built-in judges, now shown to work identically across judge families.
E1. 把前面两次运行的结果并排打印出来——builtin_results 和 guidelines_results——这样做的目的是让一个事实变得直观可见,而不只是口头说一遍:一次 correctness/safety 的运行和一次 guidelines 的运行,衡量的根本是两种不同的东西,直接比较它们的 metrics 没有意义(一个正确性分数和一个准则通过率,根本不是同一个单位)。E2. 这里才是真正的收获:用一次 evaluate() 调用,把 [correctness_eval, professional_guideline] 合并在一起,跑在 eval_dataset_builtin 上——一个事实核查判官和一个基于规则的判官,放进同一次运行里,正是 File 21 D 对内置判官讲过的那个模式,现在证明它在不同判官家族之间也同样好用。
F Conclusion
Module 2's capstone, done: configured and executed built-in judges for correctness and safety; implemented a guideline judge for custom business rules; created properly structured datasets for each judge type (with and without expectations); analyzed results with metrics and result_df; and — the part that separates this lab from the demos — iterated on a failing agent by editing its config and re-registering a new, honestly-labeled @challenger version.
Module 2 的收尾之作,完成了:配置并跑了内置的 correctness 和 safety 判官;实现了一个针对自定义业务规则的准则判官;为每种判官类型(带 expectations 和不带的)搭了结构正确的数据集;用 metrics 和 result_df 分析了结果;以及——这一点把这个 Lab 和前面的 demo 区分开来——针对一个不通过的 agent 做了迭代:编辑它的配置,重新注册一个老老实实标记为 @challenger 的新版本。
CCAR-P crosswalk
- D4 (eval dataset/framework design) — C1's embedded exact-phrase requirement inside a correctness dataset is exactly the kind of design flaw a D4 exam scenario would present for critique: the fix isn't a better judge, it's splitting the requirement into the right judge type.
- D1 (architecture) — the champion/challenger alias pattern, surfaced here for the first time as something the learner does themselves rather than reads about, is the architectural mechanism behind every "promote a new version without touching consumers" claim made since 6.5.
- D5 (LLM risk/failure modes) — this lab is the one place in Folder 3 so far where a failure is expected and worked through, not just described; the iterate loop is itself a model answer for "what do you do when an agent fails evaluation."
中文摘要
- D4(评测数据集/框架设计)——C1 里嵌在正确性数据集中的逐字措辞要求,正是 D4 考题会拿出来让你评判的那种设计缺陷:解决办法不是换个更强的判官,而是把这个要求拆分到合适的判官类型里去。
- D1(架构)——champion/challenger 别名模式,第一次不是靠读课文、而是靠学员自己动手做出来,这正是 6.5 以来每一次"推送新版本而不动任何调用方"这个说法背后的架构机制。
- D5(LLM 风险/失败模式)——这个 Lab 是目前 Folder 3 里唯一一个真正预期会失败、并带你走一遍怎么处理的地方,不只是口头描述;这个迭代循环本身,就是"评测没通过该怎么办"这个问题的一份示范答案。
This lab's whole shape — register a fresh, unproven agent; discover it fails evaluation; fix the root cause (here, the system prompt) rather than the symptom; re-register under a challenger alias; re-run the same evaluation until it passes — is the exact rehearsal FM Insight needs before any GFEBS/Navy ERP-querying agent goes anywhere near production. The champion/challenger pattern specifically gives audit remediation a clean governance story: a new agent version is testable under @challenger with zero risk to whatever is currently serving under @champion, and promotion only happens once evaluation — correctness, safety, and the domain-specific guidelines FM Insight would write (citation requirements, disclosure rules) — actually passes. That is close to a ready-made answer to "how do you control-test an AI agent before it touches financial statement data," which is a live gap in the audit-remediation roadmap this course keeps mapping onto.
这个 Lab 的整体结构——注册一个全新、没验证过的 agent;发现它评测不通过;修复根本原因(这里是系统提示),不是症状本身;用 challenger 别名重新注册;重跑同一套评测直到通过——正是 FM Insight 在任何一个查询 GFEBS/Navy ERP 的 agent 真正接近生产环境之前,需要演练的那套流程。Champion/challenger 这个模式,专门给审计整改提供了一套干净的治理说法:一个新的 agent 版本可以在 @challenger 下测试,对当前正在 @champion 下服务的东西零风险,只有当评测——正确性、安全性,以及 FM Insight 自己会写的那些领域专属准则(引用要求、披露规则)——真正通过之后,才会被晋升。这几乎是对"在一个 AI agent 接触财务报表数据之前,怎么对它做控制测试"这个问题的一份现成答案,而这正是这门课一直在对应的审计整改路线图里,一个还没填上的实际空白。
File 27 Lecture — Offline vs. Online Evaluation Strategies
Big picture first: every evaluation run so far in Folder 3 has been offline — a curated dataset, run once, scored, done. This file names that as half the picture and builds the other half: production monitoring, where the same judges run continuously on live traffic. The real content isn't either half alone, it's the loop between them — production failures become new offline test cases, and only agents that already passed offline get shipped to produce that traffic in the first place.
先说大图景:到目前为止 Folder 3 里跑过的每一次评测,都是离线的——一个精心整理的数据集,跑一次,打分,完事。这个文件指出这只是半张图,然后把另一半补上:生产监控,同一批判官在真实流量上持续运行。真正的内容不是这两半各自是什么,而是它们之间的那个循环——生产环境里的失败案例变成新的离线测试用例,而只有已经通过离线评测的 agent,才有资格先上线去产生这些流量。
A Evaluation Strategy Overview — Two Complementary Approaches
A1. Offline (before deployment, curated datasets): curate a dataset of use cases and edge cases, run the agent on every row, score each response with judges, gate the release on the results — controlled and reproducible. Online (in production, real user traffic): trace every production request, score a sample of traces automatically, collect user feedback on answers, monitor quality and alert on drops — real-world and continuous. The version that passed offline ships; failures in production flow back as new offline test cases, closing the loop.
A1. 离线(部署之前,精心整理的数据集):整理一个覆盖常见用例和边界情况的数据集,对每一行跑 agent,用判官给每个回复打分,根据结果决定是否放行发布——可控、可复现。线上(生产环境,真实用户流量):给每一次生产请求都打上 trace,自动给一部分 trace 打分,收集用户对答案的反馈,监控质量并在下降时报警——贴近真实、持续不断。离线评测通过的版本才会上线;生产环境里的失败案例会反过来变成新的离线测试用例,把这个循环闭合起来。
B Offline Evaluation — Pre-Deployment Validation
B1. Five steps: curate a dataset of common use cases and edge cases; define expectations (optional ground truth or guidelines); run the agent to generate responses; apply scorers across every response; analyze and iterate by comparing results across runs. Strengths: rigorous validation before users ever see the agent, A/B testing different configurations, baseline metrics for production. Limitations: may not fully represent real user behavior, static datasets go stale, can't capture scale or diversity issues that only show up with real traffic.
B1. 五步:整理一个覆盖常见用例和边界情况的数据集;定义 expectations(可选的真值或准则);跑 agent 生成回复;对每个回复应用判官;通过对比多次运行的结果来分析和迭代。优势:在用户见到 agent 之前就做了严格的验证、可以 A/B 测试不同的配置、能给生产环境提供基线指标。局限:可能没法完全代表真实用户的行为、静态数据集会过时、没法捕捉到只有在真实流量下才会出现的规模或多样性问题。
C Online Evaluation — Production Monitoring
C1. Five steps: deploy with tracing so every production request is traced (in this course, the Airbnb assistant app logs a trace per request to its MLflow experiment); capture traces in that experiment; score automatically by registering scorers and starting them with .register() and .start(); alert and collect feedback to monitor quality; augment the dataset with production examples. Supported scorer types for production monitoring: built-in judges, make_judge(), Guidelines, and @scorer-decorated functions all work — only direct Scorer subclasses and third-party scorers are excluded. Production monitoring capabilities: auto scoring (LLM judges run on production traces), sampling (configurable rates), alerting (when quality drops below a threshold), and trace inspection (deep dives into failures). Strengths: reflects actual user experience, detects unanticipated issues, generates data for continuous improvement. Limitations: users may hit failures first, root-cause attribution is harder, requires production infrastructure.
C1. 五步:部署时带上 tracing,让每一次生产请求都被追踪(这门课里,Airbnb assistant app 会把每次请求的 trace 记录到它的 MLflow experiment);把 trace 捕获到那个 experiment 里;通过注册判官、用 .register() 和 .start() 启动它们,实现自动打分;通过报警和收集反馈来监控质量;用生产环境的真实案例扩充数据集。生产监控支持的判官类型:内置判官、make_judge()、Guidelines、@scorer 装饰的函数都可以用——只有直接继承 Scorer 的子类和第三方判官不行。生产监控的能力:自动打分(LLM 判官跑在生产 trace 上)、采样(可配置采样率)、报警(质量低于某个门限时触发)、trace 检查(深入排查失败案例)。优势:反映真实的用户体验、能发现没预料到的问题、为持续改进提供数据。局限:用户可能先遇到失败、根因定位更难、需要生产环境的基础设施支撑。
D Complementary Strategies
D1. Offline is for quality gates (pre-deployment validation), A/B testing (comparing implementations side by side), hypothesis testing ("does the new prompt reduce hallucinations?"), and rapid iteration (fast feedback during development). Online is for generalization checks (do offline results actually hold in production?), drift detection (catching performance degradation over time), user insight (real needs, pain points, edge cases), and dataset mining (building evaluation datasets from actual usage).
D1. 离线评测适合:质量门槛(部署前的验证)、A/B 测试(并排比较不同实现)、假设检验("新的 prompt 能不能减少幻觉?")、快速迭代(开发过程中的快速反馈)。线上评测适合:泛化检验(离线的结果在生产环境里到底站不站得住)、漂移检测(捕捉随时间推移的性能下降)、用户洞察(真实的需求、痛点、边界情况)、数据集挖掘(从真实使用情况里构建评测数据集)。
D2. Creating a feedback loop. The course's own swimlane walks a request across three lanes — Users, MLflow, Developer — in seven steps: (1) Ask — a user asks the Airbnb assistant. (2) Trace — the app logs a trace to its experiment. (3) Rate — the user picks Yes or No, plus a comment. (4) Assess — user_feedback is saved on the trace. (5) Curate — the developer's search_traces() finds the No answers for the evaluation dataset. (6) Fix — change the agent and re-run evaluate(). (7) Promote — register a new version and move the @champion alias; the app serves the new champion. This cycle — real user feedback becoming the next evaluation dataset, becoming the next deployed version — is the whole point of Modules 1-2's champion-alias architecture, now shown closing the loop it was always built for.
D2. 搭建反馈循环。课程自己的这张泳道图,把一次请求的流转,分到用户、MLflow、开发者三条泳道里,走完七步:(1)问——用户向 Airbnb assistant 提问。(2)追踪——app 把 trace 记录到它的 experiment 里。(3)评价——用户选 Yes 或 No,再加一句评论。(4)评估——user_feedback 被保存到这条 trace 上。(5)整理——开发者用 search_traces() 把那些 No 的答案找出来,放进评测数据集。(6)修复——改 agent,重跑 evaluate()。(7)晋升——注册一个新版本,把 @champion 别名移过去;app 开始服务这个新的 champion。这个循环——真实用户的反馈变成下一个评测数据集,再变成下一个部署版本——正是 Module 1、2 里一直讲的 champion 别名架构真正要达成的目的,这里第一次把这个循环完整地走通了一遍。
E Integration with Unity Catalog
E1. Governance for evaluation. Unity Catalog is the governance layer across the whole workflow: agent registration (dependencies, access controls, aliases like @champion), dataset storage (versioned, governed evaluation datasets), trace storage (SQL-queryable, shareable across teams), and lineage (from datasets to metrics to agent versions).
E1. 评测的治理层。Unity Catalog 是整个工作流的治理层:agent 注册(依赖关系、访问控制、像 @champion 这样的别名)、数据集存储(有版本管理、被治理的评测数据集)、trace 存储(可以用 SQL 查询,能跨团队共享)、血缘关系(从数据集到指标到 agent 版本,全程可追溯)。
E2. Storing traces in Unity Catalog tables. By default, MLflow stores traces in the MLflow control plane service. For production workloads, OpenTelemetry traces can instead be written directly into UC-managed tables, binding the experiment with mlflow.set_experiment(experiment_name="…", trace_location=UnityCatalog(catalog_name="prod", schema_name="agents", table_prefix="airbnb")) — requiring a SQL warehouse (MLFLOW_TRACING_SQL_WAREHOUSE_ID). This writes four managed tables (airbnb_otel_spans — the call tree, airbnb_otel_logs — OTel log records, airbnb_otel_annotations — assessments/feedback/tags, airbnb_otel_metrics — OTel metric data points) plus two SQL views built over them: airbnb_trace_unified (full detail — spans, metadata, and assessments together) and airbnb_trace_metadata (fast filtering — tags and metadata only, no span payloads). Key benefits over default storage: SQL-queryable (join traces with evaluation results in Databricks SQL), UC access control (catalog/schema permissions instead of experiment ACLs), long-term retention for high-volume production, and OTel compatibility with third-party OTLP exporters.
E2. 把 trace 存进 Unity Catalog 表里。默认情况下,MLflow 把 trace 存在 MLflow 控制平面服务里。对于生产环境的负载,可以改成把 OpenTelemetry trace 直接写进 UC 管理的表里,用 mlflow.set_experiment(experiment_name="…", trace_location=UnityCatalog(catalog_name="prod", schema_name="agents", table_prefix="airbnb")) 绑定 experiment——需要一个 SQL warehouse(MLFLOW_TRACING_SQL_WAREHOUSE_ID)。这会写出四张管理表(airbnb_otel_spans——调用树,airbnb_otel_logs——OTel 日志记录,airbnb_otel_annotations——评估结果/反馈/标签,airbnb_otel_metrics——OTel 指标数据点),再加两个建在这些表之上的 SQL 视图:airbnb_trace_unified(完整细节——span、元数据、评估结果都在一起)和 airbnb_trace_metadata(快速过滤——只有标签和元数据,没有 span 的具体内容)。相比默认存储方式的关键好处:可以用 SQL 查询(在 Databricks SQL 里把 trace 和评测结果 join 起来)、UC 访问控制(用 catalog/schema 的权限,不用 experiment 的 ACL)、长期保留(适合高量级的生产 trace)、兼容 OTel(可以对接第三方 OTLP 导出器)。
CCAR-P crosswalk
- D1 (architecture) — the seven-step feedback loop is the single most complete architectural picture in Folder 3: it's the first file to show the champion alias, tracing, evaluate(), and user feedback all participating in one closed cycle rather than as separate concepts.
- D4 (eval dataset/framework design) — "dataset mining" (D1) and "augment the dataset with production examples" (C1) are the exam-relevant answer to "where do good evaluation datasets come from after the first one": not written once, grown from real failures.
中文摘要
- D1(架构)——这个七步反馈循环,是 Folder 3 里最完整的一张架构图:这是第一次,champion 别名、tracing、evaluate()、用户反馈,全都被放进同一个闭环里一起运作,而不是分散讲的几个概念。
- D4(评测数据集/框架设计)——"数据集挖掘"(D1)和"用生产环境的真实案例扩充数据集"(C1),正是"第一份评测数据集之后,好的评测数据集是从哪来的"这个考题的答案:不是一次写完的,是从真实的失败案例里长出来的。
The seven-step feedback loop is the clearest template in this entire course for what FM Insight's AI governance actually needs to look like end to end: a GFEBS/Navy ERP agent gets evaluated offline, deployed under a challenger-then-champion alias, traced on every production query, rated by the preparers and reviewers who actually use it, with disagreements curated by the AI platform team into new offline test cases — exactly the dataset-mining loop D1 describes. And E2's UC-table trace storage is directly relevant to audit evidence: SQL-queryable, governed, long-retention trace storage means every agent decision in an A-123 control-tested workflow is itself queryable and reviewable years later, not locked inside an ephemeral MLflow UI session — which is closer to what an auditor would actually need to sign off on an AI-assisted process.
这个七步反馈循环,是整门课里最清楚的一个模板,说明 FM Insight 的 AI 治理从头到尾到底应该长什么样:一个查询 GFEBS/Navy ERP 的 agent 先离线评测,用 challenger 然后 champion 别名部署上线,每一次生产查询都打 trace,被真正在用它的编制人员和复核人员打分,有分歧的地方由 AI 平台团队整理成新的离线测试用例——这正是 D1 讲的"数据集挖掘"这个循环。E2 讲的、存在 UC 表里的 trace,跟审计证据直接相关:可以用 SQL 查询、受治理、长期保留的 trace 存储,意味着一个在 A-123 控制测试工作流里的 agent 的每一个决策,若干年后都仍然可以被查询、被复核,不是被锁在一个临时的 MLflow 界面会话里——这更接近一个审计人员真正需要的、能在上面签字认可一个 AI 辅助流程的东西。
File 28 Lab — Developer and SME Feedback with MLflow
Big picture first: this lab is the hands-on version of File 27's D2 feedback loop, split across the two personas who actually do steps 1-4 of it. The developer works inside MLflow's own UI, annotating traces the classroom setup already generated. The SME works somewhere that looks nothing like MLflow at all — a chat window in a deployed app — and never knows the difference, because the app loads the exact same @champion-aliased Unity Catalog model the developer evaluates in notebooks. One agent, two front doors, one shared trace store underneath.
先说大图景:这个实验,是 File 27 D2 反馈循环的实操版,拆成了真正执行这个循环第 1-4 步的两种人。开发者在 MLflow 自己的界面里操作,给课堂环境已经生成好的 trace 打标注。SME(业务专家)则是在一个完全不像 MLflow 的地方工作——一个部署好的 app 里的聊天窗口——而且他们根本不需要知道背后的区别,因为这个 app 加载的,正是开发者在 notebook 里评测的同一个、挂着 @champion 别名的 Unity Catalog 模型。一个 agent,两个入口,底下共用同一个 trace 存储。
B Developer Feedback — Direct Trace Annotation
B1-B2. The classroom setup pre-populated a session called feedback-session-001 inside the airbnb_experiment, with 3 turns already queried. Grouping traces by session surfaces it at the top of the trace list; opening the session shows Turn 1 through Turn 3 side by side, with assessments addable at both the session level and the individual trace level.
B1-B2. 课堂环境预先在 airbnb_experiment 里准备好了一个叫 feedback-session-001 的 session,已经跑了 3 轮问答。把 trace 按 session 分组后,它会出现在 trace 列表的最上面;打开这个 session,Turn 1 到 Turn 3 会并排显示出来,既可以在 session 这一层加评估,也可以在每一条单独的 trace 上加评估。
B3-B4. Two assessment types, same mechanism. On Turn 1's trace, the lab adds an Expectation named tool_usage, data type Boolean, value True, rationale "The tool was used correctly." — this is ground truth about what should have happened, attached after the fact by someone who checked. At the session level, it then adds a Feedback named ready_for_sme_feedback, data type String, value "True", rationale that testing is complete and the session is ready for SME review — this is a judgment call about the session as a whole, not a fact about one trace. The distinction matters: Expectations assert what the correct answer was (comparable to ground truth in offline evaluation); Feedback records an opinion about quality (comparable to a judge's or reviewer's score). Both are MLflow Assessments — structured, named, typed, with a rationale and a source — just serving different roles.
B3-B4. 两种评估类型,同一套机制。在 Turn 1 这条 trace 上,实验添加了一个名为 tool_usage 的 Expectation(期望值),数据类型是 Boolean,值为 True,理由是"工具被正确调用了。"——这是事后由审核者确认的、关于"本该发生什么"的真值。在 session 这一层,又添加了一个名为 ready_for_sme_feedback 的 Feedback(反馈),数据类型是 String,值为"True",理由是测试已经完成、这个 session 已经可以交给 SME 复核了——这是对整个 session 的一个判断,不是某一条 trace 的事实陈述。这个区分很关键:Expectation 断言的是"正确答案本该是什么"(相当于离线评测里的真值);Feedback 记录的是对质量的一个看法(相当于判官或审核者给的分数)。两者都是 MLflow Assessment——有结构、有名字、有类型、带理由和来源——只是扮演的角色不一样。
C SME Feedback — The Chat UI of a Deployed App
C1. The deployed agent app. The workspace setup deployed the evaluated agent as a Databricks App named agent-airbnb-assistant. The app carries no agent code of its own — it loads dbacademy.agent_eval.airbnb@champion straight from Unity Catalog, the identical registered model the notebooks load for evaluation. That identity is what makes SME feedback meaningful: experts are reviewing the exact version under evaluation, not a stand-in. The app logs every chat turn as a trace in its own experiment, /Shared/agent-eval-app — a separate experiment from airbnb_experiment — and its chat UI asks "Was this answer correct?" after every answer, saving the Yes/No and any comment as a human feedback assessment named user_feedback, with the SME's email recorded as its source. Access is deliberately lightweight: SMEs need only CAN_USE permission on the app itself — no access to the MLflow experiment required.
C1. 已部署的 agent app。课堂环境把被评测的那个 agent,部署成了一个叫 agent-airbnb-assistant 的 Databricks App。这个 app 本身不带任何 agent 代码——它直接从 Unity Catalog 加载 dbacademy.agent_eval.airbnb@champion,跟 notebook 里评测时加载的,是同一个注册模型。正是这种"同一个版本"的关系,让 SME 的反馈真正有意义:专家审核的是正在被评测的那个确切版本,不是一个替身。这个 app 把每一轮聊天都记录成一条 trace,存到它自己的 experiment——/Shared/agent-eval-app——跟 airbnb_experiment 是两个不同的 experiment;它的聊天界面每次回答后都会问"这个回答对吗?",把 Yes/No 和任何评论保存成一条名为 user_feedback 的人工反馈评估,SME 的邮箱会被记录为它的来源。权限设计特意做得很轻:SME 只需要对这个 app 有 CAN_USE 权限——完全不需要访问 MLflow experiment 的权限。
C2-C4. Opening the app shows which registered agent version and which model-serving endpoint it's calling, right under the title — the app surfaces its own lineage. Submitting a test query ("How many rooms in Mission have a private room?") shows which tools were called above the answer. Clicking "Yes" and adding a comment ("The agent should end with 'Is there anything else I can help with?'") saves feedback to the trace and shows the trace ID in the confirmation. From there, "MLflow Traces" opens the app's experiment directly, where the SME's trace — and everyone else's, since the experiment is shared workspace-wide — can be found by the User column, and the saved user_feedback assessment is visible under that trace's Assessments panel with the SME's comment as its rationale.
C2-C4.打开这个 app,标题下面就会显示它调用的是哪个注册版本、哪个模型服务端点——app 自己把这条血缘关系展示出来了。提交一条测试查询("Mission 区域有多少间私人房?"),回答上方会显示调用了哪些工具。点 "Yes" 并加一句评论("agent 应该以'还有什么我能帮你的吗?'结尾。")会把反馈保存到这条 trace 上,确认信息里会显示 trace ID。从这里点 "MLflow Traces" 可以直接打开这个 app 的 experiment,在那里可以通过 User 这一列找到 SME 自己的 trace(也能看到其他人的,因为这个 experiment 是整个工作区共享的),保存的 user_feedback 评估会出现在那条 trace 的 Assessments 面板里,SME 的评论就是它的理由。
C5. Reading SME feedback programmatically. The same feedback is readable from a notebook with mlflow.search_traces(), filtered to the reviewer's own user:
C5. 用代码读取 SME 反馈。同样的反馈也可以在 notebook 里用 mlflow.search_traces() 读取,按审核者自己的用户名过滤:
app_exp = mlflow.get_experiment_by_name(app_experiment_path)
traces_df = mlflow.search_traces(
locations=[str(app_exp.experiment_id)],
filter_string=f"metadata.\`mlflow.trace.user\` = '{username}'",
order_by=["timestamp_ms DESC"],
max_results=5,
return_type="pandas",
)
This is the exact mechanism File 27's D2 called "Curate" — search_traces() mining the experiment for feedback-bearing traces — except here it's pointed at the app's experiment to pull SME judgments rather than at the main experiment to pull user "No" answers. Same API, same role in the loop, different source of signal.
这正是 File 27 D2 里"整理"(Curate)那一步的具体机制——用 search_traces() 在 experiment 里挖出带反馈的 trace——只不过这里指向的是 app 的 experiment,为的是拉取 SME 的判断,而不是指向主 experiment 去拉用户的"No"答案。同一个 API,在循环里扮演同一个角色,只是信号来源不一样。
CCAR-P crosswalk
- D5 (LLM risk/failure modes) — Expectation vs. Feedback is a distinction worth knowing cold: conflating "what should have happened" (ground truth, usually stable) with "was this good" (a judgment, subject to disagreement between reviewers) is a common source of noisy, hard-to-interpret eval results.
- D1 (architecture) — "no agent code of its own" is the architectural tell: the app is a thin UI client over a UC-registered model behind an alias, not a separate deployment artifact — the same decoupling that let Module 2's Lab promote a challenger without touching the serving app at all.
中文摘要
- D5(LLM 风险/失败模式)——Expectation 和 Feedback 的区分值得牢记:把"本该发生什么"(真值,通常比较稳定)和"这个回答好不好"(一个判断,不同审核者之间可能有分歧)混为一谈,是评测结果变得嘈杂、难以解读的一个常见原因。
- D1(架构)——"本身不带任何 agent 代码"是一个架构上的标志:这个 app 只是一个薄薄的 UI 客户端,背后调用的是挂着别名的 UC 注册模型,不是一个独立的部署产物——这正是 Module 2 Lab 里能够晋升 challenger 而完全不用动服务层 app 的那种解耦方式。
The developer/SME split here maps cleanly onto how an Advana/FM Insight AI feature would need to be reviewed before touching audit-relevant numbers: the AI platform team annotates traces directly in MLflow during development (expectations about tool calls on GFEBS/Navy ERP queries, feedback on whether a session is ready), then hands review to the actual financial-management SMEs — preparers, reviewers, certifying officials — through a thin chat app that loads the exact champion-aliased model under evaluation, with no separate access to the underlying MLflow workspace required. That "no experiment access needed" detail solves a real access-control problem: FM SMEs can give meaningful, attributable feedback (their email recorded as the source, exactly as an auditor would want) without being granted developer-level access to the AI platform itself.
这里开发者和 SME 的分工,跟 Advana/FM Insight 的一个 AI 功能在接触审计相关数据之前该如何被复核,可以直接对应起来:AI 平台团队在开发阶段,直接在 MLflow 里给 trace 打标注(比如关于 GFEBS/Navy ERP 查询里工具调用的 Expectation,关于一个 session 是否可以放行的 Feedback),然后把复核工作交给真正的财务管理 SME——编制人员、复核人员、认证官员——通过一个薄的聊天 app,这个 app 加载的正是被评测的、挂着 champion 别名的那个确切模型,不需要给他们任何对底层 MLflow 工作区的独立访问权限。"不需要 experiment 访问权限"这个细节,解决了一个真实存在的访问控制问题:FM 的 SME 可以给出有意义、可追溯来源的反馈(他们的邮箱会被记录为来源,这正是审计人员想看到的),而不需要被授予对 AI 平台本身的开发者级别访问权限。
Appendix Agent Deployment Patterns
Big picture first: this closing appendix zooms out from the agent-airbnb-assistant app used throughout Folders 2-3 to the two deployment mechanisms underneath it, and then further out to where custom agents sit on Databricks' full spectrum of agent-building approaches. None of it changes anything about evaluation — that's the explicit point of the course's own callout box — but it fills in exactly what kind of thing was being evaluated this whole time.
先说大图景:这个结束性的附录,从 Folder 2、3 全程用到的 agent-airbnb-assistant 这个 app,往外拉到它背后的两种部署机制,再往外拉到自定义 agent 在 Databricks 整个 agent 构建方式谱系里所处的位置。这些内容都不会改变评测本身的任何东西——课程自己用提示框明确点出了这一点——但它把"这一路评测的到底是个什么东西"这个问题,彻底讲清楚了。
A Model Serving vs. Databricks Apps
A1. Two deployment targets for the same registered agent. agents.deploy() (Model Serving) is a single function call: infrastructure provisioned automatically with limited control, agent code logged as an MLflow artifact, inference tables/tracing/the Review App built in. Databricks Apps (the recommended path, and what agent-airbnb-assistant actually is) is Git-based: bundles with explicit auth in databricks.yml, full control over code and server configuration, agent code running as an async FastAPI server (MLflow AgentServer, runnable locally with uv run start-app), a chat UI and an /invocations endpoint built in. Model Serving suits quick prototyping and existing deployments not yet due for migration; Apps is recommended for new production deployments needing Git-based CI/CD, local dev, and full serving-infrastructure control. Critically: both support MLflow tracing, and mlflow.genai.evaluate() works identically against either — this course's entire evaluation framework is deployment-agnostic by design.
A1.同一个注册好的 agent,有两个可以部署的目标。agents.deploy()(Model Serving)是一次函数调用:基础设施自动配置、控制权有限,agent 代码作为 MLflow artifact 记录,自带 inference table、tracing 和 Review App。Databricks Apps(推荐路径,也是 agent-airbnb-assistant 的真实身份)是基于 Git 的:用 bundle 配合 databricks.yml 里显式的鉴权,对代码和服务器配置有完全的控制权,agent 代码是以一个异步 FastAPI 服务器形式运行(MLflow AgentServer,可以用 uv run start-app 在本地跑),自带聊天界面和一个 /invocations 端点。Model Serving 适合快速原型验证、以及还没到迁移时机的已有部署;Apps 是推荐用于需要基于 Git 的 CI/CD、本地开发、以及对服务基础设施有完全控制权的新生产部署的路径。关键是:两者都支持 MLflow tracing,mlflow.genai.evaluate() 在两者上的表现完全一致——这门课整套评测框架,从设计上就是跟部署方式无关的。
B Migrating from Model Serving to Databricks Apps
B1. Four migration steps: download the agent's MLflow artifacts; restructure class methods into decorated functions; configure the app in databricks.yml; deploy with databricks bundle deploy. What changes: agent code moves from a class-based ResponsesAgent with predict()/predict_stream() to module-level @invoke()/@stream() decorated functions; configuration moves from an MLmodel file plus model config YAML to databricks.yml resource declarations; execution shifts from synchronous to async (async def recommended); the deploy command changes from agents.deploy() to databricks bundle deploy. What stays the same, and this is the part worth remembering: core agent logic (tools, LLM calls, prompts), MLflow tracing and evaluation integration, Unity Catalog tool registration, and the request/response payload format. The migration is a packaging and execution-model change, not a rewrite of what the agent actually does or how it's evaluated.
B1.迁移分四步:下载 agent 的 MLflow artifact;把基于类的方法重构成装饰器函数;在 databricks.yml 里配置这个 app;用 databricks bundle deploy 部署。会变的东西:agent 代码从一个基于类的 ResponsesAgent(带 predict()/predict_stream())变成模块级别的 @invoke()/@stream() 装饰函数;配置从一个 MLmodel 文件加模型配置 YAML,变成 databricks.yml 里的资源声明;执行方式从同步变成异步(推荐用 async def);部署命令从 agents.deploy() 变成 databricks bundle deploy。不会变的东西,这才是值得记住的部分:核心 agent 逻辑(工具、LLM 调用、prompt)、MLflow tracing 和评测的集成方式、Unity Catalog 工具注册、请求/响应的数据格式。这次迁移改变的是打包方式和执行模型,不是 agent 实际做什么、或者怎么被评测这件事本身。
C Agents on Databricks — The Full Spectrum
C1. Three approaches, no-code to code-first. Knowledge Assistant (legacy): bring your own AI Search index, choose chunking, attach up to 10 source types — full control over retrieval, but a legacy path. Genie Agent (managed, recommended declarative option): declare what data or documents the agent should work with — tables for structured queries, UC volumes for document search — and the platform handles tool orchestration and query generation. Custom Agent (code-first): write your own agent logic, tools, and orchestration with the OpenAI Agents SDK, LangGraph, or any Python framework, then deploy as a Databricks App — the path this entire course's airbnb agent takes.
C1. 三种方式,从无代码到代码优先。Knowledge Assistant(遗留方案):自带 AI Search 索引,自己选切分策略,最多挂 10 种数据源——对检索流程有完全的控制权,但是一条遗留路径。Genie Agent(托管,推荐的声明式方案):声明 agent 该处理什么数据或文档——表用于结构化查询,UC volume 用于文档搜索——平台负责处理工具编排和查询生成。Custom Agent(代码优先):用 OpenAI Agents SDK、LangGraph,或任何 Python 框架,自己写 agent 逻辑、工具和编排,然后部署成 Databricks App——这整门课里的 airbnb agent 走的正是这条路。
C2. The frontier — platform capabilities for custom agents. Databricks is adding infrastructure so custom agents don't have to be built entirely from scratch: an Agent developer CLI (beta) scaffolds a "hello world" custom agent in under 10 minutes, pre-wired with the capabilities below; Managed memory and sessions (beta) gives agents the right context within a conversation and across sessions; Agentic sandboxes (beta) let agents access data and run code in an isolated, secure environment; Agent hosting (GA) runs the agent on Databricks serverless infrastructure; Tracing and evaluation (GA) is exactly the MLflow stack this entire course was built on; Out-of-the-box tools and MCPs (GA) bundles pre-built first- and third-party MCP servers plus tools for web search and code execution. The pattern across Folders 1-3: tracing and evaluation are the one piece of this stack already GA and already load-bearing in production — everything else is infrastructure that reduces how much custom plumbing a team has to write before it can even start generating the traces this course teaches you to evaluate.
C2. 前沿进展——给自定义 agent 的平台能力。Databricks 正在增加一些基础设施,让自定义 agent 不用完全从零开始搭建:Agent developer CLI(beta)能在 10 分钟内搭出一个"hello world"级别的自定义 agent,预先接好下面这些能力;托管内存与 session(beta)帮 agent 在一次对话内、以及跨多个 session 之间,拿到正确的上下文;Agentic sandbox(beta)让 agent 可以在一个隔离、安全的环境里访问数据、运行代码;Agent hosting(GA)把 agent 跑在 Databricks 的 serverless 基础设施上;Tracing and evaluation(GA)正是这整门课建立在其上的那套 MLflow 体系;内置工具和 MCP(GA)打包了预构建的第一方和第三方 MCP 服务器,以及网页搜索、代码执行等工具。贯穿 Folder 1 到 3 的一个规律:tracing 和 evaluation 是这整套能力里唯一一个已经 GA、而且已经在生产环境里挑大梁的部分——其他的,都是在减少一个团队在真正开始产生"这门课教你怎么去评测"的那些 trace 之前,需要自己搭建多少基础管道。
CCAR-P crosswalk
- D1 (architecture) — "evaluation techniques apply regardless of deployment method" is the exam-relevant architectural principle of the whole Appendix: MLflow's tracing/evaluate() layer is deliberately decoupled from the serving layer, so a D1 question about agent architecture should treat deployment target (Model Serving vs. Apps vs. Genie) as orthogonal to evaluation design, not a variable that changes it.
- D3 (integration/protocol choice) — the Custom Agent row naming "OpenAI Agents SDK, LangGraph, or any Python framework" plus out-of-the-box MCP servers is the clearest single statement in Folder 3 of what D3's protocol-choice question is actually choosing between: framework-native tool calling vs. MCP as a portable interop layer.
中文摘要
- D1(架构)——"评测技术跟部署方式无关"是整个附录里考试相关的核心架构原则:MLflow 的 tracing/evaluate() 这一层,在设计上就是跟服务层解耦的,所以 D1 里关于 agent 架构的题目,应该把部署目标(Model Serving vs. Apps vs. Genie)当作跟评测设计正交的变量,而不是会改变评测设计的变量。
- D3(集成/协议选择)——Custom Agent 这一行提到的"OpenAI Agents SDK、LangGraph,或任何 Python 框架",加上内置的 MCP 服务器,是 Folder 3 里把 D3 协议选择题到底在"选什么"讲得最清楚的一句话:框架自带的工具调用方式,跟 MCP 作为一个可移植的互操作层,两者之间的选择。
This deployment spectrum maps directly onto build-vs-buy decisions FM Insight will keep facing: a Genie Agent (declarative, point it at GFEBS/Navy ERP tables) is the lowest-effort path for a straightforward query-and-report agent and should be the default first choice; a Custom Agent on Databricks Apps is what's justified once the use case needs orchestration logic an off-the-shelf declarative agent can't express — multi-step reconciliation workflows, or agents that need to call multiple feeder systems in sequence with custom business logic between calls. Either way, the appendix's core claim is the one worth carrying into any FM Insight AI governance document: the evaluation and audit-trail infrastructure (tracing, MLflow, Unity Catalog governance) is the same regardless of which deployment pattern a given agent uses, so an audit-readiness standard for AI-assisted FM processes can be written once, against the MLflow/UC layer, rather than once per deployment mechanism.
这个部署方式的谱系,直接对应到 FM Insight 以后一直会面对的"自建还是买现成"的决策:一个 Genie Agent(声明式,直接指向 GFEBS/Navy ERP 的表)对于一个直截了当的查询和报表类 agent 来说,是投入最少的路径,应该是默认的首选;一个部署在 Databricks Apps 上的 Custom Agent,只有当这个用例需要一套现成的声明式 agent 表达不出来的编排逻辑时才值得投入——比如多步骤的对账工作流,或者需要按顺序调用多个反馈系统、中间还夹着自定义业务逻辑的 agent。不管选哪种,这个附录里最值得带进任何一份 FM Insight AI 治理文档的核心论点是:评测和审计留痕的基础设施(tracing、MLflow、Unity Catalog 治理),不管具体的 agent 用哪种部署方式都是一样的,所以一份针对 AI 辅助 FM 流程的审计就绪标准,可以只针对 MLflow/UC 这一层写一次,不需要针对每一种部署机制分别写一遍。
Adoption Plan The Lego-Brick Model — Step-by-Step Adoption for FM Insight
Big picture first: nothing in Folder 3 is one monolithic system that has to be adopted all at once. Tracing, judges, offline evaluation, feedback loops, champion/challenger promotion, and UC trace storage are separate, independently snap-on-able pieces — Lego bricks, not a cast part. Each one plugs into the one beneath it at a defined connection point, each one delivers standing value on its own, and each one can be removed later without breaking the pieces under it. The job of this section is to name those connection points explicitly, so FM Insight can adopt this stack incrementally, in whatever order actually fits DoW's audit-remediation timeline, instead of treating "MLflow evaluation" as an all-or-nothing platform decision.
先说大图景:Folder 3 里讲的这些东西,不是一个必须整套一次性采用的庞然大物。Tracing、判官、离线评测、反馈循环、champion/challenger 晋升、UC trace 存储——这些都是彼此独立、可以单独"咬合"上去的零件,是乐高积木,不是一体铸造的零件。每一块都在一个明确的连接点上,咬合到它下面那一块上;每一块单独拿出来也都有持续的价值;每一块以后也都可以拆掉,而不会把它下面的零件弄坏。这一节要做的事,就是把这些连接点一个一个明确地说清楚,这样 FM Insight 就可以按照 DoW 审计整改真正的时间表,分阶段、按任意合适的顺序,逐步采用这整套体系,而不是把"MLflow 评测"当成一个要么全上、要么全不上的平台决策。
A The Brick Catalog — What Snaps Onto What
A1. The one brick everything else needs. MLflow Tracing (autolog, or manual @mlflow.trace) is the foundation plate. Nothing else in Folder 3 — no judge, no evaluation run, no feedback assessment, no monitoring — works without it, because every one of them reads or writes a trace. The good news: tracing alone is a complete, valuable, shippable brick on its own. Turning it on gives FM Insight visibility into what an agent actually did — inputs, outputs, tool calls, latency, token counts — with zero judges, zero datasets, zero evaluation code. That's worth doing in week one for its own sake.
A1. 所有其他积木都离不开的那一块。MLflow Tracing(自动打点,或者手动用 @mlflow.trace)是地基板。Folder 3 里其他任何东西——判官、评测跑批、反馈评估、生产监控——都离不开它,因为它们每一个都要读或写 trace。好消息是:tracing 本身就是一块完整、有独立价值、可以单独上线的积木。单独打开它,FM Insight 就能看到一个 agent 到底做了什么——输入、输出、工具调用、延迟、token 数量——完全不需要判官、数据集、或者评测代码。光是这一点,第一周就值得单独做。
A2. Bricks that snap directly onto tracing — no dataset required. Three scorer types plug straight into a live trace, one trace at a time, with no evaluation harness needed: Guideline judges (plain-language rules, zero code — the cheapest brick in the whole set), Built-in judges (Correctness, Safety, RelevanceToQuery, the Retrieval* family — pre-built, just point them at a trace), and Developer feedback (a human annotating a trace directly in the MLflow UI with an Expectation or a Feedback assessment — no judge at all, just a reviewer's own eyes). Any one of these three can be adopted alone, in any order, the moment tracing exists.
A2. 直接咬合到 tracing 上的积木——不需要数据集。有三种判官类型可以直接插在一条活的 trace 上,一条一条来,完全不需要评测框架:Guideline 判官(纯自然语言规则,零代码——整套积木里最便宜的一块)、内置判官(Correctness、Safety、RelevanceToQuery,还有 Retrieval* 这一族——预先搭好的,直接指向一条 trace 就能用)、开发者反馈(一个人直接在 MLflow 界面里给 trace 加一个 Expectation 或 Feedback 评估——根本不需要判官,就是审核者自己的眼睛)。这三块里的任何一块,只要有了 tracing,就可以单独采用,顺序随意。
A3. Bricks that need a scorer plus something to run it against. The Custom judge brick (make_judge() or @scorer) snaps onto the same connection point as A2's judges, but is itself a prerequisite for domain checks nothing pre-built covers — a USSGL posting-correctness check, an audit-citation-completeness check. The Offline evaluation harness (a curated dataset plus mlflow.genai.evaluate()) is the next layer up: it needs tracing and at least one scorer type (built-in, guideline, or custom — any one works), but it adds the part none of A2's bricks have alone: a repeatable, gate-the-release run across many rows at once. The champion/challenger UC alias pattern sits on top of the harness: it needs an agent already registered in Unity Catalog, and it's the mechanism that turns "this run passed" into "this version is now live."
A3. 需要一个判官、再加点东西让它跑起来的积木。自定义判官这块积木(make_judge() 或 @scorer)跟 A2 里的判官咬合在同一个连接点上,但它本身是做那些没有现成判官能覆盖的业务检查的前提——比如 USSGL 过账正确性检查、审计引用完整性检查。离线评测框架(一个整理好的数据集,加上 mlflow.genai.evaluate())是再往上一层:它需要 tracing,还需要至少一种判官(内置、guideline、自定义,任选一种都行),但它加上了 A2 那些积木单独都没有的东西:一次能跑很多行、可重复、可以用来卡发布关口的评测。champion/challenger UC 别名这个模式搭在评测框架上面:它需要一个已经在 Unity Catalog 里注册好的 agent,它的作用是把"这次跑通过了"变成"这个版本现在正式上线了"。
A4. Bricks that need a deployed agent, not just a notebook. SME feedback via a deployed app needs the agent running somewhere with a chat UI — Model Serving or Databricks Apps, either works — and needs tracing underneath it, but needs nothing from A3's judges or harness at all; an SME can rate answers Yes/No long before any automated judge exists. Production monitoring (.register()/.start()) needs tracing plus at least one scorer that supports it (built-in, make_judge(), Guidelines, or @scorer — not a direct Scorer subclass), but doesn't need the offline harness to have ever run, though it's far more useful paired with one. UC trace storage (the four-tables-plus-two-views pattern) is a pure storage-backend swap: it needs only tracing, and nothing else in the stack cares whether traces live in the default MLflow store or in Unity Catalog tables underneath them.
A4. 需要一个真正部署出去的 agent、不只是一个 notebook 的积木。通过部署的 app 收集 SME 反馈需要 agent 真的跑在某个带聊天界面的地方——Model Serving 或 Databricks Apps 都行——下面需要有 tracing,但完全不需要 A3 里的判官或评测框架;一个 SME 可以在任何自动判官存在之前,就先用 Yes/No 给答案打分。生产监控(.register()/.start())需要 tracing,再加上至少一种支持它的判官(内置、make_judge()、Guidelines,或 @scorer——不能是直接继承 Scorer 的子类),但不需要离线评测框架曾经跑过,不过跟它搭配起来用会更有价值。UC trace 存储(四张表加两个视图那套模式)是一次纯粹的存储后端替换:它只需要 tracing,整套体系里其他任何部分都不关心 trace 到底存在默认的 MLflow 存储里,还是存在底下的 Unity Catalog 表里。
A5. The one brick that's off to the side entirely. The deployment pattern choice (Genie Agent vs. Custom Agent, Model Serving vs. Databricks Apps) is orthogonal to the entire stack above. It can be decided at any point, independently, and changing it later doesn't require re-adopting anything else — the Appendix's own point, "evaluation techniques apply regardless of deployment method," is exactly this decoupling.
A5. 完全独立于整套体系之外的那一块。部署方式的选择(Genie Agent vs. Custom Agent,Model Serving vs. Databricks Apps)跟上面整套体系是正交的。可以在任何时候单独做这个决定,以后改变它也不需要重新采用其他任何东西——附录自己说的那句话,"评测技术跟部署方式无关",说的正是这种解耦关系。
B A Phased Rollout for FM Insight
B1. A suggested order that follows the dependency stack in A, sized to fit alongside DoW audit-remediation work rather than as a separate platform project: Phase 0 (weeks 1-2, one brick): turn on tracing for one FM Insight agent end to end — a GFEBS or Navy ERP query agent is a reasonable first target. No judges, no dataset, no gate. The deliverable is visibility: can the platform team actually see what the agent did on every call. Phase 1 (weeks 3-4, cheapest snap-ons): add Guideline judges (plain-language rules — no code) and Developer feedback (platform team annotating traces directly in the MLflow UI). Both plug straight into Phase 0's tracing with zero new infrastructure.
B1.一个大致按 A 节的依赖关系排列的建议顺序,节奏要能跟上 DoW 审计整改本身的工作,而不是另起一个独立的平台项目:第 0 阶段(第 1-2 周,一块积木):给某一个 FM Insight 的 agent 全程打开 tracing——一个查询 GFEBS 或 Navy ERP 的 agent,是个合理的第一个目标。不需要判官、不需要数据集、不设任何关口。这一阶段要交付的东西是"可见性":平台团队能不能真的看到这个 agent 每一次调用都做了什么。第 1 阶段(第 3-4 周,最便宜的几块积木):加上 Guideline 判官(纯自然语言规则,不用写代码)和开发者反馈(平台团队直接在 MLflow 界面里给 trace 打标注)。这两块都能直接插在第 0 阶段的 tracing 上,不需要任何新的基础设施。
B2. Phase 2 (weeks 5-8, the first real gate): curate a first FM-specific evaluation dataset — real GFEBS/Navy ERP query-response pairs with known-correct answers and known edge cases — wire up the built-in judges (Correctness, Safety, RelevanceToQuery), and run the offline evaluation harness. This is the first point where "did this agent pass or fail" becomes a reproducible, documented answer rather than a spot check. Phase 3 (weeks 9-12, domain-specific judges plus promotion): write custom judges for checks nothing pre-built covers — a USSGL posting-correctness judge, an audit-citation-completeness judge — and formalize the champion/challenger UC alias so a new version only goes live after it passes the Phase 2 harness.
B2.第 2 阶段(第 5-8 周,第一个真正的关口):整理第一份专门针对 FM 的评测数据集——真实的 GFEBS/Navy ERP 查询-回答对,带有已知正确答案和已知边界情况——接上内置判官(Correctness、Safety、RelevanceToQuery),跑离线评测框架。这是"这个 agent 到底过没过关"第一次变成一个可复现、有文档记录的答案,而不是随手抽查。第 3 阶段(第 9-12 周,业务专属判官加晋升机制):为那些没有现成判官能覆盖的检查写自定义判官——比如一个 USSGL 过账正确性判官、一个审计引用完整性判官——并且把 champion/challenger UC 别名机制正式确立下来,让一个新版本只有在通过第 2 阶段的评测框架之后才能上线。
B3. Phase 4 (quarter 2, open the feedback loop to real users): deploy as a Databricks App (decide the deployment pattern here, per A5 — independently of everything above it) and open SME feedback to the preparers, reviewers, and certifying officials who would actually use the agent, closing File 27's full Ask-Trace-Rate-Assess-Curate-Fix-Promote loop for the first time. Phase 5 (quarter 2-3, the audit-evidence layer): turn on production monitoring (.register()/.start()) and migrate trace storage into Unity Catalog tables — the piece that makes every agent decision SQL-queryable, governed, and retained long enough to matter when an auditor eventually asks for it. Each phase is independently useful and independently defensible on its own if the timeline slips; none of it requires committing to the full stack up front.
B3.第 4 阶段(第二季度,把反馈循环向真实用户打开):部署成一个 Databricks App(在这里按 A5 的说法决定部署方式——跟上面所有阶段都无关,可以独立决定),把 SME 反馈向真正会用到这个 agent 的编制人员、复核人员、认证官员打开,第一次把 File 27 讲的那套完整的"问-追踪-评价-评估-整理-修复-晋升"循环真正闭合起来。第 5 阶段(第二到第三季度,审计证据层):打开生产监控(.register()/.start()),把 trace 存储迁移到 Unity Catalog 的表里——这一块,让每一个 agent 的决策都变成可以用 SQL 查询、受治理、保留时间足够长的记录,等审计人员真的来问的时候用得上。每一个阶段单独拿出来都有用、单独拿出来也都站得住脚,哪怕时间表往后推了也没关系;这整套东西不需要一开始就承诺全盘采用。
C Snapping a Brick Off Again
C1. The same connection points that let a brick snap on let it snap off without collateral damage, because nothing downstream holds a hard reference to how an upstream piece is implemented — only to the interface it exposes (a trace; a Feedback object; a registered UC model behind an alias). Swapping Guideline judges for Custom judges, moving from Model Serving to Apps, or turning off production monitoring during a quiet period, each changes one brick without requiring any other brick in the stack to be touched. This is the practical payoff of the Lego framing: FM Insight can try a piece, decide it isn't earning its keep, and remove it, which is a much easier sell to a program office than "adopt the platform or don't."
C1.能让一块积木咬合上去的那个连接点,同样也能让它干净地拆下来,不会连带损坏别的东西,因为下游的任何东西都没有硬编码地依赖上游那一块具体是怎么实现的——只依赖它对外露出的接口(一条 trace;一个 Feedback 对象;一个挂着别名的、注册过的 UC 模型)。把 Guideline 判官换成自定义判官、从 Model Serving 换成 Apps、或者在一段平静期暂时关掉生产监控,每一次改动都只动了一块积木,不需要碰整套体系里的任何其他部分。这正是乐高比喻在实际中的好处:FM Insight 可以先试一块,发现它不值得留着,然后拆掉它——这比"要么整套采用,要么一点都不采用",对一个项目办公室来说要容易接受得多。
CCAR-P crosswalk
- D1 (architecture) — this is the exam-relevant answer to "how do you de-risk adopting an agent evaluation platform": decompose it into independently valuable, independently removable components connected through stable interfaces (traces, Feedback objects, UC aliases), rather than proposing it as one indivisible system.
- D4 (eval dataset/framework design) — the phased rollout's own ordering is itself a worked answer to a D4-style question: cheap, code-free judges and manual feedback come before a curated dataset and a formal harness, because the harness is the more expensive brick and the cheaper ones generate the real-world examples that make the first dataset worth curating.
中文摘要
- D1(架构)——这正是"怎么给采用一套 agent 评测平台这件事降低风险"这个考题的答案:把它拆成一个个单独有价值、单独可以拆掉的组件,通过稳定的接口(trace、Feedback 对象、UC 别名)连接起来,而不是把它当成一个不可分割的整体来提议。
- D4(评测数据集/框架设计)——这个分阶段推进的顺序本身,就是对一道 D4 风格考题的一次实战作答:便宜、不用写代码的判官和人工反馈,排在整理好的数据集和正式评测框架之前,因为评测框架是更贵的那块积木,而便宜的那几块,恰恰能先产生出真实世界的案例,让第一份数据集真正值得去整理。
This adoption plan is itself the deliverable most directly usable at work: it's a concrete, phased, de-risked proposal for bringing MLflow-based agent evaluation into FM Insight without asking a DCFO program office to approve a six-month platform build before seeing anything. Phase 0 alone — tracing turned on for one agent — is something that could plausibly start this quarter and produce a demonstrable artifact (a real trace of a real GFEBS query) inside two weeks, which is the kind of fast, visible win that builds the internal case for Phases 2 through 5. And because every phase maps to a named brick with a named dependency, this section doubles as the first draft of an actual rollout memo, not just study notes.
这个采用计划本身,就是这门课里最能直接拿去用在工作上的产出:这是一份具体、分阶段、风险已经被拆解掉的方案,可以把基于 MLflow 的 agent 评测带进 FM Insight,而不需要先让 DCFO 的项目办公室批一个六个月的平台建设项目、却什么都还看不到。光是第 0 阶段——给一个 agent 打开 tracing——两周之内就有可能真正开始,并且产出一个可以拿出来展示的东西(一个真实 GFEBS 查询的真实 trace),这正是那种能够为第 2 到第 5 阶段积累内部支持的、快速又看得见的小胜利。而且因为每一个阶段都对应着一块有名字的积木和一个明确的依赖关系,这一节本身就可以直接当作一份实际推进备忘录的第一稿,不只是学习笔记。