外部精选
Automating eval design and hillclimbing with Claude
本文来自外部来源,不是黄奕彬的原创文章。本站提供原文入口,并在采集端生成 AI 结构化摘要、解读与中文翻译(如有),一切以原文为准。
阅读原文(claude.dev)结构化摘要 AI 生成
背景与问题
评估(eval)能为应用或技能在特定任务上的表现提供信号,但设计评估、并在不自我欺骗的前提下改进其表现很困难。本文面向使用 Claude API 构建应用或技能的开发者,说明 Claude Code 中 claude-api 技能新增的评估设计与爬山(hillclimbing)指导。文章先讲原则,再展示命令如何落实原则,最后给出示例。
方法或内容
- 给出好评估的四要素:任务贴近生产分布;更强模型与更高 effort 通常应表现更好;最强配置应明显低于 100% 且差距不能由不可解或含糊任务解释;运行间方差要低。
- 提出对抗性采样警示:不要仅因当前模型失败而选例,应按人类判断的难度、生产流量、bug 报告选例。
- 介绍
/claude-api build-eval:Claude 访谈用户,按生产转录→bug 报告→手写案例→代码库合成的顺序采样输入,提议最便宜的 grader(程序化验证或 LLM-as-judge),并做诊断检查。 - 介绍
/claude-api hillclimb:随机切分 train/test,每轮一个补丁,检测过拟合与回归,分数停滞时按根因分桶剩余失败。
关键发现 / 结果
成本示例(内部客服基准,44 张工单:30 搜索 / 14 保留):
- 起点
Opus 4.8默认(高)effort:搜索集 74.4% 决策准确率,4.6 美分/工单。 Opus 5.5低 effort:87.8%,1.9 美分/工单;其输入输出 token 定价比Opus 4.8低 20%,缓存读低 60%。Sonnet 5低 effort:88.9%,约 1 美分/工单;加路由规则与退款上限交叉引用后达 98.9%。- 14 张保留工单上最终配置 90.5% vs 原始 78.6%,成本约 1/5。
性能示例(claude-api skill 自身评估):66% → 74%(补 8 个缺失特性)→ 77%(修 C#/Java 类型表)→ 80%(加旧→新 API 形态迁移表)→ 约 88%(修任务与 grader 缺陷)。
结论与意义
作者结论:按四要素设计评估、并以 train/test 切分等手段防过拟合,爬山可在保持或提升表现的同时显著降本或提分。适用边界:任务分布须贴近真实生产;评估接近饱和时应转向成本或延迟目标;judge 模型不应是被测模型。命令随 Claude Code 的 claude-api 技能发布,使用前需先运行 claude update。
AI 解读 AI 生成
方法:按「时空变量」分析(时间 / 空间 / 变量,严格区分包含、相关与因果),对象包括原文作者、署名人员与关键技术及其实际原理;结论用「元反空」(元思考、反思考、空思考、综合)整理。
时间:何时发生,现在是否仍成立
来源日期为 2026-09-28 20:00(北京时间,Asia/Shanghai)。文中具体数字绑定当时的模型(Opus 4.8、Opus 5.5、Sonnet 5)、定价与内部基准,随模型版本迭代可能失效;评估设计原则与防过拟合流程相对稳定。这些内容现在是否仍成立:原文未说明。
空间:谁的环境 / 场景
适用于在 Claude Code 中通过内置 claude-api 技能工作的场景,面向基于 Claude API 构建应用或技能的开发者。命令为 /claude-api build-eval(生成评估集)与 /claude-api hillclimb(按目标迭代改进),使用前需运行 claude update 获取最新版本。生成的额外结果页面默认为本地打开、不联网加载的静态文件。
变量:实际改变了什么
- 新增:
claude-api技能加入评估设计与爬山指导及两个子命令。 - 客服示例:模型与 effort 从
Opus 4.8高档换为Sonnet 5低档;prompt 删除强制工具调用 ritual、草稿步与矛盾规则,后加路由规则与退款上限交叉引用;成本从 4.6 → 约 1 美分/工单;保留集准确率 78.6% → 90.5%。 - skill 示例:补 8 个特性文档、修 C#/Java 类型表、加 API 形态迁移表、重写含糊任务与矛盾 grader,评估从 66% 升至约 88%。
区分:包含 ≠ 相关 ≠ 因果
包含:harness 包含 prompt、工具与调用循环;评估规模 = cases × repeats × model。相关(非严格因果):方差低、留有余量与“好评估”同现,属经验原则;环境残留状态(文件、git 历史)与结果被污染被描述为可能的路径。
有明确因果证据的:Opus 5.5 定价更低被原文明确指为节省的“部分原因”;补文档内容后 skill 评估 66%→74%;爬山流程中 train 升而 test 平即回滚,是流程定义的因果检查。
对象:作者/署名与关键技术原理
署名作者(仅取结构化作者字段):Lance Martin(该字段重复出现两次,原文未说明其他署名人员)。关键技术及原文描述的原理:
- 评估四要素与对抗性采样:避免评估测到单一模型的“失败指纹”。
- grader 校验:程序化验证(精确匹配、固定标签、schema 校验、测试通过)或 LLM-as-judge(rubric 写成可核查断言而非 1-5 量表;有 baseline 时随机顺序盲选;judge 模型由用户选且不应为被测模型)。
- 爬山防过拟合:随机 train/test 切分、失败内容不得贴进 prompt、答案在结构上不可达;每轮一个效果须高于评估噪声的补丁,train 升 test 平即回滚;噪声须小于最小可行动改进。
元反空综合结论
元:本质在解决“如何可信地度量并迭代改进基于 Claude 的应用”,把评估方法论工程化为 Claude Code 内可执行的命令,核心是防自我欺骗(过拟合、grader 失真、噪声)。
反:最可能失效的是具体数字——内部基准、Opus 4.8/Opus 5.5/Sonnet 5 的定价与准确率均随版本和任务变化;LLM-as-judge 与合成样例仍存偏差风险;两个示例均为内部数据,外推有限。
空:去掉叙事后剩下的必要事实是——claude-api 技能新增 /claude-api build-eval 与 /claude-api hillclimb,提供引导式评估构建(输入审核、grader 校验、诊断检查)与带过拟合检查的迭代优化;示例显示成本可降至约 1/5、skill 评估 66% → 约 88%。
综合:方法论与流程设计自洽且可复用,但收益幅度因模型、任务与基准而异,应视为特定条件下的结果而非普适承诺。
中文译文 AI 生成
评估能提供一种信号,反映你的应用或 skill 在特定任务上的表现。但设计评估,以及在不自欺欺人的前提下提升评估表现,是很困难的。我们已将这两方面的指导添加到了 claude-api skill 中。
借助这个 skill,你可以运行 /claude-api build-eval 在你的代码库中构建一个评估,并运行 /claude-api hillclimb 针对该评估改进你的应用,一次一个改动,同时用一组留出的示例来发现过拟合。
在本文中,我们先强调良好 eval 设计与 hillclimbing 的原则,然后展示搭配了 claude-api skill 的 Claude Code 如何应用这些原则。最后我们会展示这些命令的几个示例。
评估设计
设计良好的评估有几个共同要素(图 1):
- 评估任务要映照生产环境。从你在“生产”(也就是你正在测试的能力或应用将被使用的场景)中真正关心的任务里抽样。有时任务被选中只是因为它们容易生成或容易评分,但重要的是确保任务分布能代表你真正关心的东西。
- 更强的模型和更多思考应带来更好的表现。能力更强的模型和更高的 effort 档位通常应当在该评估上表现得更好。如果不是这样,往往是含糊的任务或校准不当的评分者在拖累表现。
- 在能力前沿处存在“可通过”的余量:能力最强的模型在最高 effort 下也应明显低于 100%,否则你无法可靠判断改动如何影响表现。重要的是,这一差距不应由不可能或含糊的任务来解释——常见的迹象是,无论重复多少次,某个任务在每次评估运行中都失败。一个好任务是两位领域专家会得出相同判定、且评分者所检查的一切内容都已在任务中写明的任务。
- 运行间的方差要低。高方差往往源于设计不佳、含糊的任务,或对相同输出给出不同判定的评分者;方差也可能藏在配置里,例如 effort 未必被一致地施加。此外,环境也会影响评估结果:早前一次试验遗留的状态(一个文件、一段 git 历史)可能会把答案直接递给 agent。
图 1 良好评估的四个要素(得分对比所花费的 tokens;三种模型规模在三种 effort 设置下,示意)
对抗性采样
模型能力是参差不齐的。如果你因为今天的模型在某些案例上失败而挑选它们,你就是在对某一个模型能力表面的低谷进行采样(图 2)。这样得到的评估最终衡量的可能是该模型的失败指纹,而不是对你的应用来说本质上困难或有价值的东西。
图 2 对抗性采样
选择困难案例应当是因为人类判断它们困难:一个有用的检验是,在纳入一个任务之前,你能说出它为什么难。要纳入那些源自生产流量、bug 报告或工单的、你应用中的具体失败案例。不过,不要盲目相信用户流量:用户有时只会尝试他们预期可行的操作,因此严格从用户流量中抽取的任务分布可能偏容易。
/claude-api build-eval
claude-api skill 中的 build-eval 命令把这些原则变成一个引导式工作流。当你在 Claude Code 中运行 /claude-api build-eval 时,Claude 会对你进行访谈,在你的代码库中构建 eval,并在特定节点暂停以征求你的批准。
设计示例
Claude 会按以下顺序帮助你抽取用于构建评估的输入:
- 生产 transcripts(在询问留存与敏感数据之后)。
- bug 报告与支持工单。
- 你亲手编写的五到十个案例。
- 从你的代码库合成的案例。
该 skill 优先考虑生产流量,但它也能生成以你提供的少量真实示例为锚的合成数据。该 skill 会指示 Claude 生成一个简单页面,向你展示每个输入,并等到你确认它们为止。作为示例,下面我们展示该 skill 可能会请用户审阅的一组电子邮件路由器应用的输入示例(图 3)。
图 3 该 skill 生成的示例输入审阅页
验证评分器
在输入之后,Claude 会提出适合你应用输出的、成本最低的评分器:
- 程序化验证:如果可能的输出是受约束的,它会使用基于代码的检查(精确匹配、来自固定集合的标签、符合某个 schema 的 JSON、能通过的测试)。
- LLM-as-judge:如果输出空间是开放式的——有效答案很多但质量标准明确——它会默认采用这类检查。此时,另一个模型会读取输入、输出以及一份写成可核查断言(而非 1 到 5 量表)的 rubric,并返回分数及其推理。如果你有可对照的 baseline,judge 会改为按随机顺序读取两个输入、不被告知哪个是 baseline,并从中选出更好的那个;judge 模型由你挑选,且不应是你正在测试的模型。
Claude 会对少数几个案例打分,并询问你是否有哪个案例你会打出不同的分数(图 4)。总体而言,在相信你的评估器之前,先阅读一部分已打分的 transcript 样本是很重要的;打分出错是评估被错误配置的最常见方式之一。
当你验证完评分器后,该 skill 会告诉你评估集的规模(案例数 × 重复次数 × 模型,以及大致需要多长时间),运行 baseline,并打印带置信区间的得分。
你会得到:案例、评分器、runner、每个案例一行 JSON 和一份完整 transcript,以及一个列出每个案例得分并附其 transcript 链接的简单页面。
如果你想要超出该页面所示的内容(例如一张图表),只要提出,Claude 会把它构建为紧挨着它的附加页面。默认情况下,这些附加页面是本地打开、不从网络加载任何内容的静态文件。
图 4 为每个输入给出建议评分的结果页面示意图。
诊断检查
在上述 baseline 运行期间,Claude 会检查多项内容:
- 评分器:Claude 会对同一输出运行两次 grader,并报告判定结果是否发生变化。
- 底层管线:Claude 会检查超时、API 错误和被截断的回答,以确保基础设施噪声不会被当作模型方差。
- 提升空间:如果 baseline 已经达到约 95% 或更高的分数,该 skill 会警告用户,并提示 hillclimb 应以探索成本或延迟为目标,而不是质量。
爬山法(HILLCLIMBING)
既然你已经拥有一种可靠的方式来评分你的应用在某项任务上的表现,就可以尝试改进它。爬山法是调节诸如 effort 或 prompt 之类参数的有效方式,这些参数在成本与性能之间进行权衡。关于选择在何处应用爬山法的一些通用建议:
- 低成本迭代 - 修改你在爬山时所聚焦的任何 surface,应当在时间、成本和人力上都很便宜。许多内部项目和客户都将爬山集中在文本上,例如 prompt 和 skill。这些内容易于修改和回退。相比之下,在爬山过程中对 agent harness 进行开放式修改可能涉及大量代码改动。
- 可归因 - 评估分数的变化应当能够归因于你在爬山期间所修改的 surface。例如,若干成功的爬山应用都聚焦于 skill 触发。评估指标(skill 的触发率)与被修改的 skill 描述直接耦合。
- 目标范围明确 - 一种常见的失败模式是在未仔细考虑评估中可用提升空间的情况下提出开放式的性能改进要求;接近饱和的评估或范围界定不清的 surface(例如对更新 harness 的开放式请求)更容易停滞。在各类工作中普遍表现出色的一类目标是成本:即使评估已经饱和,你也可以让 Claude 寻找在保持性能持平的同时降低成本的方法。
过拟合(Overfitting)
即使是设计良好的评估,也很少能精确匹配你在生产环境中关心的任务分布。因此,对评估的“过拟合”是一个常见问题,其结果是系统在评估上的表现优于在生产流量上的表现。
有很多方式会让评估“泄漏”进你的 harness(模型外围的代码,包括 prompt、tool 以及调用 Claude 的循环)。例如,设想一个能从 OCR 中受益的评估任务,但 OCR 在你的生产任务中很少有帮助。
评估 harness 可能会向你的应用添加一个 OCR tool,这在 benchmark 上有所提升,却对生产毫无影响。更广泛地说,爬山可能会向该 harness 添加一些功能,用于处理你所选的特定评估示例中的边缘情况。这些 harness 上的添加会提高你的评估分数,但不会转化为生产中的改进(图 5)。
图 5 harness 过拟合的常见原因。
以下三件事有助于解决此问题:
- 拆分用例。使用 hillclimber 可以读取的 train set,以及从未见过的 test set。如果 train set 分数提升而 test set 分数持平,这就是一个常见的过拟合警示信号。
- 绝不将失败内容粘贴进 prompt。如果 hillclimber 读取失败的 transcript,它绝不应把失败内容粘贴到 prompt 中。
- 在结构上让答案处于模型够不到的位置。模型有时会通过直接找到评估的答案来进行“reward hack”。
如下文所述,claude-api skill 会为你应用这些原则。
/CLAUDE-API HILLCLIMB
claude-api skill 中的 hillclimb 命令将这些原则转化为一个引导式工作流。当你在 Claude Code 中运行 /claude-api hillclimb 时,Claude 会针对给定评估进行迭代改进。你可以选择它能够修改的内容,包括:
- 你的 system prompt
- skill 或指令文件
- tool 描述
- 模型选择、effort 级别以及其他 API 参数
- 你的 harness 代码
在开始之前,Claude 会询问你想优化什么(例如性能,或在保持性能的同时降低成本),然后随机将评估集拆分为 test 和 train。在成本目标下,它会考虑若干常见的成本驱动因素,包括 prompt caching、审查 prompt 与所选模型的兼容性,以及挑选模型和 effort 设置。
在第一轮之前,Claude 会检查评估的噪声(仅凭偶然因素分数能波动的幅度)是否小于你会据以采取行动的最小改进;如果不是,它会说明这一点,并建议增加重复次数或用例数量。
每一轮,Claude 都会读取上一轮的 train transcript,并以 patch 的形式提出一项修改。它让每一轮都瞄准一项效果能够超出评估噪声的修改:它从根源上修复失败行为(例如重写导致该行为的部分,或补充缺失的规则),而不是改写某一行措辞。随后它会带着打过 patch 的修改运行评估。
此时,Claude 会执行一项检查:如果 train set 有所提升而 test set 持平,Claude 会怀疑过拟合并回退该 patch。如果出现回归,Claude 会回退。如果 train 和 test 集都有提升,它会保留该 patch(图 6)。
图 6 hillclimber 所使用的过程。
当分数连续两三轮停滞时,Claude 会读取每个剩余的 train 失败并按原因分类。如果没有任何一项单一修复能带来超过评估噪声的收益,它也会提前执行同样的操作,并建议增加重复次数或用例数量,而不是把轮次花在小到无法度量的修改上。这一步可以发现有歧义的评估用例、harness 错误或运行之间的方差。
只有合理的失败才会被纳入后续的爬山轮次。
爬山完成后,Claude 会把你的代码留在针对你的目标在 test set 上表现最好的那个版本。它会报告相对 baseline 的测试结果并附带置信区间(图 7)。如果收益处于噪声范围内,它会说明这一点,并建议不要合并。
图 7 hillclimbing 之后生成的报告示意图。
示例
以降低成本为目标的 hillclimbing
我们在一个内部客服基准上运行了 /claude-api hillclimb,目标是降低成本并提升性能。该基准包含 44 个工单,其中 30 个用于搜索,14 个作为保留集。它从 Opus 4.8、默认(高)effort 设置开始,在搜索工单上的决策准确率为 74.4%,token 成本为每工单 4.6 美分。
hillclimb 首先审查了 prompt,移除了强制性的工具调用例行流程、一个 scratchpad 步骤以及相互矛盾的规则。随后它尝试了低 effort 的 Opus 5.5。该配置以 87.8% 的准确率越过了基线门槛,并将成本降至每工单 1.9 美分,不到起始成本的一半。
这笔节省有一部分来自 Opus 5.5 的定价:输入和输出 token 比 Opus 4.8 便宜 20%,缓存读取便宜 60%。由于 Opus 5.5 越过了门槛,hillclimb 随后降了一档,检验更便宜的模型是否也能达标。
低 effort 的 Sonnet 5 得分大致相同,为 88.9%,成本约为其一半,即每工单 1 美分(图 8)。
客服基准 采用路径上的其他配置 图 8 以成本为焦点的 hillclimbing。
最后,Claude 通过路由规则和退款上限交叉核对改进了 prompt,使 Sonnet 5 达到 98.9%,成本大致不变。在搜索过程从未见过的 14 个保留工单上,最终配置得分为 90.5%,而原始设置为 78.6%,成本约为后者的五分之一。
以性能提升为目标的 hillclimbing
另一个例子是我们的 claude-api skill,它提供关于使用我们 API 的指导,以及与 Claude 协作的一般技巧(包括本文讨论的子命令)。我们希望确保该 skill 能正确实现使用我们 API 的代码,并基于我们的文档构建了一个评估集来测试该 skill。
在我们的评估上,该 skill 起始得分为 66%。我们向 hillclimber 提供了文档和我们 SDK 的访问权限,让 Claude 能够识别错误并自我修正(图 9)。Claude 发现该 skill 缺少对八个特性的覆盖。
在 skill 中为这些特性添加章节后,性能提升至 74%。随后它发现 C# 和 Java 类型表中存在错误,将性能提升至 77%。
claude-api skill 评估 经过三个阶段的工作从 66.1% 到 87.9% 图 9 以性能为焦点的 hillclimbing。
在得分停滞两轮之后,Claude 分析了剩余的失败并按根本原因对其分桶。正常的一轮会针对最常见的失败做一次修改。这一步不做修改;它只是按原因对每个剩余失败进行归类。
这一反思步骤在几个方面很有用:
- 在对一组失败进行整体反思时,hillclimber 发现 skill 内容其实存在,但 Claude 只是在编写较旧的 API 形态(例如来自其训练先验)。为解决这一问题,hillclimber 在 skill 顶部附近添加了一个表格,引导 Claude 从它记得的形式转向当前形式:例如,从带有固定 token 预算的 extended thinking(API 现在在较新的 Opus 模型上会拒绝它)转向 adaptive thinking,以及从旧版本的 web search 和 web fetch 工具转向当前版本。
- 它还将 C# 和 Java 中反对固定预算 thinking 的警告移到了各自的 adaptive-thinking 示例之前。这将性能提升至 80%。
- 尽管补齐了明显的内容缺口、性能却始终没有提升的任务,是示例或评分器存在缺陷的信号。有一个任务要求编写捕获一种错误类型的代码,而其评分器却要求一个至少包含三个的链。Claude 重写了该任务的表述。
- 另一个评分器的说明与我们的文档相矛盾,实测真实 API 表明文档是对的。解决这些问题并进行更多 skill 编辑后,性能达到约 88%。
开始使用
注意:请先运行 claude update。claude-api skill 随 Claude Code 内置发布,因此更新后即可获得这些命令的最新版本。
代码 Shell claude update
然后,在 Claude Code 中:
提示 /claude-api build-eval /claude-api hillclimb
这些子命令可以通过 claude-api skill 在 Claude Code 中直接使用:
- 如果你想为某个特定问题生成评估集,请运行
/claude-api build-eval。你可以通过提供对示例(例如 trace)的访问来引导它。Claude 将运用本文分享的指导来设计示例和评分器,并确保由你批准这些示例和评分器。 - 如果你已有评估,并希望 Claude 在你的目标(例如更好的性能,或在保持性能的同时降低成本)引导下改进它,请运行
/claude-api hillclimb。Claude 将运用本文分享的指导,在爬升过程中检查过拟合,并在第一轮之前以及每当得分停滞时检查评估本身的 bug,例如把看起来正确的答案判为错误的评分器,或 harness 错误。
特别感谢 Misha Khalman 进行 skill 开发。感谢 Misha Khalman、Michael Segner、Matt Bell、Matt Thanablan 和 Punit Shah 的审阅、贡献和产品支持。
展开原文提取正文(采集端自动提取,可能有缺失)
Evaluations provide a signal on how your app or skill is performing on specific tasks. But designing evaluations, and improving performance on them without fooling yourself, is hard. We've added guidance for both to the claude-api skill. With the skill, you can run /claude-api build-eval to build an evaluation inside your codebase, and run /claude-api hillclimb to improve your application against it, one change at a time, with a held-out set of examples to catch overfitting. In this article, we highlight the principles of good eval design and hillclimbing first, then show how Claude Code with the claude-api skill applies those principles. We’ll close by showing a few examples of these commands. EVAL DESIGN Well designed evaluations have a few common elements (Figure 1):
Eval tasks mirror production. Sample tasks that you care about in “production,” or the setting in which the capability or application you are testing will be used. Sometimes tasks are picked because they are easy to generate or they are easy to grade. But it’s important to ensure that the task distribution represents what you actually care about. Performance improves with stronger models and more thinking. More capable models and higher effort levels typically should perform better on an evaluation. If they don’t, ambiguous tasks or a miscalibrated grader often are hobbling performance. There is “passable” headroom at the frontier. The most capable model at the highest effort should be well below 100% on the evaluation, otherwise you can’t reliably judge how changes impact performance. Importantly, the gap should not be explained by impossible or ambiguous tasks: a common tell is that a task fails every evaluation run, regardless of the number of replicates. A good task is one where two domain experts would reach the same verdict and everything the grader checks is stated in the task. Low run-to-run variance. High variance is often due to poorly designed, ambiguous tasks or a grader that produces different verdicts on identical output. Variance can also hide in the configuration. For example, effort may not be applied consistently. Also, the environment can affect the results of the evaluation: leftover state from an earlier trial (a file, a git history) can hand the agent the answer.
Score against tokens spentThree model sizes at three effort settings, illustrativeFIG 1The four elements of a good eval Adversarial sampling Model capability is jagged. If you pick cases because today's model fails them, you are sampling the valleys of one model's capability surface (Figure 2). The evaluation can end up measuring that model's failure fingerprint rather than what is intrinsically hard or valuable for your application to do. FIG 2Adversarial sampling Pick hard cases because a human judged them hard: a useful test is to be able to say why a task is hard before you include it. Include cases that are specific failures in your application derived from production traffic, bug reports, or tickets. However, don’t blindly trust user traffic: users sometimes try what they expect to work, so a task distribution drawn strictly from user traffic may skew easy. /CLAUDE-API BUILD-EVAL The build-eval command in the claude-api skill turns these principles into a guided workflow. When you run /claude-api build-eval in Claude Code, Claude interviews you, builds the eval inside your codebase, and pauses for approval at specific points. Designing examples Claude helps you sample inputs to build evaluations in this order:
Production transcripts, after asking about retention and sensitive data. Bug reports and support tickets. Five to ten cases you write by hand. Cases synthesized from your codebase.
The skill prioritizes production traffic, but it can also generate synthetic data anchored in a few real examples that you provide. The skill instructs Claude to generate a simple page that shows you every input and waits until you confirm them. As an illustration, below we show an example set of inputs for an e-mail router application that the skill may ask the user to review (Figure 3). FIG 3Example inputs review generated by the skill Validating the grader After the inputs, Claude proposes the cheapest grader that fits your application’s output:
Programmatic verification: If the output possibilities are constrained, it uses a code based check (exact match, a label from a fixed set, JSON that matches a schema, tests that pass). LLM-as-judge: It will default to this type of check if the output space is open-ended, with many valid answers but clear quality criteria. In this case, a second model reads the input, the output and a rubric written as checkable claims (not a 1-to-5 scale), and returns a score with its reasoning. If you have a baseline to compare against, the judge instead reads both inputs in random order, without being told which is the baseline, and picks the better one. You pick the judge model, and it should not be the model you are testing.
Claude grades a handful of cases and asks whether you would have scored any of them differently (Figure 4). In general, it is important to read a sample of scored transcripts before believing your evaluator; scoring failures are among the most common ways an evaluation is misconfigured. When you’ve validated the grader, the skill tells you the size of the evaluation set (cases × repeats × model, and roughly how long it will take), runs the baseline, and prints the score with a confidence interval. What you get back: the cases, the grader, the runner, one JSON line and one full transcript per case, and a plain page that lists each case's score with a link to its transcript. If you want more than that page shows (e.g., a chart), just ask and Claude will build it as an extra page next to it. By default, these extra pages are static files that open locally and load nothing from the network. FIG 4Schematic of the results page generated with suggested grades for each input. Diagnostic checks During the baseline runs mentioned above, Claude checks a number of things:
Grader: Claude runs the grader twice on the same output, and reports whether the verdict changed. Plumbing: Claude checks for timeouts, API errors, and cut-off answers to ensure infrastructure noise doesn't pass as model variance. Headroom: if the baseline already scores about 95% or higher, the skill warns the user and alerts that the hillclimb should aim to explore cost or latency rather than quality.
HILLCLIMBING Now that you have a reliable means of grading your application’s performance on a task, you can try to improve it. Hillclimbing is an effective way to tune parameters like effort or prompts, which trade-off cost and performance. Some general tips for choosing where to apply it:
Cheap iteration - It should be inexpensive (in terms of time, cost, and effort) to modify whatever surface you are focused on for hillclimbing. Many internal efforts and customers have focused hillclimbing on text, such as prompts and skills. These are easy to change and revert. In contrast, open-ended modifications to an agent harness during hillclimbing may involve extensive code changes. Attributable - Changes in the score on your evaluation should be attributable to the surface you are modifying during hillclimbing. For example, several successful applications of hillclimbing have focused on skill triggering. The evaluation metric (the trigger rate for the skill) is directly coupled to the skill description that is being modified. Well-scoped objective - One common failure mode is an open-ended request to improve performance without careful consideration of the headroom available in the evaluation; an evaluation that’s near saturation or a poorly scoped surface (e.g., an open-ended request to update the harness) is more likely to stall. One generally strong objective across various efforts is cost: even if an evaluation is saturated, you can ask Claude to find ways to reduce cost while keeping performance at parity.
Overfitting Even a well-designed evaluation rarely matches the exact task distribution you care about in production. As a result, "overfitting" to an evaluation is a common problem and results in a system that performs better on an evaluation than on production traffic. There are many ways an evaluation can "leak" into your harness (the code around the model, including prompts, tools, and loop that calls Claude). For example, consider an evaluation task that benefits from OCR, but OCR is rarely beneficial in your production tasks. The evaluation harness might add an OCR tool to your application, which improves on the benchmark without any impact on production. More broadly, hillclimbing may add features to that harness that address edge cases in the particular evaluation examples you’ve chosen. These harness additions improve your evaluation score, but don’t translate to improvements in production (Figure 5). FIG 5Common causes of harness overfitting. Three things can help address this:
Split the cases. Use a train set that the hillclimber may read and a test set that is never seen. If the train set scores improve while the test set scores stay flat, then that is a common overfitting warning sign. Never paste failures into the prompt. If the hillclimber reads the failing transcripts, it should never paste the failure content into the prompt. Keep the answers structurally out of the model's reach. Models can sometimes “reward hack” by directly finding answers to evaluations.
As discussed below, the claude-api skill applies these principles for you. /CLAUDE-API HILLCLIMB The hillclimb command in the claude-api skill turns these principles into a guided workflow. When you run /claude-api hillclimb in Claude Code, Claude iterates to improve against a given evaluation. You choose what changes it can make including:
Your system prompt Skills or instruction files Tool descriptions Model choice, effort level, and other API parameters Your harness code
Before it starts, Claude asks what you want to optimize (e.g., performance, or cost while performance holds) and then splits the evaluation set at random into test and train. With a cost goal, it considers a few common cost drivers, including prompt caching, auditing the prompt for compatibility with the selected model, and picking the model and effort setting. Before the first round, Claude checks that the eval's noise (how far the score can move by chance alone) is smaller than the smallest improvement you'd act on; if it isn't, it says so and suggests more repetitions or cases. Each round, Claude reads the previous round’s train transcripts and proposes one change as a patch. It aims each round at a change whose effect can show above the eval's noise: it fixes the failing behavior at its root (e.g., rewrites the section that causes it or adds a missing rule) rather than rewording a line. It then runs evaluation with the patched change. At this point, Claude applies a check: if the train set improves but the test set is flat, Claude suspects overfitting and reverts the patch. If there is a regression, Claude reverts. If train and test sets improve, it keeps the patch (Figure 6). FIG 6The process used by the hillclimber. When the score stalls for two or three rounds, Claude reads each remaining train failure and sorts it by cause. It does the same early if no single fix could gain more than the eval's noise, and suggests more repetitions or cases, rather than spending rounds on changes too small to measure. This step can catch ambiguous evaluation cases, harness errors, or run-to-run variance. Only legitimate failures are included in more hillclimbing rounds. When hillclimbing completes, Claude leaves your code at the version that did best on the test set for your goal. It reports the test result against the baseline with confidence intervals (Figure 7). If the gain is within noise, it says so and recommends against merging. FIG 7Schematic of the report generated following hillclimbing. EXAMPLES Hillclimbing for cost reduction We ran /claude-api hillclimb on an internal customer support benchmark with the goal of reducing cost and improving performance. The benchmark included 44 tickets, with 30 used for the search and 14 held out. It started on Opus 4.8 at default (high) effort settings with 74.4% decision accuracy on the search tickets and a token cost of 4.6 cents per ticket. The hillclimb first audited the prompt, removing mandatory tool-call rituals, a scratchpad step, and contradictory rules. Then it tried Opus 5.5 on low effort. This cleared the baseline accuracy bar at 87.8% and cut cost to 1.9 cents per ticket, less than half the starting cost. Part of that saving comes from Opus 5.5's pricing: input and output tokens cost 20% less than on Opus 4.8, and cache reads cost 60% less. Because Opus 5.5 cleared the bar, the hillclimb then stepped down a tier to check whether a cheaper model could clear it too. Sonnet 5 on low effort scored about the same, 88.9%, at about half the cost, 1 cent per ticket (Figure 8). The customer support benchmarkFour configurations along the adopted pathFIG 8Cost-focused hillclimbing. Finally, Claude improved the prompt with routing rules and a refund-cap cross-reference, bringing Sonnet 5 to 98.9% at about the same cost. On the 14 held-out tickets that the search never saw, the final configuration scored 90.5% against the original setup's 78.6%, at about one fifth of the cost. Hillclimbing for performance improvement Another example is our claude-api skill, which provides guidance on using our APIs and general tips for working with Claude (including the sub-commands discussed in this article). We want to ensure our skill can correctly implement code that uses our APIs, and we built an evaluation set derived from our documentation to test the skill. On our evaluation, the skill started at 66%. We gave the hillclimber access to documentation and our SDKs, allowing Claude to identify errors and self-correct them (Figure 9). Claude found that the skill was missing coverage of eight features. Adding sections for them in the skill improved performance to 74%. It then found errors in C# and Java type tables, boosting performance to 77%. The claude-api skill evalFrom 66.1% to 87.9% in three phases of workFIG 9Performance-focused hillclimbing. After the score stalled for two rounds, Claude analyzed the remaining failures and bucketed them by root-cause. A normal round makes one edit for the most common failure. This step makes no edit; it only sorts every remaining failure by cause. This reflection step was useful in a few ways:
Reflecting across a collection of failures, the hillclimber found that the skill content was present but Claude was simply writing older API shapes (e.g., from its trained priors). To address, the hillclimber added a table near the top of the skill that guided Claude from the forms it remembered to the current ones: for example, from extended thinking with a fixed token budget, which the API now rejects on recent Opus models, to adaptive thinking, and from older versions of the web search and web fetch tools to the current ones. It also moved the C# and Java warnings against fixed-budget thinking above their adaptive-thinking examples. This improved performance to 80%. Tasks that never improved in performance despite addressing obvious content gaps are tells that the example or grader is flawed. One task asked for code that catches one error type, while its grader wanted a chain of at least three. Claude reworded the task. Another grader's instructions contradicted our docs, and testing the real API showed the docs were right. Addressing these, along with more skill edits, brought performance to ~88%.
GETTING STARTED Note: Run claude update first. The claude-api skill ships inside Claude Code, so updating gets you the latest version of these commands. CODEShellclaude update Then, in Claude Code: PROMPT/claude-api build-eval /claude-api hillclimb These sub-commands can be used directly in Claude Code via the claude-api skill: Run /claude-api build-eval if you want to generate an evaluation set for a particular problem. You can steer it by providing access to examples (e.g., traces). Claude will employ the guidance shared in this article to design the examples and grader, and ensure you approve the examples and the grader. Run /claude-api hillclimb if you have an evaluation and want Claude to improve on this, guided by your goal (e.g., better performance, or lower cost while performance holds). Claude will employ the guidance shared in this article to check for overfitting while climbing and check for bugs in the eval itself, such as a grader that marks a correct-looking answer wrong or a harness error, both before the first round and whenever the score stalls. With special thanks to Misha Khalman for skill development. With thanks to Misha Khalman, Michael Segner, Matt Bell, Matt Thanabalan, and Punit Shah for reviews, contributions, and product support.
原文入口
阅读原文(claude.dev)原文将在新窗口打开。收录时间不是内容更新时间;正文、译文与解读的版权归原作者/来源所有,本站仅作个人阅读辅助并保留原文入口;页面时间均为北京时间。
了解来源批准与收录规则