axiom-foundation-models-diag

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Foundation Models Diagnostics

Foundation Models 诊断指南

Overview

概述

Foundation Models issues manifest as context window exceeded errors, guardrail violations, slow generation, availability failures, and unexpected output. Core principle 80% of Foundation Models problems stem from misunderstanding model capabilities (3B parameter device-scale model, not world knowledge), context limits (4096 tokens), or availability requirements—not framework bugs.
Foundation Models的问题表现为上下文窗口超出错误、护栏规则违反、生成速度慢、可用性故障以及意外输出。核心原则:80%的Foundation Models问题源于对模型能力的误解(这是30亿参数的设备级模型,不具备通用世界知识)、上下文限制(4096 tokens)或可用性要求,而非框架漏洞。

Red Flags — Suspect Foundation Models Issue

预警信号——疑似Foundation Models问题

If you see ANY of these, suspect a Foundation Models misunderstanding, not framework breakage:
  • Generation takes >5 seconds
  • Error:
    exceededContextWindowSize
  • Error:
    guardrailViolation
  • Error:
    unsupportedLanguageOrLocale
  • Model gives hallucinated/wrong output
  • UI freezes during generation
  • Feature works in simulator but not on device
  • FORBIDDEN "Foundation Models is broken, we need a different AI"
    • Foundation Models powers Apple Intelligence across millions of devices
    • Wrong output = wrong use case (world knowledge vs summarization)
    • Do not rationalize away the issue—diagnose it
Critical distinction Foundation Models is a device-scale model (3B parameters) optimized for summarization, extraction, classification—NOT world knowledge or complex reasoning. Using it for the wrong task guarantees poor results.
如果出现以下任何一种情况,应怀疑是对Foundation Models的误解,而非框架故障:
  • 生成耗时超过5秒
  • 错误:
    exceededContextWindowSize
  • 错误:
    guardrailViolation
  • 错误:
    unsupportedLanguageOrLocale
  • 模型输出幻觉/错误内容
  • 生成过程中UI冻结
  • 功能在模拟器中可用,但在真机上不可用
  • 禁止 声称“Foundation Models坏了,我们需要换个AI”
    • Foundation Models为数百万设备上的Apple Intelligence提供支持
    • 错误输出=用例错误(通用世界知识 vs 摘要总结)
    • 不要回避问题——要诊断问题
关键区别:Foundation Models是一款设备级模型(30亿参数),针对摘要、提取、分类进行优化——不适合通用世界知识或复杂推理。错误的任务选型必然导致糟糕的结果。

Mandatory First Steps

强制第一步

ALWAYS run these FIRST (before changing code):
swift
// 1. Check availability
let availability = SystemLanguageModel.default.availability

switch availability {
case .available:
    print("✅ Available")
case .unavailable(let reason):
    print("❌ Unavailable: \(reason)")
    // Possible reasons:
    // - Device not Apple Intelligence-capable
    // - Region not supported
    // - User not opted in
}

// Record: "Available? Yes/no, reason if not"

// 2. Check supported languages
let supported = SystemLanguageModel.default.supportedLanguages
print("Supported languages: \(supported)")
print("Current locale: \(Locale.current.language)")

if !supported.contains(Locale.current.language) {
    print("⚠️ Current language not supported!")
}

// Record: "Language supported? Yes/no"

// 3. Check context usage
let session = LanguageModelSession()
// After some interactions:
print("Transcript entries: \(session.transcript.entries.count)")

// Rough estimation (not exact):
let transcriptText = session.transcript.entries
    .map { $0.content }
    .joined()
print("Approximate chars: \(transcriptText.count)")
print("Rough token estimate: \(transcriptText.count / 3)")
// 4096 token limit ≈ 12,000 characters

// Record: "Approaching context limit? Yes/no"

// 4. Profile with Instruments
// Run with Foundation Models Instrument template
// Check:
// - Initial model load time
// - Token counts (input/output)
// - Generation time per request
// - Areas for optimization

// Record: "Latency profile: [numbers from Instruments]"

// 5. Inspect transcript for debugging
print("Full transcript:")
for entry in session.transcript.entries {
    print("Entry: \(entry.content.prefix(100))...")
}

// Record: "Any unusual entries? Repeated content?"
在修改代码前,务必先执行以下步骤
swift
// 1. 检查可用性
let availability = SystemLanguageModel.default.availability

switch availability {
case .available:
    print("✅ 可用")
case .unavailable(let reason):
    print("❌ 不可用:\(reason)")
    // 可能的原因:
    // - 设备不支持Apple Intelligence
    // - 地区不支持
    // - 用户未选择启用
}

// 记录:"是否可用?是/否,不可用的原因"

// 2. 检查支持的语言
let supported = SystemLanguageModel.default.supportedLanguages
print("支持的语言:\(supported)")
print("当前区域设置:\(Locale.current.language)")

if !supported.contains(Locale.current.language) {
    print("⚠️ 当前语言不受支持!")
}

// 记录:"语言是否受支持?是/否"

// 3. 检查上下文使用情况
let session = LanguageModelSession()
// 进行一些交互后:
print("对话条目数:\(session.transcript.entries.count)")

// 粗略估算(非精确值):
let transcriptText = session.transcript.entries
    .map { $0.content }
    .joined()
print("大约字符数:\(transcriptText.count)")
print("粗略token估算:\(transcriptText.count / 3)")
// 4096 token限制 ≈ 12,000字符

// 记录:"是否接近上下文限制?是/否"

// 4. 使用Instruments进行性能分析
// 使用Foundation Models Instrument模板运行
// 检查:
// - 初始模型加载时间
// - Token数量(输入/输出)
// - 每次请求的生成时间
// - 可优化的区域

// 记录:"延迟分析:[来自Instruments的数值]"

// 5. 检查对话记录以调试
print("完整对话记录:")
for entry in session.transcript.entries {
    print("条目:\(entry.content.prefix(100))...")
}

// 记录:"是否有异常条目?重复内容?"

What this tells you

这些步骤能告诉你什么

  • Unavailable → Proceed to Pattern 1a/1b/1c (availability issues)
  • Context exceeded → Proceed to Pattern 2a (token limit)
  • Guardrail error → Proceed to Pattern 2b (content policy)
  • Language error → Proceed to Pattern 2c (unsupported language)
  • Wrong output → Proceed to Pattern 3a/3b/3c (output quality)
  • Slow generation → Proceed to Pattern 4a/4b/4c/4d (performance)
  • UI frozen → Proceed to Pattern 5a (main thread blocking)
  • 不可用 → 进入模式1a/1b/1c(可用性问题)
  • 上下文超出 → 进入模式2a(token限制)
  • 护栏规则错误 → 进入模式2b(内容政策)
  • 语言错误 → 进入模式2c(不支持的语言)
  • 错误输出 → 进入模式3a/3b/3c(输出质量)
  • 生成速度慢 → 进入模式4a/4b/4c/4d(性能)
  • UI冻结 → 进入模式5a(主线程阻塞)

