AnyLanguageModel 1.0:Apple 平台本地模型一年
Hugging Face Blog 发布了这条动态,详情请查看官方发布。

来自 Hugging Face Blog 的官方动态,版本与适用范围以发布方说明为准。
Hugging Face Blog · 查看官方发布中文机器翻译 · 原文附后
正文 · 来源原文
本地推理和托管推理各有优势,并且在构建新一代智能应用程序中都发挥着作用。共享 API 可以更轻松地为每个任务选择正确的模型。
一年后,发布了数十个版本,AnyLanguageModel 1.0 以及 swift-huggingface 1.0 和 swift-xet 1.0 已经发布。
以下是更改的内容以及接下来的内容:
AnyLanguageModel 的核心思想保持不变:将 Foundation Models API 与适合您的应用程序的模型结合使用。首先,更改您的导入语句:
然后,相同的会话代码可与系统模型、通过 llama.cpp、MLX 和 Core ML 的开放权重模型以及下面的托管提供程序配合使用。
在过去的一年里,我们添加了几项主要功能:
工具调用适用于每个提供商。引导生成也适用于每个提供程序,包括嵌套的 @Generabletypes 及其数组。图像支持允许您使用 Foundation Models 27 的语法将图像附加到提示,包括当您在 iOS、macOS 和 VisionOS 27 上使用系统模型时。
在 OS 27 上,AnyLanguageModel 还可以与任何符合 Foundation Models 的 LanguageModel 协议的模型配合使用,包括 Core AI 模型。
除了 AnyLanguageModel 之外,我们还构建了 swift-huggingface 和 swift-xet,以将模型从 Hub 加速下载到 Swift 应用程序。
今年对托管模型的支持也得到了扩展。 AnyLanguageModel 现在支持:
OpenAI 的聊天完成和响应 API 开放响应,适用于任何具有兼容端点的提供商 Anthropic 的消息 API,具有自适应思维和工作选项 Google 的 Gemini API Ollama 私有云计算,在 OS 27 上 Hugging Face Inference Providers 和其他 OpenAI 兼容端点(例如 OpenRouter),通过自定义基本 URL
借助推理提供程序,您可以使用太大而无法在具有相同会话代码的设备上运行的开放权重模型:
托管提供程序具有与本地模型相同的功能:引导生成、流式传输工具调用以及响应中的令牌使用。
推理现在也成为笔录的一部分。当您切换提供程序时,如果新提供程序无法重播推理块,则会自动从请求中省略推理块。
API 密钥来自闭包而不是字符串,因此您的应用程序可以从您自己的服务器获取短期令牌。自述文件解释了何时让人们携带自己的密钥以及何时通过代理路由请求。
AnyLanguageModel 也可以在 Linux 上运行,因此相同的代码可以在服务器上运行。
虽然我们使本地模型更易于使用,但模型本身也变得更加强大,使小型模型成为一个良好的起点。以下是目前 Hub 上下载最多的一些模型:
来自 Google 的 Gemma 4 E2B,在 GGUF 中,在 Q4_0 时约为 3.4 GB,具有量化感知训练。来自 Liquid AI 的 LFM2.5 2.6B,GGUF 格式,Q4_K_M 时约 1.7 GB。阿里巴巴的 Qwen3.8 27B for MLX,4 位时约 16 GB。
查看英文原文
AnyLanguageModel 1.0: One Year of Local Models on Apple Platforms
Hugging Face Blog 发布了这条动态,详情请查看官方发布。
正文 · 来源原文
Local and hosted inference each have their strengths, and both have a role in building this new generation of intelligent apps. A shared API makes it easier to choose the right model for each task.
A year and dozens of releases later, AnyLanguageModel 1.0 is out, along with swift-huggingface 1.0 and swift-xet 1.0.
Here's what changed, and what's next:
The core idea of AnyLanguageModel remains the same: use the Foundation Models API with the model that fits your app. To get started, change your import statement:
The same session code then works with the system model, with open-weight models through llama.cpp, MLX, and Core ML, and with the hosted providers below.
Over the past year, we've added several major features:
Tool calling works with every provider. Guided generation works with every provider, too, including nested @Generabletypes and arrays of them. Image support lets you attach images to prompts using Foundation Models 27's syntax, including when you use the system model on iOS, macOS, and visionOS 27.
On OS 27, AnyLanguageModel also works with any model that conforms to Foundation Models' LanguageModel protocol, including Core AI models.
Alongside AnyLanguageModel, we've built out swift-huggingface and swift-xet to bring accelerated model downloads from the Hub to Swift apps.
