← 所有文章

Evaluations:模型品質的 XCTest(iOS 27)

一般的單元測試會斷言 add(2, 2) 回傳 4,若非如此,建置就會亮紅燈。AI 功能在第一行就打破了這個契約,因為同一段 prompt 每次執行都可能產生不同的句子,而「不同」並不等於「錯誤」。你無法針對模型寫出 #expect(summary == "預期的摘要"),因為根本不存在唯一的預期字串。你能衡量的,是輸出是否夠好、是否夠頻繁地夠好,而衡量的依據是你自己訂定的標準。Apple 全新的 Evaluations 框架正是提供了這套衡量機制,搭配型別安全的 Swift API,做為開發流程的一環來執行1。它是 27 版的新功能,橫跨各個 Apple 平台(iOS、iPadOS、macOS、visionOS 與 watchOS):這是一項你在測試時執行的開發者工具,通常跑在你的 Mac 上,而非你打包進 app 內出貨的執行階段功能1

如果你寫過測試,這套架構會讓你倍感熟悉。你定義資料集、產生模型回應、套用度量,再彙整結果,接著便能看出哪種做法表現最佳,以及個別回應在哪裡不如預期1。它的心智模型就是模型品質版的 XCTest:相同的迴圈(安排一個案例、執行、斷言某件事),只是斷言的方式不同(用評分過的度量,而非相等比對)。

在第 298 場議程中,Apple 如此界定核心問題:生成式 AI 功能打破了軟體測試的一項根本契約,因為同一組輸入可能產生不同的輸出,這使得單元測試力有未逮25

Watch on Apple Developer ↗
為何相等斷言會在 AI 功能上失靈:同一組輸入可能產生不同的輸出。

TL;DR / 重點摘要

  • Evaluations 框架是 27 版在所有 Apple 平台(iOS、iPadOS、macOS、visionOS、watchOS)上的新功能,是一層用來衡量智慧驅動功能的開發者工具,做為測試流程的一環來執行(通常在 Mac 上)1
  • Evaluator 是你直接內嵌撰寫、以 closure 為基礎的評估器;Evaluation 協定則是你實作的型別,用來讓受測系統針對資料集執行,並套用各個評估器23
  • Metric 透過工廠方法(passingfailingscoringignore)攜帶一個具名結果,而 ScoreDimension 則為「以模型當裁判」的評估器命名一條評分軸45
  • ModelSample 是通用型的評估樣本;SampleGenerator 是一個 actor,會以非同步串流的方式從語言模型產生樣本;結果會落入一個具有型別欄位的 DataFrame,其中包含一個 responseColumn678
  • ToolCallEvaluator 會比對代理式工具呼叫與 TrajectoryExpectation,並由 ArgumentMatcher 定義每個引數的驗證方式91011
  • EvaluationTrait 會在一個測試內執行評估,並將結果記錄為附件,這正是接入 Swift Testing 執行的橋樑12

本文逐一走過 API 表面、說明每個元件存在的原因,並把它們繫回它所評分的 Foundation Models 工具呼叫工作。凡是我展示某個 Apple 尚未公布確切簽章的呼叫,我都會標示為示意用途,並提醒你務必對照官方文件確認。

Evaluator 模型

框架的核心問題是「這次輸出有多好」,而它用一套精簡的詞彙來回答:評估器負責判定、度量負責記錄、評分維度負責給分,結果則負責彙整。

Evaluation 協定是你實作來定義一次評估的型別,它會讓受測系統針對資料集執行,並套用各個評估器來衡量表現3。其宣告極為精簡:

// 27.0 beta (all Apple platforms)
protocol Evaluation : Sendable

這個協定之所以是 Sendable,是因為評估屬於並行作業:眾多樣本平行執行,正如 Swift Testing 預設會平行執行測試案例一樣13。當你想要一個可重複使用、具名的評估時,便實作這個協定。當你想要快速搞定時,則改用 Evaluator,Apple 將它描述為以 closure 為基礎、可內嵌使用而無須定義自訂型別的評估器2