MANDATORY INTERPRETATION

强制解读规则

Before changing ANY code, identify ONE of these:
  1. If
    availability = .unavailable
    → Device/region/opt-in issue (not code bug)
  2. If error is
    exceededContextWindowSize
    → Too many tokens (condense transcript)
  3. If error is
    guardrailViolation
    → Content policy triggered (not model failure)
  4. If error is
    unsupportedLanguageOrLocale
    → Language not supported (check supported list)
  5. If output is hallucinated → Wrong use case (world knowledge vs extraction)
  6. If generation >5 seconds → Not streaming or need optimization
  7. If UI frozen → Calling on main thread (use Task {})
在修改任何代码之前,必须确定以下情况之一:
  1. 如果
    availability = .unavailable
    → 设备/地区/用户未启用问题(非代码bug)
  2. 如果错误为
    exceededContextWindowSize
    → Token数量过多(压缩对话记录)
  3. 如果错误为
    guardrailViolation
    → 触发了内容政策(非模型故障)
  4. 如果错误为
    unsupportedLanguageOrLocale
    → 语言不受支持(检查支持列表)
  5. 如果输出存在幻觉 → 用例错误(通用世界知识 vs 信息提取)
  6. 如果生成耗时超过5秒 → 未使用流式输出或需要优化
  7. 如果UI冻结 → 在主线程调用了同步方法(使用Task {})

If diagnostics are contradictory or unclear

如果诊断结果矛盾或不明确

  • STOP. Do NOT proceed to patterns yet
  • Add detailed logging to every
    respond()
    call
  • Run with Instruments Foundation Models template
  • Establish baseline: what's actually happening vs what you assumed
  • 停止操作。不要急于进入具体模式
  • 为每个
    respond()
    调用添加详细日志
  • 使用Instruments的Foundation Models模板运行
  • 建立基准:明确实际发生的情况 vs 你的假设

Decision Tree

决策树

Foundation Models problem?
├─ Won't start?
│  ├─ .unavailable → Availability issue
│  │  ├─ Device not capable? → Pattern 1a (device requirement)
│  │  ├─ Region restriction? → Pattern 1b (regional availability)
│  │  └─ User not opted in? → Pattern 1c (Settings check)
│  │
├─ Generation fails?
│  ├─ exceededContextWindowSize → Context limit
│  │  └─ Long conversation or verbose prompts? → Pattern 2a (condense)
│  │
│  ├─ guardrailViolation → Content policy
│  │  └─ Sensitive or inappropriate content? → Pattern 2b (handle gracefully)
│  │
│  ├─ unsupportedLanguageOrLocale → Language issue
│  │  └─ Non-English or unsupported language? → Pattern 2c (language check)
│  │
│  └─ Other error → General error handling
│     └─ Unknown error type? → Pattern 2d (catch-all)
├─ Output wrong?
│  ├─ Hallucinated facts → Wrong model use
│  │  └─ Asking for world knowledge? → Pattern 3a (use case mismatch)
│  │
│  ├─ Wrong structure → Parsing issue
│  │  └─ Manual JSON parsing? → Pattern 3b (use @Generable)
│  │
│  ├─ Missing data → Tool needed
│  │  └─ Need external information? → Pattern 3c (tool calling)
│  │
│  └─ Inconsistent output → Sampling issue
│     └─ Different results each time? → Pattern 3d (temperature/greedy)
├─ Too slow?
│  ├─ Initial delay (1-2s) → Model loading
│  │  └─ First request slow? → Pattern 4a (prewarm)
│  │
│  ├─ Long wait for results → Not streaming
│  │  └─ User waits 3-5s? → Pattern 4b (streaming)
│  │
│  ├─ Verbose schema → Token overhead
│  │  └─ Large @Generable type? → Pattern 4c (includeSchemaInPrompt)
│  │
│  └─ Complex prompt → Too much processing
│     └─ Massive prompt or task? → Pattern 4d (break down)
└─ UI frozen?
   └─ Main thread blocked → Async issue
      └─ App unresponsive during generation? → Pattern 5a (Task {})
是否为Foundation Models问题?
├─ 无法启动?
│  ├─ .unavailable → 可用性问题
│  │  ├─ 设备不兼容? → 模式1a(设备要求)
│  │  ├─ 地区限制? → 模式1b(区域可用性)
│  │  └─ 用户未启用? → 模式1c(设置检查)
│  │
├─ 生成失败?
│  ├─ exceededContextWindowSize → 上下文限制
│  │  └─ 对话过长或提示过于冗长? → 模式2a(压缩对话)
│  │
│  ├─ guardrailViolation → 内容政策
│  │  └─ 包含敏感或不当内容? → 模式2b(优雅处理)
│  │
│  ├─ unsupportedLanguageOrLocale → 语言问题
│  │  └─ 非英语或不受支持的语言? → 模式2c(语言检查)
│  │
│  └─ 其他错误 → 通用错误处理
│     └─ 未知错误类型? → 模式2d(通用捕获)
├─ 输出错误?
│  ├─ 事实幻觉 → 模型用例错误
│  │  └─ 询问通用世界知识? → 模式3a(用例不匹配)
│  │
│  ├─ 结构错误 → 解析问题
│  │  └─ 手动解析JSON? → 模式3b(使用@Generable)
│  │
│  ├─ 数据缺失 → 需要工具调用
│  │  └─ 需要外部信息? → 模式3c(工具调用)
│  │
│  └─ 输出不一致 → 采样问题
│     └─ 相同提示每次结果不同? → 模式3d(温度/贪心采样)
├─ 生成过慢?
│  ├─ 初始延迟(1-2秒) → 模型加载
│  │  └─ 首次请求缓慢? → 模式4a(预加载)
│  │
│  ├─ 等待结果时间过长 → 未使用流式输出
│  │  └─ 用户等待3-5秒? → 模式4b(流式输出)
│  │
│  ├─ 大 schema 开销 → Token冗余
│  │  └─ 大型@Generable类型? → 模式4c(includeSchemaInPrompt)
│  │
│  └─ 提示过于复杂 → 处理负载过高
│     └─ 超大提示或任务? → 模式4d(拆分任务)
└─ UI冻结?
   └─ 主线程阻塞 → 异步问题
      └─ 生成过程中应用无响应? → 模式5a(使用Task {})

