Tool · 2026-10-20

AnyLanguageModel 1.0: One Year of Local Models on Apple Platforms

AnyLanguageModel 1.0: One Year of Local Models on Apple Platforms

Hugging Face Blog2026-10-20About 4 min readWorth tracking

Marked as a signal by the editors; worth tracking.

On-device AIOpen-weight modelsInference & deploymentAgent runtimes & protocols
On this page12 sections

The full write-up and the editors' notes are in Chinese; the summary above is from the original announcement.

Record

The signal

#

Hugging Face 在 10 月 20 日发布了 AnyLanguageModel 1.0,同时配套的 swift-huggingface 与 swift-xet 也到达 1.0。这个库去年以「Foundation Models 框架的替代品」形式出现,目标是让 Swift 开发者用同一套会话代码选择模型和提供方。

核心变化

接入方式仍然是替换 import 语句:把 import FoundationModels 换成 import AnyLanguageModel,原有 session 代码继续有效。模型侧覆盖系统自带模型、经 llama.cpp、MLX、Core ML 运行的开放权重模型,以及托管 API。

过去一年补齐的功能包括:

  • 工具调用在所有提供方上可用;
  • 引导生成(guided generation)同样覆盖全部提供方,支持嵌套的 @Generable 类型及其数组;
  • 图像可以按 Foundation Models 27 的语法附加到提示中,系统模型也支持;
  • 在 OS 27 上,任何遵循 LanguageModel 协议(含 Core AI 模型)的模型都能接入;
  • 新增 Linux 支持,同一份代码可运行在服务器上。

托管提供方

1.0 支持的托管服务包括 OpenAI Chat Completions 与 Responses API、Open Responses、Anthropic Messages API(带 adaptive thinking 与 effort 选项)、Google Gemini API、Ollama、Private Cloud Compute,以及通过自定义 base URL 接入的 HF Inference Providers、OpenRouter 等 OpenAI 兼容端点。

原文给出的示例用 OpenAILanguageModel 把 openai/gpt-oss-120b 指向 https://router.huggingface.co/v1/,说明超出设备能力的开放权重模型也能用同一套会话代码调用。托管提供方与本地模型享有相同特性:引导生成、带流式的工具调用、响应中的 token 用量。推理过程会进入 transcript,切换提供方时若对方无法回放则自动从请求中省略。API key 改为通过闭包获取,便于从自有服务器取短期 token。

模型示例与依赖

原文列出的热门模型包括: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 的 MLX 版本(4 位下约 16 GB)。前两个可在 iPhone 上运行,Qwen3.8 27B 需要 32 GB 内存以上的 Mac。Z.ai 的 GLM-5.3 在 BF16 下约需 1.5 TB,适合通过 Inference Providers 使用。

升级依赖写法为 .package(url: "https://github.com/huggingface/AnyLanguageModel", from: "1.0.0", traits: ["MLX"]),已有应用可参考三个库的 release notes 中的迁移说明。

对读者意味着什么

  1. 已经有 Swift 应用在用 Foundation Models 的团队,可以用很小的改动获得多提供方切换能力,不必为每个后端写适配层。
  2. 打算在 iPhone 或 Mac 上跑开放权重模型的团队,可以借 Gemma 4 E2B、LFM2.5 2.6B 这类小模型先做端侧原型,再用同一套代码把大模型请求转到托管端点。
  3. 需要服务端复用的团队可以关注 Linux 支持,但应先在目标 OS 版本上核对这些特性是否全部可用。

Why now

Why it matters

#

Apple 平台上的模型接入一直分散在系统框架和各推理后端之间,AnyLanguageModel 把切换成本压到一行 import,并让本地与云端共享工具调用、引导生成等特性。对已经在维护 Swift 应用的团队,这意味着评估端侧模型或更换提供方不再需要重写会话层。

Background

Technical context

#

Foundation Models 是 Apple 的系统模型框架,AnyLanguageModel 用相同 API 提供可替换的模型后端。llama.cpp、MLX、Core ML 是 Apple 生态常见的本地推理路径,托管侧则通过 OpenAI 兼容或各家原生 API 接入。引导生成指按 Swift 类型约束模型输出结构,工具调用则让模型在会话中触发外部函数。

At your level

Have AI explain this signal at your level

Pick your level of experience and AI writes an explanation for it on the spot.

Audience

Who should care

#
正在用 Foundation Models 框架开发 iOS/macOS 应用的 Swift 开发者需要在端侧运行开放权重模型并评估机型可行性的移动团队希望同一套代码同时覆盖设备端与服务器端推理的工程团队
Areas it may affect
端侧推理Swift 开发多提供方接入开放权重模型

Next

Learning path

#
  1. 先读 AnyLanguageModel 的 README 与迁移说明,弄清替换 import 后哪些会话代码保持不变、哪些需要调整。
  2. 在目标 iPhone 或 Mac 上跑通 Gemma 4 E2B 或 LFM2.5 2.6B 的示例,确认显存与首 token 延迟是否可接受。
  3. 对照 Foundation Models 的引导生成与工具调用文档,验证同一段代码在本地模型和托管提供方上的行为差异。
  4. 如果要上线,检查 API key 闭包与代理方案,并确认 Linux 端所需特性在目标环境中可用。

Getting started

Have AI draft a learning path

From the related knowledge and skills on this page, AI drafts a path from the basics to applying it.

Network

Where it sits in the network

#

How this signal connects to neighbouring technologies, skills and background knowledge. Follow any link to keep exploring.

Comparison

Compare with another technology

Pick another published technology and AI writes a comparison of what they share, how they differ and when to use each.

Further thought

Follow-up questions

#
  • 同一段会话代码在本地 MLX 模型与托管 OpenAI 兼容端点上的工具调用行为是否一致?
  • 在目标 iPhone 机型上运行 Gemma 4 E2B 的实际内存占用和生成速度是多少?
  • 从旧版本迁移到 1.0 时,哪些 API 或依赖声明需要手动修改?

Publication record

Featured in

#

The briefings that carried this signal, newest first; the last row is the weekly review of its week. The tag is the section it ran in.

Sources

Hugging Face Blog

Hugging FaceOpen-source community2026-10-20
Open original sourcehttps://huggingface.co/blog/anylanguagemodel-1-0