// 27.0 beta (all Apple platforms)
struct Evaluator<Input> where Input : SampleProtocol,
    Input.ExpectedValue : Decodable,
    Input.ExpectedValue : Encodable,
    Input.ExpectedValue : Sendable

Apple 的說明指出,這個 closure 會接收輸入樣本與回應,並可同時存取 .value.transcript2.value 是模型的型別化輸出;.transcript 則是它如何得出結果的紀錄。內嵌評估器就是模型品質版的一行式 #expect 區塊:不必建立子類別,只要把判斷寫成一個 closure 即可。以下的呼叫形式僅供示意;請對照 Apple 文件確認其初始化器:

import Evaluations

// Illustrative call shape — confirm against Apple's docs.
let nonEmpty = Evaluator<ModelSample<String>> { input, response in
    response.value.isEmpty ? .failing("empty output") : .passing()
}

closure 回傳的是一個 Metric。Apple 把 Metric 描述為攜帶結果值的具名度量,並明確點名各個工廠方法:passingfailingscoringignore 各會回傳一個內含結果的新 Metric4

// 27.0 beta (all Apple platforms)
struct Metric

這四個工廠方法對應到 AI 功能所需的各種判斷類型。摘要工具要嘛包含必要的事實、要嘛沒有,因此得到 passingfailing。語氣評分準則從 1 分到 5 分,因此得到 scoring。某個你想排除於彙整之外的樣本(格式錯誤的輸入、已知有問題的測試夾具)則得到 ignore,它會把該列保留在資料集中,又不致汙染統計數字。從 passing 到評分式 scoring 的這整段範圍,正是框架所承諾的:從簡單的通過或失敗檢查,一路到搭配「以模型當裁判」模式的細緻評分1

在這段範圍的評分端,ScoreDimension 才真正展現價值。Apple 將它定義為「以模型當裁判」評估器的具名評分維度,每個維度都會定義一個名稱(用作 DataFrame 欄位)、一段選用的描述,以及每個分數所代表意義的定義5

// 27.0 beta (all Apple platforms)
struct ScoreDimension

單一輸出可能在某條軸上表現良好,在另一條軸上卻表現不佳。一封草擬的電子郵件可能內容正確,語氣卻不對。ScoreDimension 讓你分開為這些軸評分(正確性、語氣、簡潔度),如此彙整結果便能告訴你是哪個維度下滑,而不只是整體品質下滑。維度名稱會成為一個欄位,意味著分數會落入一張可排序、可比較的結構化表格,而非一大片散文。

那張表格就是 EvaluationResult。Apple 把它描述為執行一次模型評估的結果,是一個包含該次評估執行之摘要與詳細結果的結構14

// 27.0 beta (all Apple platforms)
struct EvaluationResult

這種兩層式結構(摘要加上明細)正是評估得以付諸行動的關鍵。摘要回答「這段 prompt 是否比上一段表現更好」。明細回答「哪些樣本不如預期」,讓你能打開最糟的那幾列,讀出模型究竟產生了什麼1

樣本與產生

評估需要可供執行的案例,而框架中一個案例的單位就是樣本。ModelSample 是通用的那一種。Apple 將它描述為通用型的語言模型評估樣本,可接受以字串為基礎的 prompt 與指示6

// 27.0 beta (all Apple platforms)
struct ModelSample<ExpectedValue> where ExpectedValue : Decodable,
    ExpectedValue : Encodable,
    ExpectedValue : Sendable

泛型參數 ExpectedValue 就是型別化的預期值:自由文字任務用字串,有已知答案的任務則用結構化的 Codable 型別。Codable 加上 Sendable 這兩項約束,與 EvaluatorInput.ExpectedValue 相互呼應,因為預期值必須序列化進結果表格,並在平行執行期間跨越並行邊界。至於多模態的 prompt,Apple 指出你可以建立自訂的一致性,或改用搭配預建 prompt 的初始化器6

手動撰寫每個樣本並不具擴充性,這正是 SampleGenerator 存在的理由,它是一個會運用語言模型產生評估樣本的 actor7

// 27.0 beta (all Apple platforms)
actor SampleGenerator<SampleType> where SampleType : ModelSampleProtocol