Diagnostic Patterns

诊断模式

Pattern 1a: Device Not Capable

模式1a:设备不兼容

Symptom:
  • SystemLanguageModel.default.availability = .unavailable
  • Reason: Device not Apple Intelligence-capable
Diagnosis:
swift
let availability = SystemLanguageModel.default.availability

switch availability {
case .available:
    print("✅ Available")
case .unavailable(let reason):
    print("❌ Reason: \(reason)")
    // Check if device-related
}
Fix:
swift
// ❌ BAD - No availability UI
let session = LanguageModelSession() // Crashes on unsupported devices

// ✅ GOOD - Graceful UI
struct AIFeatureView: View {
    @State private var availability = SystemLanguageModel.default.availability

    var body: some View {
        switch availability {
        case .available:
            AIContentView()
        case .unavailable:
            VStack {
                Image(systemName: "cpu")
                Text("AI features require Apple Intelligence")
                    .font(.headline)
                Text("Available on iPhone 15 Pro and later")
                    .font(.caption)
                    .foregroundColor(.secondary)
            }
        }
    }
}
Time cost: 5-10 minutes to add UI

症状
  • SystemLanguageModel.default.availability = .unavailable
  • 原因:设备不支持Apple Intelligence
诊断代码
swift
let availability = SystemLanguageModel.default.availability

switch availability {
case .available:
    print("✅ 可用")
case .unavailable(let reason):
    print("❌ 原因:\(reason)")
    // 检查是否为设备相关问题
}
修复方案
swift
// ❌ 错误示例 - 无可用性UI
let session = LanguageModelSession() // 在不支持的设备上会崩溃

// ✅ 正确示例 - 优雅的UI处理
struct AIFeatureView: View {
    @State private var availability = SystemLanguageModel.default.availability

    var body: some View {
        switch availability {
        case .available:
            AIContentView()
        case .unavailable:
            VStack {
                Image(systemName: "cpu")
                Text("AI功能需要Apple Intelligence")
                    .font(.headline)
                Text("适用于iPhone 15 Pro及后续机型")
                    .font(.caption)
                    .foregroundColor(.secondary)
            }
        }
    }
}
时间成本:5-10分钟添加UI

Pattern 1b: Regional Availability

模式1b:区域可用性限制

Symptom:
  • Feature works for some users, not others
  • .unavailable due to region restrictions
Diagnosis: Foundation Models requires:
  • Supported region (e.g., US, UK, Australia initially)
  • May expand over time
Fix:
swift
// ✅ GOOD - Clear messaging
switch SystemLanguageModel.default.availability {
case .available:
    // proceed
case .unavailable(let reason):
    // Show region-specific message
    Text("AI features not yet available in your region")
    Text("Check Settings → Apple Intelligence for availability")
}
Time cost: 5 minutes

症状
  • 功能对部分用户可用,对其他用户不可用
  • .unavailable原因是区域限制
诊断: Foundation Models要求:
  • 支持的地区(例如初始支持美国、英国、澳大利亚)
  • 支持范围可能会逐步扩大
修复方案
swift
// ✅ 正确示例 - 清晰的提示信息
switch SystemLanguageModel.default.availability {
case .available:
    // 继续执行
case .unavailable(let reason):
    // 显示区域相关提示
    Text("AI功能暂未在你的地区开放")
    Text("前往设置 → Apple Intelligence查看可用性")
}
时间成本:5分钟

Pattern 1c: User Not Opted In

模式1c:用户未启用

Symptom:
  • Device capable, region supported
  • Still .unavailable
Diagnosis: User must opt in to Apple Intelligence in Settings
Fix:
swift
// ✅ GOOD - Direct user to settings
switch SystemLanguageModel.default.availability {
case .available:
    // proceed
case .unavailable:
    VStack {
        Text("Enable Apple Intelligence")
        Text("Settings → Apple Intelligence → Enable")
        Button("Open Settings") {
            if let url = URL(string: UIApplication.openSettingsURLString) {
                UIApplication.shared.open(url)
            }
        }
    }
}
Time cost: 10 minutes

症状
  • 设备兼容,地区支持
  • 仍然显示.unavailable
诊断: 用户必须在设置中启用Apple Intelligence
修复方案
swift
// ✅ 正确示例 - 引导用户前往设置
switch SystemLanguageModel.default.availability {
case .available:
    // 继续执行
case .unavailable:
    VStack {
        Text("启用Apple Intelligence")
        Text("设置 → Apple Intelligence → 启用")
        Button("打开设置") {
            if let url = URL(string: UIApplication.openSettingsURLString) {
                UIApplication.shared.open(url)
            }
        }
    }
}
时间成本:10分钟

Pattern 2a: Context Window Exceeded

模式2a:上下文窗口超出

Symptom:
Error: LanguageModelSession.GenerationError.exceededContextWindowSize
Diagnosis:
  • 4096 token limit (input + output)
  • Long conversations accumulate tokens
  • Verbose prompts eat into limit
Fix:
swift
// ❌ BAD - Unhandled error
let response = try await session.respond(to: prompt)
// Crashes after ~10-15 turns

// ✅ GOOD - Condense transcript
var session = LanguageModelSession()

do {
    let response = try await session.respond(to: prompt)
} catch LanguageModelSession.GenerationError.exceededContextWindowSize {
    // Condense and continue
    session = condensedSession(from: session)
    let response = try await session.respond(to: prompt)
}

func condensedSession(from previous: LanguageModelSession) -> LanguageModelSession {
    let entries = previous.transcript.entries

    guard entries.count > 2 else {
        return LanguageModelSession(transcript: previous.transcript)
    }

    // Keep: first (instructions) + last (recent context)
    var condensed = [entries.first!, entries.last!]

    let transcript = Transcript(entries: condensed)
    return LanguageModelSession(transcript: transcript)
}
Time cost: 15-20 minutes to implement condensing

症状
Error: LanguageModelSession.GenerationError.exceededContextWindowSize
诊断
  • 4096 Token限制(输入+输出)
  • 长对话会累积Token
  • 冗长的提示会占用Token配额
修复方案
swift
// ❌ 错误示例 - 未处理错误
let response = try await session.respond(to: prompt)
// 大约10-15轮对话后会崩溃

// ✅ 正确示例 - 压缩对话记录
var session = LanguageModelSession()

