-
Foundation Models 框架的新功能
探索 Foundation Models 框架的新功能。了解如何访问专用云计算、整合第三方模型及开源模型,并构建优化视觉功能。探索上下文管理 API、内置的语义搜索,以及用于为你的 App 创建智能体体验的强大原语。
章节
- 0:00 - Introduction
- 2:34 - New on-device model
- 3:21 - Vision: image understanding
- 4:20 - Private Cloud Compute
- 6:46 - Model abstraction layer
- 7:32 - Partner model integrations
- 9:40 - System tools: Vision and Spotlight
- 10:57 - Dynamic Profiles for agentic apps
- 13:46 - Composing models and configurations
- 15:30 - Evaluations framework
- 16:02 - The fm command line tool
- 17:13 - Foundation Models Python SDK
- 17:55 - Open source and framework utilities
- 19:24 - Next steps
资源
-
搜索此视频…
大家好 欢迎来到本场 我是Erik 我是Zhen 去年 我们推出了 Foundation Models 框架 提供了引导式生成 快照流式传输等功能 以及强大的工具协议 你们的热情让我们深感震撼 对第一年 Foundation Models 框架的热情 我们相信你会更喜爱 今年为你准备的内容 我们将介绍今年框架 的所有新内容 告诉你 这次版本内容满满 我们的2027版本 专注于系统内外的集成 更多种类的模型 以及构建智能体体验 的新原语 让我们从最令人兴奋 的更新之一开始 Foundation Models 框架 包括我们今天发布的 许多全新API 即将开源 而且风格十足 除核心框架外 我们还发布了一个新包 Foundation Models 框架工具包 将在系统版本之间持续更新 让你能够使用新兴的 和实验性的构建模块 在本节中 你还将了解到 更多包加入了 Foundation Models 框架生态系统 准备好和我们一起探索了吗 我将介绍所有 关于新模型的内容 新模态以及框架中 新增的工具 我还将向你展示 我们构建的全新API 帮助你充分发挥它们的价值 我们的日程十分丰富 首先 我们为你准备了 大量模型更新 包括设备端模型更新 以及对服务器模型的访问 我们还添加了新系统工具 极大增强了你的会话能力 借助Spotlight 和Vision 框架 之后 Zhen会重新加入我们 为你介绍一个强大的 新API——dynamic profiles 这是创建智能体体验 的新原语 Zhen还将深入介绍 全新的Evaluations 框架 及其与Foundation Models 的紧密集成
最后 我们有一些关于 Mac专属生产力工具的好消息 请务必继续收看 让我们直接了解新模型
本次版本带来了 全新的设备端模型 从头开始重建 全面提升 它更智能 逻辑和工具调用能力更强 在iOS 26.4中 我们发布了 用于检查模型上下文大小的新API 以及计算指令、提示词 和记录中Token数量的功能 你将需要在今后使用这些功能 让你的App适配 运行所在的硬件 我们也一直在努力 优化护栏机制 你可能已经注意到 iOS 26.4中的调整 以减少误报数量 我们将继续在iOS 27 中进行更多改进 此外 设备端模型 还将获得Vision能力
这将开启全新的 应用类别
API简洁 是现有提示构建器的自然延伸
这里我们创建了一个会话 我们想询问右边 折纸照片的相关问题 只需在提示词中 插入图像附件和文本
现在 模型可以回答 关于图像的问题了
图像附件可以从 多种类型创建 包括 UIImage NSImage
CGImage Core Image类型 CoreVideo Pixel Buffers 以及文件URL 模型支持任意 尺寸和宽高比的图像 无需裁剪或填充 为特定形状
允许任意图像尺寸 但请注意 较大的图像会消耗 更多Token并增加延迟 得益于所有这些升级 设备端系统语言模型 比以往任何时候都更强大 但如果你需要更强的算力 我们提供了全新的 PrivateCloudComputeLanguageModel 以运行Apple最强大的服务器模型 Private Cloud Compute模型 正是同一个 驱动着你所熟知和喜爱的 许多Apple Intelligence功能 它比设备端模型大得多 拥有32,000个Token的上下文窗口 并带有一项强大的 新能力——推理 推理模型经过训练 会花时间仔细思考 在给出响应之前 先深思熟虑 从而获得 显著更好的结果 使用Private Cloud Compute 再简单不过了 只需创建模型实例 然后用它初始化 你的语言模型会话 在向会话发送提示时 现在可以在新的 contextOptions参数中指定推理级别 ReasoningLevel控制模型 在响应前的思考量 深度推理可获得更好的响应 但需要额外的计算资源 Private Cloud Compute 最大的优点之一 是你无需担心 账户设置 也不必处理 身份验证 更不需要存储API密钥 一切完全无缝 当然 Private Cloud Compute 首要特点是隐私保护 提示词从不被存储 我们允许独立研究人员 验证这些声明 更重要的是 Private Cloud Compute使我们能够 将Foundation Models 框架 引入watchOS 从watchOS 27开始 你可以在手腕上 使用最强大的智能功能
PCC无需云API费用 适用于首次下载量 不足200万的开发者 你的用户每天 都可以使用PCC 如果他们订阅了iCloud+ 额度将更高 要了解 PrivateCloudComputeLanguageModel的详情
包括使用所需的权限 请务必收看我们关于使用 Private Cloud Compute构建应用的视频 除了全面升级的 设备端模型 以及新的Private Cloud Compute模型 我们还开放了 模型抽象层 使几乎任何语言模型 都能够 与Foundation Models 框架 配合使用 抽象层基于 新的LanguageModel协议构建 允许本地和服务器模型 为LanguageModelSession提供支持 现有模型如SystemLanguageModel 和PrivateCloudComputeLanguageModel 已符合此协议 我们还将开源 另外两个实现 CoreAILanguageModel和MLXLanguageModel
用于在Mac的GPU和 Apple神经网络引擎上运行众多本地模型 我们也很高兴与你分享 我们一直在幕后努力工作 确保你能访问 多种前沿服务器模型 Anthropic和Google 都在发布Swift包 为你提供访问 其最新最强模型的途径 模型抽象层使使用 第三方模型变得简单 只需使用Swift Package Manager 导入语言模型包 初始化我想使用的模型
在创建会话时传入即可
后续所有操作保持不变
请注意 如果你使用 第三方服务器模型 可能需要处理 身份验证和计费问题 切记 绝不要在 App二进制文件中存储私钥 始终通过OAuth等 安全机制获取访问Token 并使用KeyChain安全存储 作为开发者 使用第三方模型时 通常按Token计费 因此我们让追踪用量 变得更加简便 会话和响应现在 都有usage属性 可以精确告诉你 使用了多少Token 你还可以查看有多少 输入Token是从缓存中读取的 以及有多少响应Token 用于推理
如需了解更多 关于使用LanguageModels的内容 或如何编写自己的 LanguageModel包 请查看"Bring an LLM provider to the Foundation Models framework" 我们终于介绍完 所有模型更新了 接下来是系统工具 在本次版本中 我们 引入了多个内置工具 极大增强了 LanguageModelSession 的系统功能 Foundation Models现在 包含两个原生工具
由Vision 框架的 强大能力支持 BarcodeReaderTool允许模型 读取条形码中的信息 OCRTool允许模型 从图像中提取结构化文本 两者都增强了模型 对视觉信息的推理能力 而这是它原生无法做到的 "What's new in image understanding"视频中 有更多关于如何利用 这些工具的详细信息 同样 我们还引入了 由Spotlight驱动的搜索工具 用于实现完全本地的 检索增强生成 这是你们呼声最高 的功能之一 检索增强生成 即RAG 是一种让模型访问 最新个人或领域知识的技术 通过利用Spotlight索引 和经过特殊处理的查询实现 如果这正是你一直期待的功能 "LLM search using Core Spotlight" 应该是你的必看内容 现在我们已经了解了 本次版本的所有新模型 以及新增到SDK的系统工具 我将交棒给Zhen 为你介绍我们用于构建 智能体App体验的新API 期待吧 交给你了 Zhen 谢谢 Erik
我将向你介绍 dynamic profiles 这是构建智能体体验 的新原语
让我们先来了解一下 crafts App 看看dynamic profiles 能实现哪些体验 在App中 我可以创建 带有折纸照片的日记条目 App创建了一个会话 从手工分析模式开始 指令告诉模型分析图像 并记录发现的内容 它识别手工类型、颜色 和材料 然后通过工具调用 将其保存回日记 接下来 App切换到 头脑风暴模式 使用Private Cloud Compute 的推理能力 它整合刚刚学到的一切 并建议一系列 富有创意的折纸项目 很酷对吧 要实现这个功能 我会先创建LanguageModelSession 然后添加更多会话 每个会话 有自己的模型、指令和工具
但如果我想让模型 自主切换模式呢
事情开始变得复杂了
管理上下文和编排 这样的智能体系统 会涉及大量样板代码 这就是为什么Foundation Models 引入了新的声明式API Dynamic Profiles 让你专注于 上下文中真正重要的内容 而不必担心命令式控制 一切在单个 语言模型会话中完成 要创建简单的dynamic profile 我可以声明一个结构体 并使其遵循 DynamicProfile协议 通过包含Profile的 body属性实现
语言模型会话现在 可以使用DynamicProfile初始化
我可以指定指令和工具 在那一时刻应当 存在于上下文中的内容 这是DynamicProfile 最简单的形式 由指令和工具 组成的数据结构 我想实现两种不同的模式 一种用于手工分析 一种用于头脑风暴 我的App有一个可观察对象 存储了模式变量 可以根据它进行切换
在不同分支中 LanguageModelSession应该 有不同的指令和工具
我甚至可以给模型一个工具 以智能切换到 头脑风暴模式的上下文
有时仅管理上下文 还不够 对于不同任务 你可能还需要 不同的模型和配置 同时保持 对话历史记录
在我的crafts App中 有两种场景:手工分析和头脑风暴 每种场景都已经有 不同的指令和工具集
对于分析手工这类快速任务 SystemLanguageModel可能就足够了 现在 如果我想切换到 头脑风暴 我还可以指定Private Cloud Compute 并配置为深度推理
要描述这些配置 我可以使用修饰符
用model修饰符指定PCC 用reasoningLevel修饰符 要求模型进行深入思考 现在我们有了LanguageModelSession 具有动态配置的模型 工具和指令 当App需要用不同模型能力 处理不同上下文时 dynamic profiles非常适合 理解DynamicProfile的 关键在于 它在任意时刻 解析为单个活跃的Profile 你使用条件判断来 选择哪个Profile处于活跃状态 框架会为你 处理切换过程 现在让我们在crafts App中试试 当我选择创意时 模型 切换到Private Cloud Compute
它仍然拥有分析的完整上下文 但生成富有创意的 项目创意得益于 更大模型的能力 例如更好的工具调用 和更广泛的世界知识 Profiles让管理上下文 变得更加容易 并能动态配置会话 使用此API时 请考虑 隐私边界、模型能力和成本 要深入了解 请查看深度讲解 "Build agentic app experiences with Foundation Models framework"
尽管这些能力很强大 语言模型本质上 是非确定性的 这使得其行为 难以预测
Evaluations 框架是 一个全新的Swift框架 用于衡量你的 智能功能质量 有了Evaluations 框架 你可以在调整提示词时 量化准确性 Evaluations专为像你这样的 App开发者而建 帮助你了解 变更的统计影响 并让你充满信心地 发布App 要了解更多关于Evaluations的内容 请查看这些视频
现在 我想换个话题 谈谈我们的工具和开源工作 在macOS 27中 模型将来到命令行 fm CLI是使用 Apple Foundation Models的全新方式 用于日常生产力 你可以从终端访问 设备端模型和PCC 只需使用fm命令
fm有实用的帮助功能 列出了所有支持的特性
我一直在使用fm chat 为我的App功能测试模型 让我来演示一下 我想知道"valley fold 在折纸中是什么意思?"
轻而易举 就是这么简单 我甚至可以将fm嵌入 Shell脚本来汇总文档 提取信息或生成内容 例如 我有一些 名称随机的图片
比如这张IMG_1234 让我请fm根据图像内容 生成一个文件名
看看这个 它生成了一个 简洁描述性的名称
如果你是数据科学家 或研究人员 在Python生态系统中工作 FoundationModels SDK for Python 同样能满足你的需求
Python SDK让你直接访问 完全相同的设备端模型 该模型驱动着 Swift Foundation Models 框架 你可以检查模型可用性 或用几行Python代码 生成响应 SDK具有Swift框架的 核心功能 让你在几秒内 从提示词得到结构化响应 要了解更多 请查看视频 "Build AI-powered scripts with the fm CLI and Python SDK" 现在我们已经了解了 Mac上的生产力功能 让我们来谈谈开源
从Foundation Models 框架工具包开始
工具包包含 一系列构建模块 帮助你探索 与LLM协作的新兴实践
它提供了用于记录管理的 profile修饰符 用于过程性知识加载 的skill API 以及可与服务器交互的 语言模型 使用Chat Completions标准 这些只是起点 工具和趋势在不断演进 Foundation Models 框架工具包 将与你共同成长
除了工具包 FoundationModels框架的核心 也将开源 开源Foundation Models框架 使其成为与LLM交互的 绝佳方案 适用于所有运行Swift的地方 包括Linux服务器 结合其他模型提供商 如Anthropic和Google 以及CoreAI和MLX集成 你将能在任何地方 运行任何模型 欢迎回来 Erik 准备好收尾了吗 当然 干得好 Zhen
希望你和我们一样 对所有这些新能力感到兴奋 模型和API 我们只是刚刚触及了皮毛 要获取完整内容 请务必查看其他视频 深入了解我们在这里 介绍的所有主题 从Evaluations 框架 到Private Cloud Compute 增强的Xcode工具 以及dynamic profiles的详细内容 接下来的好步骤是 探索我们的示例App 以了解更多关于dynamic profiles的内容 并开始熟悉 Evaluations 框架 代表整个团队 感谢你的加入 谢谢
-
-
2:46 - Context size and token counting
// Context size and token counting let model = SystemLanguageModel() print(model.contextSize) // 8192 let count = try await model.tokenCount(for: "What are the Japanese characters for origami?") print(count) -
3:52 - Attachable image types
// Insert c// Attachable image types let response = try await session.respond { "What animal is this?" Attachment(UIImage(...)) }ode snippet. -
8:45 - Inspecting usage
// Inspecting usage let response = try await session.respond( to: "Recommend a craft that doesn't require scissors.", contextOptions: ContextOptions(reasoningLevel: .light) ) print(response.usage.input.totalTokenCount) print(response.usage.input.cachedTokenCount) print(response.usage.output.totalTokenCount) print(response.usage.output.reasoningTokenCount) -
11:55 - Routing between craft analysis and brainstorm
// Routing between craft analysis and brainstorm @Observable final class AppStates { var mode: Mode } let appStates: AppStates var session: LanguageModelSession? func updateSession() { let originalTranscript = session?.transcript.dropFirstInstructions() ?? Transcript() // Create a new session with new instructions and tools switch appStates.mode { case .craftAnalysis: session = LanguageModelSession( tools: [ RecordImageAnalysisTool(), SwitchModeTool(states: appStates) ], instructions: "Analyze the user's craft project...", transcript: originalTranscript ) case .brainstorm: session = LanguageModelSession( tools: [ RecordBrainstormTool(), ], instructions: "Brainstorm some ideas...", transcript: originalTranscript ) } } struct SwitchModeTool: Tool { let description = "Switch to a different mode." let states: AppStates @Generable struct Arguments { let mode: Mode } func call(arguments: Arguments) async throws -> some PromptRepresentable { appStates.mode = arguments.mode return "Successfully switched to \(arguments.mode)." } } // If mode changes, update the session withObservationTracking { appStates.mode } onChange: { updateSession() } -
12:42 - Describing the profile for craft app
// Describing the profile for craft app struct CraftProfile: LanguageModelSession.DynamicProfile { var body: some DynamicProfile { Profile { Instructions { """ You are an expert crafting assistant. \ Record craft project image analyses \ using the recordImageAnalysis tool. """ } RecordImageAnalysisTool() } } } let session = LanguageModelSession( profile: CraftProfile() ) -
14:36 - Describing the profile for craft app
// Describing the profile for craft app struct CraftProfile: LanguageModelSession.DynamicProfile { let states: CraftProjectStates var body: some DynamicProfile { switch states.mode { case .craftAnalysis: Profile { Instructions { /* ... */ } RecordImageAnalysisTool() SwitchModeTool(states: states) } case .brainstorm: Profile { Instructions { /* ... */ } BrainstormRecordTool() } .model(states.privateCloudCompute) .reasoningLevel(.deep) } } } -
18:29 - Foundation Models SDK for Python
# Foundation Models SDK for Python import apple_fm_sdk as fm model = fm.SystemLanguageModel() # Check the model's availability is_available, reason = model.is_available() if is_available: # Create a session session = fm.LanguageModelSession(model=model) # Generate a response response = await session.respond(prompt="Hello!") print(response)
-
-
- 0:00 - Introduction
Erik Hornberger and Zhen Li introduce this year's Foundation Models release, going open source with a new utilities package, and preview the agenda: model updates, system tools, dynamic profiles, evaluations, and tooling.
- 2:34 - New on-device model
A rebuilt on-device model with better reasoning and tool calling, plus new APIs (from iOS 26.4) for inspecting context size and counting tokens, and refined guardrails that reduce false positives.
- 3:21 - Vision: image understanding
The on-device model gains vision. Add image attachments to a prompt to ask about images, accepting UIImage, NSImage, CGImage, Core Image, CoreVideo pixel buffers, and file URLs at any size, though larger images cost more tokens.
- 4:20 - Private Cloud Compute
Access Apple's server models via PrivateCloudComputeLanguageModel, a 32K context window with reasoning levels, with no account setup, auth, or API keys, fully private, and now available on watchOS 27.
- 6:46 - Model abstraction layer
A new LanguageModel protocol lets local and server models back a LanguageModelSession. Existing models conform already, plus open-source CoreAILanguageModel and MLXLanguageModel for running local models on the Neural Engine and GPU.
- 7:32 - Partner model integrations
Anthropic and Google publish Swift packages for their frontier models. Swap models via Swift Package Manager with everything downstream unchanged, handle auth and billing securely with OAuth and Keychain, and track per-token usage including cache and reasoning tokens.
- 9:40 - System tools: Vision and Spotlight
New built-in tools: BarcodeReaderTool and OCRTool (Vision-backed) for reasoning over visual information, and a Spotlight-powered search tool enabling fully local Retrieval-Augmented Generation (RAG).
- 10:57 - Dynamic Profiles for agentic apps
Dynamic Profiles, a declarative primitive for agentic experiences. Using the Crafts app, a single session swaps instructions and tools between modes (craft analysis vs. brainstorm) by conforming a struct to DynamicProfile.
- 13:46 - Composing models and configurations
Use modifiers to vary the model and reasoning level per profile branch, for example SystemLanguageModel for quick analysis and Private Cloud Compute with deep reasoning for brainstorming, while preserving conversation history. A profile resolves to one active profile at a time.
- 15:30 - Evaluations framework
A new Swift framework to measure the quality of intelligence features, quantifying accuracy as you tweak prompts so you can understand the statistical impact of changes and ship with confidence.
- 16:02 - The fm command line tool
In macOS 27, the models come to the terminal. The fm CLI gives on-device and PCC access for everyday productivity: fm chat for interactive use and piping into shell scripts to summarize, extract, or generate content.
- 17:13 - Foundation Models Python SDK
A Python SDK exposes the same on-device model as the Swift framework, checking availability and generating structured responses in a few lines, for data scientists and researchers in the Python ecosystem.
- 17:55 - Open source and framework utilities
The Foundation Models framework utilities package offers building blocks (transcript management, a skill API, chat-completions interfacing), and the core framework is open-sourced to run wherever Swift runs, including Linux servers.
- 19:24 - Next steps
Download the sample app, get familiar with dynamic profiles and the Evaluations framework, and watch the deep-dive sessions on PCC, evaluations, the Xcode instrument, and dynamic profiles.