它之所以是 actor,是因為它持有可變的產生狀態(已接受與已拒絕的樣本),而非同步迭代會更動這個狀態,actor 隔離正是 Swift 用來防範該狀態出現資料競爭的護欄。Apple 的工作流程是:建立一個產生器、設定其屬性,再呼叫它以非同步串流的方式產出新樣本;迭代結束後,你便能取得所有已產生的樣本,或任何被驗證器拒絕的樣本7。被拒絕的那一批是值得停下來細看的細節。一個悄悄丟棄壞樣本的產生器,會把自己的失敗率藏起來;把這些被拒樣本攤開來,能讓你像稽核手寫夾具那樣稽核資料集。

樣本一旦執行完畢,回應便會落入一個帶有型別化欄位描述子的 DataFrame,讓你不必靠字串硬查就能讀取表格。Apple 為回應欄位取了精確的名稱:responseColumn,這是詳細 DataFrame 中模型回應的型別化欄位描述子8

// 27.0 beta (all Apple platforms)
var responseColumn: ResultColumn<Self.Subject> { get }

泛型 ResultColumn<Value> 正是讓欄位具備型別的關鍵:它是 DataFrame 欄位的描述子,以其所容納的值來參數化15。除了 responseColumn,框架還提供了對應輸入樣本的 inputColumn,以及對應預期值的 expectedColumn,每一個都是型別化的 ResultColumn1617。型別化欄位所秉持的,與 Swift Testing 的運算式擷取是同一種直覺:與其從一個無型別的袋子裡掏出某個值、再祈禱型別轉換成立,不如透過一個知道自身型別的描述子來讀取它。當你把結果餵進 MetricsAggregator 求取平均值、中位數與標準差時,這些欄位就是你定位資料的途徑,無須對鍵名瞎猜18

工具與軌跡檢查

最難測試的 AI 功能就是代理式的那一種,因為正確與否並非一個字串,而是一連串動作。當一個 Foundation Models 工作階段先呼叫 OCRTool、再呼叫 BarcodeReaderTool、接著呼叫你自己的目錄查詢時,問題不在於「最終那句話是否吻合」,而在於「模型是否走了正確的路徑」19ToolCallEvaluator 會直接為那條路徑評分。Apple 將它描述為一個會比對代理式工具呼叫與預期軌跡的評估器9

// 27.0 beta (all Apple platforms)
struct ToolCallEvaluator<Input> where Input : ModelSampleProtocol,
    Input.Expectation == TrajectoryExpectation

where 子句是承重的部分:輸入的預期值必須是一個 TrajectoryExpectation。Apple 把這個型別描述為一次評估所預期的工具呼叫模式,並沿三條軸來指定10

// 27.0 beta (all Apple platforms)
struct TrajectoryExpectation

Apple 指出 ToolCallEvaluator 支援有序序列、無序預期、不允許工具的檢查,以及群組步驟,並能在單次評估流程中同時產出嚴格與部分兩種結果9。每一項都對應到一種真實的代理失誤。有序序列能逮到以錯誤順序呼叫正確工具的模型。無序預期則表示「這些呼叫都得發生,順序不拘」。不允許工具的檢查能逮到伸手去碰它本不該碰的工具的模型(這是安全情境:一個本應維持唯讀的代理卻去呼叫了具破壞性的工具)。群組步驟則用來表達「擇一即可」,對應到有不只一條路徑可被接受的分支情形。

嚴格加部分這組搭配,貼合代理品質實際劣化的方式。一段新 prompt 鮮少會把功能從完美直接拖垮;它通常是把功能從「每次都走對軌跡」拉到「多數時候走對軌跡,但有一個呼叫順序顛倒」。只有嚴格結果會把這種情況回報成一次平板的失敗,完全沒告訴你模型究竟差了多少。部分結果則量化了這些差之毫釐的情況,而那正是你用來調校的訊號。

每次呼叫的正確性則位於更下一層,落在引數裡。模型可能用錯誤的值去呼叫正確的工具,而 ArgumentMatcher 會定義每個引數的驗證方式。Apple 將它描述為用來定義如何驗證工具呼叫引數的那些值11