do {
    let response = try await session.respond(to: prompt)
} catch LanguageModelSession.GenerationError.exceededContextWindowSize {
    // 压缩对话后继续
    session = condensedSession(from: session)
    let response = try await session.respond(to: prompt)
}

func condensedSession(from previous: LanguageModelSession) -> LanguageModelSession {
    let entries = previous.transcript.entries

    guard entries.count > 2 else {
        return LanguageModelSession(transcript: previous.transcript)
    }

    // 保留:第一条(指令)+最后一条(最近上下文)
    var condensed = [entries.first!, entries.last!]

    let transcript = Transcript(entries: condensed)
    return LanguageModelSession(transcript: transcript)
}
时间成本:15-20分钟实现压缩逻辑

Pattern 2b: Guardrail Violation

模式2b:护栏规则违反

Symptom:
Error: LanguageModelSession.GenerationError.guardrailViolation
Diagnosis:
  • User input triggered content policy
  • Violence, hate speech, illegal activities
  • Model refuses to generate
Fix:
swift
// ✅ GOOD - Graceful handling
do {
    let response = try await session.respond(to: userInput)
    print(response.content)
} catch LanguageModelSession.GenerationError.guardrailViolation {
    // Show user-friendly message
    print("I can't help with that request")
    // Log for review (but don't show user input to avoid storing harmful content)
}
Time cost: 5-10 minutes

症状
Error: LanguageModelSession.GenerationError.guardrailViolation
诊断
  • 用户输入触发了内容政策
  • 包含暴力、仇恨言论、非法活动等内容
  • 模型拒绝生成内容
修复方案
swift
// ✅ 正确示例 - 优雅处理
do {
    let response = try await session.respond(to: userInput)
    print(response.content)
} catch LanguageModelSession.GenerationError.guardrailViolation {
    // 显示用户友好的提示
    print("我无法处理该请求")
    // 记录日志用于审核(但不要存储用户输入以避免保存有害内容)
}
时间成本:5-10分钟

Pattern 2c: Unsupported Language

模式2c:不支持的语言

Symptom:
Error: LanguageModelSession.GenerationError.unsupportedLanguageOrLocale
Diagnosis: User input in language model doesn't support
Fix:
swift
// ❌ BAD - No language check
let response = try await session.respond(to: userInput)
// Crashes if unsupported language

// ✅ GOOD - Check first
let supported = SystemLanguageModel.default.supportedLanguages

guard supported.contains(Locale.current.language) else {
    // Show disclaimer
    print("Language not supported. Currently supports: \(supported)")
    return
}

// Also handle errors
do {
    let response = try await session.respond(to: userInput)
} catch LanguageModelSession.GenerationError.unsupportedLanguageOrLocale {
    print("Please use English or another supported language")
}
Time cost: 10 minutes

症状
Error: LanguageModelSession.GenerationError.unsupportedLanguageOrLocale
诊断: 用户输入的语言模型不支持
修复方案
swift
// ❌ 错误示例 - 未检查语言
let response = try await session.respond(to: userInput)
// 如果语言不支持会崩溃

// ✅ 正确示例 - 先检查语言
let supported = SystemLanguageModel.default.supportedLanguages

guard supported.contains(Locale.current.language) else {
    // 显示免责声明
    print("该语言不受支持。当前支持:\(supported)")
    return
}

// 同时处理错误
do {
    let response = try await session.respond(to: userInput)
} catch LanguageModelSession.GenerationError.unsupportedLanguageOrLocale {
    print("请使用英语或其他支持的语言")
}
时间成本:10分钟

Pattern 2d: General Error Handling

模式2d:通用错误处理

Symptom: Unknown error types
Fix:
swift
// ✅ GOOD - Comprehensive error handling
do {
    let response = try await session.respond(to: prompt)
    print(response.content)
} catch LanguageModelSession.GenerationError.exceededContextWindowSize {
    // Handle context overflow
    session = condensedSession(from: session)
} catch LanguageModelSession.GenerationError.guardrailViolation {
    // Handle content policy
    showMessage("Cannot generate that content")
} catch LanguageModelSession.GenerationError.unsupportedLanguageOrLocale {
    // Handle language issue
    showMessage("Language not supported")
} catch {
    // Catch-all for unexpected errors
    print("Unexpected error: \(error)")
    showMessage("Something went wrong. Please try again.")
}
Time cost: 10-15 minutes

症状: 未知错误类型
修复方案
swift
// ✅ 正确示例 - 全面的错误处理
do {
    let response = try await session.respond(to: prompt)
    print(response.content)
} catch LanguageModelSession.GenerationError.exceededContextWindowSize {
    // 处理上下文溢出
    session = condensedSession(from: session)
} catch LanguageModelSession.GenerationError.guardrailViolation {
    // 处理内容政策问题
    showMessage("无法生成该内容")
} catch LanguageModelSession.GenerationError.unsupportedLanguageOrLocale {
    // 处理语言问题
    showMessage("该语言不受支持")
} catch {
    // 捕获所有意外错误
    print("意外错误:\(error)")
    showMessage("出现问题,请重试。")
}
时间成本:10-15分钟

Pattern 3a: Hallucinated Output (Wrong Use Case)

模式3a:幻觉输出(用例错误)

Symptom:
  • Model gives factually incorrect answers
  • Makes up information
Diagnosis: Using model for world knowledge (wrong use case)
Fix:
swift
// ❌ BAD - Wrong use case
let prompt = "Who is the president of France?"
let response = try await session.respond(to: prompt)
// Will hallucinate or give outdated info

// ✅ GOOD - Use server LLM for world knowledge
// Foundation Models is for:
// - Summarization
// - Extraction
// - Classification
// - Content generation

// OR: Use Tool calling with external data source
struct GetFactTool: Tool {
    let name = "getFact"
    let description = "Fetch factual information from verified source"

    @Generable
    struct Arguments {
        let query: String
    }

    func call(arguments: Arguments) async throws -> ToolOutput {
        // Fetch from Wikipedia API, news API, etc.
        let fact = await fetchFactFromAPI(arguments.query)
        return ToolOutput(fact)
    }
}
Time cost: 20-30 minutes to implement tool OR switch to appropriate AI

症状
  • 模型输出事实错误的答案
  • 编造信息
诊断: 将模型用于通用世界知识场景(错误用例)
修复方案
swift
// ❌ 错误示例 - 错误用例
let prompt = "法国总统是谁?"
let response = try await session.respond(to: prompt)
// 会产生幻觉或输出过时信息

