Automating eval design and hillclimbing with Claude
https://claude.dev/blog/automating-eval-design-and-hillclimbing/📌 【Anthropic 官方發布】用 Claude 自動化打造評測與逐步最佳化
TL;DR:claude-api skill 新增兩個指令,自動化建置評測與逐步最佳化流程。
你的 AI 應用到底有沒有變好,還是你只是在自己騙自己?Anthropic 這次把「怎麼做出一個不會騙人的評測」和「怎麼在不過度配適的前提下逐步改善」都寫成了 Claude Code 裡可以直接呼叫的指令。
🤔 評測設計為什麼這麼難
這篇文章指出,評測(evaluation)提供的是你的應用或 skill 在特定任務上的表現訊號,但設計評測、以及在不自我欺騙的前提下改善表現,其實不容易。常見的錯誤包括:為了方便生成或方便打分而選錯任務分佈、忽略任務本身的模糊性、或是評分者(grader)本身不穩定。
🧩 好評測的四個共同特徵
文章列出設計良好評測的四個要素:
- 任務要能反映真實的生產環境使用情境,而不是因為好生成或好打分才被選中。
- 更強的模型、更多的思考(effort)應該帶來更高的分數;如果沒有,通常代表任務本身有歧義,或評分者校準出了問題。
- 在前沿(frontier)模型用最高 effort 時,分數也應該明顯低於 100%,否則無法可靠判斷後續改動的影響,而且這個差距不該是來自不可能完成或模糊的任務。
- 同一設定下多次執行的變異(run-to-run variance)要低;高變異通常來自任務本身模糊、評分者對相同輸出給出不同判決,或是環境殘留狀態(例如前一次測試留下的檔案、git 歷史)洩漏了答案。
文章也特別點名「對抗性抽樣(adversarial sampling)」的陷阱:如果只挑「現在這個模型會答錯」的案例,等於只在取樣某一個模型能力曲面上的低谷,最後評測測的其實是這個模型的特定失敗指紋,而不是應用真正在意的難度。建議改成:挑選人類判斷確實困難、且能說明「為什麼難」的案例;納入從生產流量、bug 回報、工單中觀察到的具體失敗案例;但不能完全信任使用者流量,因為使用者通常只會嘗試他們預期會成功的操作,純靠使用紀錄取樣的任務分佈容易偏向過於簡單。
🧩 /claude-api build-eval:讓 Claude 主持訪談、自動建置評測
執行 /claude-api build-eval 後,Claude 會在對話中訪談使用者,直接在你的程式碼庫裡建出評測,並在特定節點暫停等待確認。取樣案例的優先順序依序是:生產環境的對話紀錄(會先詢問資料保留與敏感性問題)、bug 回報與客服工單、使用者手寫的 5 到 10 個案例,最後才是從程式碼庫合成的案例。
建好輸入案例後,Claude 會依應用的輸出型態提出最省錢的評分方式:如果輸出空間受限(固定分類、符合 schema 的 JSON、能跑測試的程式碼),就用程式化驗證(exact match 等);如果輸出是開放式但有清楚的品質標準,就預設用 LLM-as-judge:由另一個模型讀取輸入、輸出和寫成「可檢查陳述」而非 1 到 5 分量表的評分準則,給出分數與理由;如果有基準(baseline)可比較,評審模型則會在不知道哪個是基準、順序隨機的情況下,直接選出較好的一方。使用者可以自行選擇評審用的模型,但規則是它不能是被測試的那個模型。Claude 會先手動評幾個案例,詢問使用者是否會打出不同分數,藉此校正評分者。
確認評分者沒問題後,指令會告知評測規模(案例數 × 重複次數 × 模型數)與大概花費時間,接著跑一次基準並附上信賴區間的分數。產出的東西包括:所有案例、評分邏輯、執行腳本、每個案例一行 JSON 加一份完整對話紀錄,以及一個列出每個案例分數並連到該筆對話紀錄的靜態頁面;如果想要更多呈現方式(例如圖表),只要提出要求 Claude 就會另外做一頁,而且這些額外頁面預設是純本地檔案,不會向外連網。
在跑基準的過程中,Claude 還會做幾項診斷檢查:對同一個輸出重複跑評分者兩次,確認判決是否一致;檢查是否有逾時、API 錯誤或被截斷的回答,避免把基礎設施噪訊誤判成模型表現的變異;如果基準分數已經高達 95% 以上,則會提醒使用者,此時逐步最佳化應該轉向探索成本或延遲,而不是繼續追求分數。
🧩 /claude-api hillclimb:一次只改一個變數,用 held-out 集避免過度配適
有了可信的評分方式後,下一步是 hillclimb(逐步最佳化):調整像是 effort 或 prompt 這類會在成本與表現之間做取捨的參數,同時保留一組 held-out 範例來抓出過度配適。文章給出兩個選擇優化對象的原則:一是「便宜迭代」,優先選擇修改成本低、容易復原的介面,像是文字、prompt、skill 本身,而不是對 agent harness 做大範圍的程式碼改動;二是「可歸因」,分數的變化要能明確歸因到正在調整的那個介面上,文章提到多個成功案例都是把焦點放在 skill 的觸發邏輯(skill triggering)上。
🎯 實務啟示
對正在維護 Claude 應用或自訂 skill 的團隊,這套流程把「怎麼確保評測本身值得信任」具體拆成了可檢查的步驟(評分者一致性、基礎設施噪訊、headroom),而不是憑感覺相信一個分數。更實際的是,把 hillclimbing 限定在「便宜且可歸因」的介面(prompt、skill 觸發條件)上,而不是貿然大改 agent 架構,能避免把進步的訊號和噪訊混在一起。
🔗 來源
- 標題:Automating eval design and hillclimbing with Claude
- 作者/機構:Anthropic
- 連結:https://claude.dev/blog/automating-eval-design-and-hillclimbing/
#Anthropic #ClaudeCode #LLMEvaluation #Hillclimbing #AIEngineering #PromptEngineering #EvalDesign #AgenticAI #LLMasJudge #MLOps
原始資料 Claude Blog · 收集於 2026-10-07
摘要原文
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 spent png Three model sizes at three effort settings, illustrative Perfect score low effort medium effort high effort Action tokens per attempt, log scale Score Frontier model Mid-size model Smaller model 1 2 3 4 1 A more capable model scores higher 2 More effort scores higher 3 Headroom below a perfect score 4 Low run-to-run variance Perfect score low medium high Action tokens per attempt, log scale Score Frontier model Mid-size model Smaller model 1 2 3 4 1 A more capable model scores higher 2 More effort scores higher 3 Headroom below a perfect score 4 Low run-to-run variance FIG 1 The 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 2 Adversarial 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 3 Example 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 4 Schematic 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.
由 claude-code/sonnet 自動生成