// 27.0 beta (all Apple platforms)
enum ArgumentMatcher

Apple 的說明列出了各項驗證規則:要求精確的值、確認鍵是否存在、檢查範圍、比對模式,或運用語言模型進行語意比對11。語意比對這一項,正是單純的相等斷言無從表達的。如果某個工具引數是一段自由文字查詢,兩個不同的字串可能同樣正確,而一般的 == 會讓一個明明很好的呼叫不通過。把那個引數交給「以模型當裁判」的比對,正是 ScoreDimension 在輸出層所提供的同一個逃生口,只是套用在引數層。各個 case 的拼法取自 Apple 的列舉;以下僅供示意,請務必對照文件確認:

import Evaluations

// Illustrative — confirm shapes against Apple's docs.
let expectation = TrajectoryExpectation(/* ordered / unordered / disallowed steps */)
let evaluator = ToolCallEvaluator<ModelSample<String>>(/* expectation */)

這裡的代理迴圈,正是 Foundation Models 工具呼叫一文 從執行階段那一側所描述的同一個迴圈。在那裡,GenerationOptions.ToolCallingMode 掌管裝置端模型伸手取用工具的積極程度,而框架可在首次呼叫之後切換模式,藉此限定單次請求的工具活動量19ToolCallEvaluator 則是同一個行為的衡量端:你在執行階段設定呼叫姿態,再於測試時為軌跡評分,以確認該姿態確實產出了你所預期的路徑。執行階段的旋鈕與測試階段的評估器,是同一項功能的兩端。

這如何融入工作流程

評估並不是你每季才舉行一次的獨立儀式。它們屬於你測試的左鄰右舍,待在同一個迴圈裡,跑在同一台 Mac 上。框架接入那個迴圈的橋樑就是 EvaluationTrait。Apple 將它描述為一個會執行評估並把結果記錄為附件的測試 trait12

// 27.0 beta (all Apple platforms)
struct EvaluationTrait

「trait」這個詞用得刻意。Swift Testing 整套設定模型,就是套用在 @Test@Suite 宣告上的各個 trait:.enabled(if:).disabled(_:).tags(...) 等等13EvaluationTrait 把一次評估嵌入這套詞彙,於是評估的執行方式就跟測試一樣,落在同一個 swift test 呼叫之下,享有同樣的平行性。把結果記錄為附件,沿用的是 Swift Testing 既有的自訂附件機制,因此評估的詳細結果會一併搭著測試報告與你蒐集的 CI 產物前行13。框架還提供了一個 EvaluationContext,讓測試範圍內的程式碼能在評估完成後讀取結果20

那個 trait 回答了「評估住在哪裡」。它們住在你的測試目標裡,緊鄰你的單元測試,受同一批 trait 所節制。一個 .tags(.evals) 註記能在 prompt 變更後只執行模型品質檢查,正如 .tags(.regression) 用來框限一次迴歸執行13。快速的單元式測試每次編輯都維持綠燈;較慢、由模型驅動的評估,則只跑在那些會觸及模型的 prompt 與工具定義上。

評估與測試的這道分界,呼應了 代理工作流程一文 所談的執行階段與開發工具之分,該文劃出了 app 出貨的裝置端模型,與開發者用來開發 app 的工具模型之間的界線21。Evaluations 站在這道界線的建置那一側:它是 27 週期的開發者工具,在迭代過程中執行,用來衡量你所出貨的執行階段功能是否夠好1。你不會把 Evaluations 框架出貨給使用者,正如你不會把 XCTest 出貨一樣。你出貨的是它所產生的那份信心。

框架對於你要評分哪個模型也保持開放。Apple 指出它能搭配你程式碼可取用的任何模型運作,而資料集那一側則透過 Loader 來供應,這是一個供「能提供資料集的型別」遵循的協定,可使用內建的具體型別,也可為你自己的來源建立自訂的一致性122。在「以模型當裁判」的評分上,ModelJudgeEvaluator 會把查詢、回應與選用的參考資料送往一個裁判模型,由它回傳一或多個維度的分數23,而裁判 prompt 可透過 ModelJudgePrompt 設定,它把指示、回應呈現方式與參考資料注入這三者,捆成單一個可組合的值24。如果你的技術堆疊本就信任 Claude,不妨透過你自己的程式碼路徑把 Claude 拿來當裁判;框架並不會把你綁死在單一模型上。