// ✅ 正确示例 - 使用服务器端LLM处理通用世界知识
// Foundation Models适用于:
// - 摘要总结
// - 信息提取
// - 分类
// - 内容生成

// 或者:使用工具调用外部数据源
struct GetFactTool: Tool {
    let name = "getFact"
    let description = "从可信来源获取事实信息"

    @Generable
    struct Arguments {
        let query: String
    }

    func call(arguments: Arguments) async throws -> ToolOutput {
        // 从维基百科API、新闻API等获取数据
        let fact = await fetchFactFromAPI(arguments.query)
        return ToolOutput(fact)
    }
}
时间成本:20-30分钟实现工具调用或切换到合适的AI服务

Pattern 3b: Wrong Structure (Not Using @Generable)

模式3b:结构错误(未使用@Generable)

Symptom:
  • Parsing errors
  • Invalid JSON
  • Wrong keys
Diagnosis: Manual JSON parsing instead of @Generable
Fix:
swift
// ❌ BAD - Manual parsing
let prompt = "Generate person as JSON"
let response = try await session.respond(to: prompt)
let data = response.content.data(using: .utf8)!
let person = try JSONDecoder().decode(Person.self, from: data) // CRASHES

// ✅ GOOD - @Generable
@Generable
struct Person {
    let name: String
    let age: Int
}

let response = try await session.respond(
    to: "Generate a person",
    generating: Person.self
)
// response.content is type-safe Person, guaranteed structure
Time cost: 10 minutes to convert to @Generable

症状
  • 解析错误
  • 无效JSON
  • 错误的键名
诊断: 手动解析JSON而非使用@Generable
修复方案
swift
// ❌ 错误示例 - 手动解析
let prompt = "以JSON格式生成人物信息"
let response = try await session.respond(to: prompt)
let data = response.content.data(using: .utf8)!
let person = try JSONDecoder().decode(Person.self, from: data) // 会崩溃

// ✅ 正确示例 - 使用@Generable
@Generable
struct Person {
    let name: String
    let age: Int
}

let response = try await session.respond(
    to: "生成一个人物信息",
    generating: Person.self
)
// response.content是类型安全的Person对象,结构有保障
时间成本:10分钟转换为@Generable实现

Pattern 3c: Missing Data (Need Tool)

模式3c:数据缺失(需要工具调用)

Symptom:
  • Model doesn't have required information
  • Output is vague or generic
Diagnosis: Need external data (weather, locations, contacts)
Fix:
swift
// ❌ BAD - No external data
let response = try await session.respond(
    to: "What's the weather in Tokyo?"
)
// Will make up weather data

// ✅ GOOD - Tool calling
import WeatherKit

struct GetWeatherTool: Tool {
    let name = "getWeather"
    let description = "Get current weather for a city"

    @Generable
    struct Arguments {
        let city: String
    }

    func call(arguments: Arguments) async throws -> ToolOutput {
        // Fetch real weather
        let weather = await WeatherService.shared.weather(for: arguments.city)
        return ToolOutput("Temperature: \(weather.temperature)°F")
    }
}

let session = LanguageModelSession(tools: [GetWeatherTool()])
let response = try await session.respond(to: "What's the weather in Tokyo?")
// Uses real weather data
Time cost: 20-30 minutes to implement tool

症状
  • 模型不具备所需信息
  • 输出模糊或通用内容
诊断: 需要外部数据(天气、位置、联系人等)
修复方案
swift
// ❌ 错误示例 - 无外部数据
let response = try await session.respond(
    to: "东京的天气如何?"
)
// 会编造天气数据

// ✅ 正确示例 - 工具调用
import WeatherKit

struct GetWeatherTool: Tool {
    let name = "getWeather"
    let description = "获取城市当前天气"

    @Generable
    struct Arguments {
        let city: String
    }

    func call(arguments: Arguments) async throws -> ToolOutput {
        // 获取真实天气数据
        let weather = await WeatherService.shared.weather(for: arguments.city)
        return ToolOutput("温度:\(weather.temperature)°F")
    }
}

let session = LanguageModelSession(tools: [GetWeatherTool()])
let response = try await session.respond(to: "东京的天气如何?")
// 使用真实天气数据
时间成本:20-30分钟实现工具调用

Pattern 3d: Inconsistent Output (Sampling)

模式3d:输出不一致(采样问题)

Symptom:
  • Different output every time for same prompt
  • Need consistent results for testing
Diagnosis: Random sampling (default behavior)
Fix:
swift
// Default: Random sampling
let response1 = try await session.respond(to: "Write a haiku")
let response2 = try await session.respond(to: "Write a haiku")
// Different every time

// ✅ For deterministic output (testing/demos)
let response = try await session.respond(
    to: "Write a haiku",
    options: GenerationOptions(sampling: .greedy)
)
// Same output for same prompt (given same model version)

// ✅ For low variance
let response = try await session.respond(
    to: "Classify this article",
    options: GenerationOptions(temperature: 0.5)
)
// Slightly varied but focused

// ✅ For high creativity
let response = try await session.respond(
    to: "Write a creative story",
    options: GenerationOptions(temperature: 2.0)
)
// Very diverse output
Time cost: 2-5 minutes

症状
  • 相同提示每次输出不同内容
  • 测试时需要一致结果
诊断: 使用了随机采样(默认行为)
修复方案
swift
// 默认:随机采样
let response1 = try await session.respond(to: "写一首俳句")
let response2 = try await session.respond(to: "写一首俳句")
// 每次结果不同

// ✅ 用于确定性输出(测试/演示)
let response = try await session.respond(
    to: "写一首俳句",
    options: GenerationOptions(sampling: .greedy)
)
// 相同提示输出相同内容(基于相同模型版本)

// ✅ 用于低方差输出
let response = try await session.respond(
    to: "对这篇文章进行分类",
    options: GenerationOptions(temperature: 0.5)
)
// 略有变化但聚焦主题

// ✅ 用于高创意输出
let response = try await session.respond(
    to: "写一个创意故事",
    options: GenerationOptions(temperature: 2.0)
)
// 输出多样性极高
时间成本:2-5分钟

Pattern 4a: Initial Latency (Prewarm)

模式4a:初始延迟(预加载)

Symptom:
  • First generation takes 1-2 seconds to start
  • Subsequent requests faster
Diagnosis: Model loading time
Fix:
swift
// ❌ BAD - Load on user interaction
Button("Generate") {
    Task {
        let session = LanguageModelSession() // 1-2s delay here
        let response = try await session.respond(to: prompt)
    }
}

// ✅ GOOD - Prewarm on init
class ViewModel: ObservableObject {
    private var session: LanguageModelSession?

    init() {
        // Prewarm before user interaction
        Task {
            self.session = LanguageModelSession(instructions: "...")
        }
    }

    func generate(prompt: String) async throws -> String {
        guard let session = session else {
            // Fallback if not ready
            self.session = LanguageModelSession()
            return try await self.session!.respond(to: prompt).content
        }
        return try await session.respond(to: prompt).content
    }
}
Time cost: 10 minutes Latency saved: 1-2 seconds on first request

症状
  • 首次生成需要1-2秒启动
  • 后续请求速度更快
诊断: 模型加载时间
修复方案
swift
// ❌ 错误示例 - 用户交互时才加载
Button("生成") {
    Task {
        let session = LanguageModelSession() // 此处有1-2秒延迟
        let response = try await session.respond(to: prompt)
    }
}

// ✅ 正确示例 - 初始化时预加载
class ViewModel: ObservableObject {
    private var session: LanguageModelSession?

    init() {
        // 在用户交互前预加载
        Task {
            self.session = LanguageModelSession(instructions: "...")
        }
    }

    func generate(prompt: String) async throws -> String {
        guard let session = session else {
            // 如果未准备好则回退
            self.session = LanguageModelSession()
            return try await self.session!.respond(to: prompt).content
        }
        return try await session.respond(to: prompt).content
    }
}
时间成本:10分钟 节省延迟:首次请求减少1-2秒

Pattern 4b: Long Generation (Streaming)

模式4b:生成耗时过长(流式输出)

Symptom:
  • User waits 3-5 seconds seeing nothing
  • Then entire result appears at once
Diagnosis: Not streaming long generations
Fix:
swift
// ❌ BAD - No streaming
let response = try await session.respond(
    to: "Generate 5-day itinerary",
    generating: Itinerary.self
)
// User waits 4 seconds seeing nothing

// ✅ GOOD - Streaming
@Generable
struct Itinerary {
    var destination: String
    var days: [DayPlan]
}

let stream = session.streamResponse(
    to: "Generate 5-day itinerary to Tokyo",
    generating: Itinerary.self
)

for try await partial in stream {
    // Update UI incrementally
    self.itinerary = partial
}
// User sees destination in 0.5s, then days progressively
Time cost: 15-20 minutes Perceived latency: 0.5s vs 4s

症状
  • 用户等待3-5秒看不到任何内容
  • 然后一次性显示完整结果
诊断: 长内容生成未使用流式输出
修复方案
swift
// ❌ 错误示例 - 未使用流式输出
let response = try await session.respond(
    to: "生成5天行程",
    generating: Itinerary.self
)
// 用户等待4秒看不到任何内容

// ✅ 正确示例 - 流式输出
@Generable
struct Itinerary {
    var destination: String
    var days: [DayPlan]
}

let stream = session.streamResponse(
    to: "生成东京5天行程",
    generating: Itinerary.self
)

for try await partial in stream {
    // 逐步更新UI
    self.itinerary = partial
}
// 用户在0.5秒内看到目的地,然后逐步看到每日行程
时间成本:15-20分钟 感知延迟:从4秒降至0.5秒

Pattern 4c: Large Schema Overhead

模式4c:大Schema开销

Symptom:
  • Subsequent requests with same @Generable type slow
Diagnosis: Schema re-inserted into prompt every time
Fix:
swift
// First request - schema inserted automatically
let first = try await session.respond(
    to: "Generate first person",
    generating: Person.self
)

// ✅ Subsequent requests - skip schema insertion
let second = try await session.respond(
    to: "Generate another person",
    generating: Person.self,
    options: GenerationOptions(includeSchemaInPrompt: false)
)
Time cost: 2 minutes Latency saved: 10-20% per request

症状
  • 使用相同@Generable类型的后续请求变慢
诊断: Schema每次请求都会重新插入到提示中
修复方案
swift
// 首次请求 - 自动插入Schema
let first = try await session.respond(
    to: "生成第一个人物信息",
    generating: Person.self
)

// ✅ 后续请求 - 跳过Schema插入
let second = try await session.respond(
    to: "生成另一个人物信息",
    generating: Person.self,
    options: GenerationOptions(includeSchemaInPrompt: false)
)
时间成本:2分钟 节省延迟:每次请求减少10-20%

Pattern 4d: Complex Prompt (Break Down)

模式4d:提示过于复杂(拆分任务)

Symptom:
  • Generation takes >5 seconds
  • Poor quality results
Diagnosis: Prompt too complex for single generation
Fix:
swift
// ❌ BAD - One massive prompt
let prompt = """
    Generate complete 7-day itinerary with hotels, restaurants,
    activities, transportation, budget, tips, and local customs
    """
// 5-8 seconds, poor quality

// ✅ GOOD - Break into steps
let overview = try await session.respond(
    to: "Generate high-level 7-day plan for Tokyo"
)

var dayDetails: [DayPlan] = []
for day in 1...7 {
    let detail = try await session.respond(
        to: "Detail activities and restaurants for day \(day) in Tokyo",
        generating: DayPlan.self
    )
    dayDetails.append(detail.content)
}
// Total time similar, but better quality and progressive results
Time cost: 20-30 minutes Quality improvement: Significantly better

症状
  • 生成耗时超过5秒
  • 输出质量差
诊断: 单次生成的提示过于复杂
修复方案
swift
// ❌ 错误示例 - 单个超大提示
let prompt = """
    生成完整的7天行程,包含酒店、餐厅、
    活动、交通、预算、提示和当地习俗
    """
// 耗时5-8秒,质量差

// ✅ 正确示例 - 拆分为多个步骤
let overview = try await session.respond(
    to: "生成东京7天行程的大纲"
)

var dayDetails: [DayPlan] = []
for day in 1...7 {
    let detail = try await session.respond(
        to: "详细规划东京第\(day)天的活动和餐厅",
        generating: DayPlan.self
    )
    dayDetails.append(detail.content)
}
// 总时间相近,但质量更好且结果逐步呈现
时间成本:20-30分钟 质量提升:显著改善

Pattern 5a: UI Frozen (Main Thread Blocking)

模式5a:UI冻结(主线程阻塞)

Symptom:
  • App unresponsive during generation
  • UI freezes for seconds
Diagnosis: Calling
respond()
on main thread synchronously
Fix:
swift
// ❌ BAD - Blocking main thread
Button("Generate") {
    let response = try await session.respond(to: prompt)
    // UI frozen for 2-5 seconds!
}