常見問題

Evaluations 框架是什麼?它在哪個平台上執行?

Evaluations 框架運用型別安全、能融入你開發流程的 Swift API,來衡量你 app 中智慧驅動功能的品質1。它是 27 版在 iOS、iPadOS、macOS、visionOS 與 watchOS 上的新功能:這是一個你在測試時執行的開發者工具框架(通常在 Mac 上),而非打包進 app 內出貨的執行階段功能1。你定義資料集、產生模型回應、套用度量,再彙整結果,接著便能看出哪種做法表現最佳,以及個別回應在哪裡不如預期1

為什麼我不能用 XCTest 或 Swift Testing 的相等斷言來測 AI 功能?

相等斷言需要一個唯一的預期值,而非確定性的模型並沒有這種東西:同一段 prompt 每次執行都可能產生一個不同卻有效的輸出。Evaluations 以評分過的判斷取代了相等比對。一個 Metric 會記錄 passingfailingscoringignore 的結果,而一個 ScoreDimension 則在一條具名的軸上為輸出評分45。你仍然透過 EvaluationTrait 在測試內執行這些評估,因此它們與你其他的測試住在同一個目標、同一個 swift test 迴圈裡12

框架如何評估代理式的工具呼叫行為?

透過 ToolCallEvaluator,它會比對代理式工具呼叫與一條預期軌跡9。你以 TrajectoryExpectation 沿三條軸描述路徑;該評估器支援有序序列、無序預期、不允許工具的檢查,以及群組步驟,並能在一次流程中產出嚴格與部分兩種結果910。逐引數的驗證則使用 ArgumentMatcher(精確的值、鍵是否存在、範圍、模式,或以模型為基礎的語意比對)11

Evaluator 和 Evaluation 協定有什麼差別?

Evaluator 是以 closure 為基礎、可內嵌使用而無須定義自訂型別的評估器;它的 closure 會接收輸入樣本與回應,並可存取 .value.transcript2Evaluation 協定則是你實作的型別,用來定義一個可重複使用、具名的評估,它會讓受測系統針對資料集執行並套用各個評估器3。需要快速內嵌檢查時就用 Evaluator,需要結構化、可重複的評估時就用 Evaluation 協定。

產生的樣本與結果住在哪裡?

SampleGenerator 是一個 actor,會以非同步串流的方式從語言模型產生樣本;迭代結束後,你可讀取已接受的樣本,或被驗證器拒絕的那些7。結果會落入一個帶有型別化 ResultColumn 描述子的 DataFrame:responseColumninputColumnexpectedColumn8161715MetricsAggregator 則在這些資料上計算平均值、中位數與標準差18