// ✅ GOOD - Async task
Button("Generate") {
    Task {
        do {
            let response = try await session.respond(to: prompt)
            // Update UI on main thread
            await MainActor.run {
                self.result = response.content
            }
        } catch {
            print("Error: \(error)")
        }
    }
}
Time cost: 5 minutes UX improvement: Massive (no frozen UI)

症状
  • 生成过程中应用无响应
  • UI冻结数秒
诊断: 在主线程同步调用
respond()
修复方案
swift
// ❌ 错误示例 - 阻塞主线程
Button("生成") {
    let response = try await session.respond(to: prompt)
    // UI冻结2-5秒!
}

// ✅ 正确示例 - 异步任务
Button("生成") {
    Task {
        do {
            let response = try await session.respond(to: prompt)
            // 在主线程更新UI
            await MainActor.run {
                self.result = response.content
            }
        } catch {
            print("错误:\(error)")
        }
    }
}
时间成本:5分钟 用户体验提升:大幅改善(无UI冻结)

Production Crisis Scenario

生产危机场景

Context

背景

Situation: You just launched an AI-powered feature using Foundation Models. Within 2 hours:
  • 20% of users report "AI feature doesn't work"
  • App Store reviews dropping: "New AI broken"
  • VP of Product emailing: "What's the ETA on fix?"
  • Engineering manager: "Should we roll back?"
Pressure Signals:
  • 🚨 Revenue impact: Feature is key selling point for new app version
  • Time pressure: "Fix it NOW"
  • 👔 Executive visibility: VP watching
  • 📉 Public reputation: App Store reviews visible to all
情况:你刚刚发布了一个使用Foundation Models的AI功能。2小时内:
  • 20%的用户反馈“AI功能无法使用”
  • App Store评分下降:“新AI功能坏了”
  • 产品副总裁发邮件:“修复ETA是多少?”
  • 工程经理:“我们应该回滚吗?”
压力信号
  • 🚨 营收影响:该功能是新版本的核心卖点
  • 时间压力:“立刻修复”
  • 👔 管理层关注:副总裁在跟进
  • 📉 公众声誉:App Store评论对所有人可见

Rationalization Traps

常见错误思路

DO NOT fall into these traps:
  1. "Disable the feature"
    • Loses product differentiation
    • Admits defeat
    • Doesn't learn what went wrong
  2. "Roll back to previous version"
    • Loses weeks of work
    • Doesn't fix root cause
    • Users still angry
  3. "It works for me"
    • Simulator ≠ real devices
    • Your device ≠ all devices
    • Ignores real problem
  4. "Switch to ChatGPT API"
    • Violates privacy
    • Expensive at scale
    • Doesn't address availability issue
切勿陷入以下误区:
  1. “禁用该功能”
    • 失去产品差异化优势
    • 承认失败
    • 无法了解问题根源
  2. “回滚到上一版本”
    • 浪费数周工作成果
    • 未解决根本问题
    • 用户仍然不满
  3. “在我这里是好的”
    • 模拟器 ≠ 真机
    • 你的设备 ≠ 所有用户的设备
    • 忽视真实问题
  4. “切换到ChatGPT API”
    • 违反隐私政策
    • 大规模使用成本高昂
    • 未解决可用性问题

MANDATORY Protocol

强制应对流程

Phase 1: Identify (5 minutes)

阶段1:定位问题(5分钟)

swift
// Check error distribution
// What percentage seeing what error?

// Run this on test devices:
let availability = SystemLanguageModel.default.availability

switch availability {
case .available:
    print("✅ Available")
case .unavailable(let reason):
    print("❌ Unavailable: \(reason)")
}

// Hypothesis:
// - If 20% unavailable → Availability issue (device/region/opt-in)
// - If 20% getting errors → Code bug
// - If 20% seeing wrong results → Use case mismatch
Results: Discover that 20% of users have devices without Apple Intelligence support.

swift
// 检查错误分布
// 各错误类型的占比是多少?

// 在测试设备上运行:
let availability = SystemLanguageModel.default.availability

switch availability {
case .available:
    print("✅ 可用")
case .unavailable(let reason):
    print("❌ 不可用:\(reason)")
}

// 假设:
// - 如果20%用户显示不可用 → 可用性问题(设备/地区/未启用)
// - 如果20%用户遇到错误 → 代码bug
// - 如果20%用户看到错误结果 → 用例不匹配
结果:发现20%的用户设备不支持Apple Intelligence。

Phase 2: Confirm (5 minutes)

阶段2:确认问题(5分钟)

swift
// Check which devices affected
// iPhone 15 Pro+ = ✅ Available
// iPhone 15 = ❌ Unavailable
// iPhone 14 = ❌ Unavailable

// Conclusion: Availability issue, not code bug
Root cause: Feature assumes all users have Apple Intelligence. 20% don't.

swift
// 检查受影响的设备
// iPhone 15 Pro+ = ✅ 可用
// iPhone 15 = ❌ 不可用
// iPhone 14 = ❌ 不可用

// 结论:可用性问题,非代码bug
根本原因:功能假设所有用户都有Apple Intelligence支持,但20%的用户没有。

Phase 3: Device Requirements (5 minutes)

阶段3:设备要求(5分钟)

Verify:
  • Apple Intelligence requires iPhone 15 Pro or later
  • Or iPad with M1+ chip
  • Or Mac with Apple silicon
验证:
  • Apple Intelligence需要iPhone 15 Pro或后续机型
  • 或搭载M1+芯片的iPad
  • 或搭载Apple硅芯片的Mac

20% of user base = older devices

20%的用户群体使用旧设备



Phase 4: Implement Fix (15 minutes)

阶段4:实施修复(15分钟)

swift
// ✅ Add availability check + graceful UI
struct AIFeatureView: View {
    @State private var availability = SystemLanguageModel.default.availability

    var body: some View {
        switch availability {
        case .available:
            // Show AI feature
            AIContentView()

        case .unavailable:
            // Graceful fallback
            VStack {
                Image(systemName: "sparkles")
                    .font(.largeTitle)
                    .foregroundColor(.secondary)

                Text("AI-Powered Features")
                    .font(.headline)

                Text("Available on iPhone 15 Pro and later")
                    .font(.subheadline)
                    .foregroundColor(.secondary)
                    .multilineTextAlignment(.center)

                // Offer alternative
                Button("Use Standard Mode") {
                    // Show non-AI fallback
                }
            }
        }
    }
}

swift
// ✅ 添加可用性检查和优雅的UI
struct AIFeatureView: View {
    @State private var availability = SystemLanguageModel.default.availability

    var body: some View {
        switch availability {
        case .available:
            // 显示AI功能
            AIContentView()

        case .unavailable:
            // 优雅的回退方案
            VStack {
                Image(systemName: "sparkles")
                    .font(.largeTitle)
                    .foregroundColor(.secondary)

                Text("AI驱动功能")
                    .font(.headline)

                Text("适用于iPhone 15 Pro及后续机型")
                    .font(.subheadline)
                    .foregroundColor(.secondary)
                    .multilineTextAlignment(.center)

                // 提供替代方案
                Button("使用标准模式") {
                    // 显示非AI版本
                }
            }
        }
    }
}

Phase 5: Deploy (20 minutes)

阶段5:部署(20分钟)

  1. Test on multiple devices (15 min)
    • iPhone 15 Pro: ✅ Shows AI feature
    • iPhone 14: ✅ Shows graceful message
    • iPad Pro M1: ✅ Shows AI feature
  2. Submit hotfix build (5 min)

  1. 在多台设备上测试(15分钟)
    • iPhone 15 Pro: ✅ 显示AI功能
    • iPhone 14: ✅ 显示清晰提示
    • iPad Pro M1: ✅ 显示AI功能
  2. 提交热修复版本(5分钟)

Communication Template

沟通模板

To VP of Product (immediate):
Root cause identified:

The AI feature requires Apple Intelligence (iPhone 15 Pro+).
20% of our users have older devices. We didn't check availability.

Fix: Added availability check with graceful fallback UI.

Timeline:
- Hotfix ready: Now
- TestFlight: 10 minutes
- App Store submission: 30 minutes
- Review: 24-48 hours (requesting expedited)

Impact mitigation:
- 80% of users see working AI feature
- 20% see clear message + standard mode fallback
- No functionality lost, just graceful degradation
To Engineering Team:
Post-mortem items:
1. Add availability check to launch checklist
2. Test on non-Apple-Intelligence devices
3. Document device requirements clearly
4. Add analytics for availability status
给产品副总裁(即时)
已定位根本原因:

AI功能需要Apple Intelligence(iPhone 15 Pro及后续机型)。
20%的用户使用旧设备,我们未添加可用性检查。

修复方案:添加可用性检查和优雅的回退UI。

时间线:
- 热修复已完成:现在
- TestFlight测试:10分钟
- App Store提交:30分钟
- 审核:24-48小时(已申请加急)

影响缓解:
- 80%的用户可正常使用AI功能
- 20%的用户看到清晰提示+标准模式回退
- 无功能损失,仅优雅降级
给工程团队
事后总结项:
1. 将可用性检查添加到发布检查清单
2. 在非Apple Intelligence设备上测试
3. 清晰记录设备要求
4. 添加可用性状态的分析统计

Time Saved

节省的时间

  • Panic path (disable/rollback): 2 hours of meetings + lost work
  • Proper diagnosis: 45 minutes root cause → fix → deploy
  • 恐慌路径(禁用/回滚):2小时会议+工作成果损失
  • 正确诊断:45分钟从根源定位→修复→部署

What We Learned

经验教训

  1. Always check availability before creating session
  2. Test on real devices across device generations
  3. Graceful degradation better than feature removal
  4. Clear messaging to users about requirements

  1. 创建会话前务必检查可用性
  2. 在全系列真机上测试
  3. 优雅降级比移除功能更好
  4. 向用户清晰说明需求

Quick Reference Table

快速参考表

SymptomCauseCheckPatternTime
Won't start.unavailableSystemLanguageModel.default.availability1a5 min
Region issueNot supported regionCheck supported regions1b5 min
Not opted inApple Intelligence disabledSettings check1c10 min
Context exceeded>4096 tokensTranscript length2a15 min
Guardrail errorContent policyUser input type2b10 min
Language errorUnsupported languagesupportedLanguages2c10 min
Hallucinated outputWrong use caseTask type check3a20 min
Wrong structureNo @GenerableManual parsing?3b10 min
Missing dataNo toolExternal data needed?3c30 min
InconsistentRandom samplingNeed deterministic?3d5 min
Initial delayModel loadingFirst request slow?4a10 min
Long waitNo streaming>1s generation?4b20 min
Schema overheadRe-inserting schemaSubsequent requests?4c2 min
Complex promptToo much at once>5s generation?4d30 min
UI frozenMain threadThread check5a5 min

症状原因检查项模式时间成本
无法启动.unavailableSystemLanguageModel.default.availability1a5分钟
地区问题地区不支持检查支持地区1b5分钟
未启用Apple Intelligence已禁用设置检查1c10分钟
上下文超出超过4096 tokens对话记录长度2a15分钟
护栏规则错误触发内容政策用户输入类型2b10分钟
语言错误语言不受支持supportedLanguages2c10分钟
幻觉输出用例错误任务类型检查3a20分钟
结构错误未使用@Generable是否手动解析?3b10分钟
数据缺失需要外部数据是否需要外部信息?3c30分钟
输出不一致随机采样是否需要确定性结果?3d5分钟
初始延迟模型加载首次请求是否缓慢?4a10分钟
等待时间长未使用流式输出生成耗时是否超过1秒?4b20分钟
Schema开销重复插入Schema是否为后续请求?4c2分钟
提示复杂单次任务负载过高生成耗时是否超过5秒?4d30分钟
UI冻结主线程阻塞线程检查5a5分钟

Cross-References

交叉引用

Related Axiom Skills:
  • axiom-foundation-models
    — Discipline skill for anti-patterns, proper usage patterns, pressure scenarios
  • axiom-foundation-models-ref
    — Complete API reference with all WWDC 2025 code examples
Apple Resources:
  • Foundation Models Framework Documentation
  • WWDC 2025-286: Meet the Foundation Models framework
  • WWDC 2025-301: Deep dive into the Foundation Models framework
  • Instruments Foundation Models Template

Last Updated: 2025-12-03 Version: 1.0.0 Skill Type: Diagnostic
相关Axiom技能
  • axiom-foundation-models
    — 包含反模式、正确使用模式、压力场景的技能指南
  • axiom-foundation-models-ref
    — 完整API参考,包含所有WWDC 2025代码示例
Apple官方资源
  • Foundation Models框架文档
  • WWDC 2025-286:Foundation Models框架介绍
  • WWDC 2025-301:Foundation Models框架深度解析
  • Instruments的Foundation Models模板

最后更新:2025-12-03 版本:1.0.0 技能类型:诊断