完整的 Apple Ecosystem 系列:Foundation Models 框架解析執行階段 LLM 與開發工具 LLM 之分;本框架所評分的 iOS 27 工具呼叫控制;以及 Swift Testing 與 XCTest 之比較EvaluationTrait 正是接入了它的 trait 模型。系列總覽位於 Apple Ecosystem 系列。若想了解更廣泛的「iOS 結合 AI 代理」脈絡,請參閱 iOS 代理開發指南



  1. Apple Developer, “Evaluations” framework overview. Available iOS 27.0, iPadOS 27.0, Mac Catalyst 27.0, macOS 27.0, visionOS 27.0, watchOS 27.0 (all beta). Abstracted as “measure the quality of your app’s intelligence-powered features.” Apple’s discussion states you define datasets, generate model responses, apply metrics, and aggregate results with type-safe Swift APIs that integrate into your development workflow; the framework evaluates features against metrics from simple pass or fail checks to detailed scoring with model-as-judge patterns, aggregates results into summaries that show which approach performs best and where individual responses fall short, and works with any model available to your code. (iOS 27.0+ beta, all Apple platforms) 

  2. Apple Developer, “Evaluator”. A structure (struct Evaluator<Input> with Input : SampleProtocol and Input.ExpectedValue conforming to Decodable, Encodable, Sendable) abstracted as a closure-based evaluator; Apple’s discussion states the closure receives the input sample and the response, providing access to .value and .transcript. (iOS 27.0+ beta, all Apple platforms) 

  3. Apple Developer, “Evaluation”. A protocol (protocol Evaluation : Sendable) abstracted as a type that defines an evaluation; Apple’s discussion states the evaluation runs your system under test against a dataset and applies evaluators to measure performance. (iOS 27.0+ beta, all Apple platforms) 

  4. Apple Developer, “Metric”. A structure (struct Metric) abstracted as a named metric that carries a result value; Apple’s discussion states the factory methods passing, failing, scoring, and ignore return a new Metric with the result stored inside. (iOS 27.0+ beta, all Apple platforms) 

  5. Apple Developer, “ScoreDimension”. A structure (struct ScoreDimension) abstracted as a named scoring dimension for a model judge evaluator; Apple’s discussion states each dimension defines a name (used as the DataFrame column), an optional description, and a definition of what each score means. (iOS 27.0+ beta, all Apple platforms) 

  6. Apple Developer, “ModelSample”. A structure (struct ModelSample<ExpectedValue> with ExpectedValue conforming to Decodable, Encodable, Sendable) abstracted as a general-purpose language model evaluation sample; Apple’s discussion states it accepts string-based prompts and instructions, and that multimodal prompts use a custom conformance or an initializer with a prebuilt prompt. (iOS 27.0+ beta, all Apple platforms) 

  7. Apple Developer, “SampleGenerator”. Declared actor SampleGenerator<SampleType> with SampleType : ModelSampleProtocol, abstracted as an actor that generates evaluation samples using a language model; Apple’s discussion states you create a generator, configure its properties, then call it to produce new samples as an async stream, after which you access all generated samples or any the validator rejected. (iOS 27.0+ beta, all Apple platforms) 

  8. Apple Developer, “responseColumn”. An instance property (var responseColumn: ResultColumn<Self.Subject> { get }) abstracted as a typed column descriptor for the model responses in the detailed DataFrame. (iOS 27.0+ beta, all Apple platforms) 

  9. Apple Developer, “ToolCallEvaluator”. A structure (struct ToolCallEvaluator<Input> with Input : ModelSampleProtocol and Input.Expectation == TrajectoryExpectation) abstracted as an evaluator that verifies agentic tool calls against an expected trajectory; Apple’s discussion states it produces both a strict and partial result from a single evaluation pass and supports ordered sequences, unordered expectations, disallowed tool checks, and group steps. (iOS 27.0+ beta, all Apple platforms) 

  10. Apple Developer, “TrajectoryExpectation”. A structure (struct TrajectoryExpectation) abstracted as the expected pattern of tool calls for an evaluation; Apple’s discussion states it specifies expected tool-calling behavior across three axes. (iOS 27.0+ beta, all Apple platforms) 

  11. Apple Developer, “ArgumentMatcher”. An enumeration (enum ArgumentMatcher) abstracted as the values that define how to validate a tool-call argument; Apple’s discussion states you can require exact values, verify key presence, check ranges, match patterns, or use a language model for semantic matching. (iOS 27.0+ beta, all Apple platforms) 

  12. Apple Developer, “EvaluationTrait”. A structure (struct EvaluationTrait) abstracted as a test trait that runs an evaluation and records the result as attachments. (iOS 27.0+ beta, all Apple platforms) 

  13. Author’s analysis in Swift Testing: The Framework Replacing XCTest, May 2, 2026, covering @Test, @Suite, #expect, #require, parallel-by-default execution, custom attachments, and the trait vocabulary (.enabled(if:), .disabled(_:), .serialized, .timeLimit(...), .tags(...), .bug(...)) that EvaluationTrait extends, with citations to Apple’s Swift Testing and Trait references. 

  14. Apple Developer, “EvaluationResult”. A structure (struct EvaluationResult) abstracted as the results of running a model evaluation; Apple’s discussion states it contains the summary and detailed results from an evaluation run. (iOS 27.0+ beta, all Apple platforms) 

  15. Apple Developer, “ResultColumn”. A structure (struct ResultColumn<Value>) abstracted as a typed descriptor for a column in an evaluation result DataFrame. (iOS 27.0+ beta, all Apple platforms) 

  16. Apple Developer, “inputColumn”. An instance property (var inputColumn: ResultColumn<Self.Sample> { get }) abstracted as a typed column descriptor for the input samples in the detailed DataFrame. (iOS 27.0+ beta, all Apple platforms) 

  17. Apple Developer, “expectedColumn”. An instance property (var expectedColumn: ResultColumn<Self.Sample.ExpectedValue> { get }) abstracted as a typed column descriptor for the expected values in the detailed DataFrame. (iOS 27.0+ beta, all Apple platforms) 

  18. Apple Developer, “MetricsAggregator”. A structure (struct MetricsAggregator) abstracted as a utility for computing aggregate statistics from evaluation metrics; Apple’s discussion states it calculates summary statistics like mean, median, and standard deviation, processing metric data from a DataFrame to produce aggregated results. (iOS 27.0+ beta, all Apple platforms) 

  19. Author’s analysis in Foundation Models in iOS 27: Tool-Calling Control, June 8, 2026, covering GenerationOptions.ToolCallingMode, the framework’s after-first-call mode shift, and the built-in Vision tools OCRTool and BarcodeReaderTool

  20. Apple Developer, “EvaluationContext”. A structure (struct EvaluationContext) abstracted as a context that provides the evaluation result within a test scope; Apple’s discussion states you access the result after the evaluation completes. (iOS 27.0+ beta, all Apple platforms) 

  21. Author’s analysis in Foundation Models Agentic Workflow: In-App vs Tooling LLM, May 1, 2026, on the runtime/tooling LLM distinction and the trust boundary between the shipped on-device model and the developer’s tooling model. 

  22. Apple Developer, “Loader”. A protocol (protocol Loader<Sample> : Sendable) abstracted as a protocol for types that supply a dataset for evaluation; Apple’s discussion states you use one of the built-in concrete types or implement the protocol directly for custom data sources. (iOS 27.0+ beta, all Apple platforms) 

  23. Apple Developer, “ModelJudgeEvaluator”. A structure (struct ModelJudgeEvaluator<Input> with Input : ModelSampleProtocol) abstracted as an evaluator that uses a language model as a judge to score responses; Apple’s discussion states it sends the query, response, and optional reference data to a judge model that returns scores for one or more dimensions. (iOS 27.0+ beta, all Apple platforms) 

  24. Apple Developer, “ModelJudgePrompt”. A structure (struct ModelJudgePrompt<Input> with Input : ModelSampleProtocol) abstracted as a configuration for how a model-as-judge evaluator constructs its prompt; Apple’s discussion states it bundles the instructions, response presentation, and reference-data injection into a single composable value. (iOS 27.0+ beta, all Apple platforms) 

  25. Apple, WWDC26 session 298, Meet the Evaluations framework. Apple states generative-AI features “break a contract that is fundamental to software testing” because “the same input can produce different outputs,” and concludes that “unit tests are insufficient.” 

相關文章

Swift 新功能總覽(2026):WWDC26 更新

來自 WWDC26 的 Swift 6.3 與 6.4:anyAppleOS 可用性、模組選擇器、borrow/mutate 存取器、Iterable 協定、Swift Testing 互通,以及 MLX。

5 分鐘閱讀

Apple 將開源 Foundation Models 框架

WWDC 2026:Foundation Models 框架將於今夏開源,讓同一套 Swift API 也能在伺服器端執行,另有一個全新的 Skills 套件已在 GitHub 上線。

5 分鐘閱讀

The Robots Are Taking Exams in My Search Console

First-party GSC data: 91% of 3.8M impressions fail a human-query filter. Exam questions, pasted errors, and agent sweeps…

10 分鐘閱讀