跳到正文
Hacker News· frizlab·· 7 天前AI 评分22

用 fm 命令在 Mac 上体验 Apple 端侧 AI 模型 AFM 3 Core

Try On-Device AI with FM

AI 导读

在搭载 M3 及以上芯片、至少 12 GB 内存的 Mac 上,可通过 Terminal 中的 fm 命令直接调用 Apple 端侧模型 AFM 3 Core 及其 Advanced 版本,无需 Swift、Xcode 或 Python。

正文 · AI 翻译

如果你的 Mac 已经在运行 Golden Gate,并且你一直在关注 Apple 的 AI 动态,你就会知道它强调尽可能在设备上完成工作,而不将你的数据发送到别处处理。当设备外 AI 由 Private Cloud Compute (PCC) 处理时,Apple 竭尽全力保护你的隐私,但未来某个时候我们将为这项服务付费。当然,设备上 AI 将保持免费。

目前这可能看起来令人困惑,因为即使是最琐碎的任务似乎也会被发送到 PCC,使用其更重量级的模型(包括 AFM 3 Cloud)来运行,正如 Apple Intelligence Reports (AIR) 中所见。本文展示了当你的 Mac 上可用时(承诺是 M3 芯片或更新版本且至少 12 GB 内存的机型),如何开始探索 Apple 的设备上 AFM 3 Core 及其 Advanced 版本。为此你不需要 Swift 编程技能、Xcode 甚至 Python,只需一点时间和耐心,在 Terminal 中使用新的 fm 命令。

fm 有自己的 man page,清晰且信息丰富,但并未真正解释如何充分利用其对本地 Foundation Models 的访问。还有 Blake Crosley 写的一篇不错的入门文章,尽管那主要针对从 Python 调用 fm,他链接的 WWDC 2026 演示也是如此。

在你首次使用 fm 之前,Apple 要求你通过输入
sudo fm license
并输入 yes 或 y 来同意其法律声明和条款。

Q&A

然后你可以通过探索其局限性来轻松尝试,使用
fm respond 'What does Disk Utility do?'
或类似问题。这些会作为提示发送给默认系统模型(AFM 3 Core)来回应。

你很快会发现它知道的不多。问它一天中的时间,它无法读取系统时钟。它甚至不知道你运行的是哪个版本的 macOS,或 Mac 的型号。如果你想快速一笑,试试经典问题
fm respond 'How many r's are there in the word "strawberry"?'
它会回答 2。事实上,它似乎对你提供的任何词都回答 2,甚至大象。

不过,当被问及 macOS 时,它确实表现更好。它对 Disk Utility 和其他常见工具略知一二,但有时会错误回应,例如断言 Storage 设置在其视图底部显示了可清除磁盘空间的大小。也许它只接受了 Apple 有限文档的训练,尚未被允许抓取这个博客。

Chat

我发现它的 Chat 模式更成功,也更有价值,因为它能提供对其‘推理’的洞察。在进入 Chat 模式之前,值得给它一些精心准备的指令,例如使用
fm chat --instructions "Answer the person's question. 1. Begin your response with a plan to solve this question. 2. Follow your plan's steps and show your work. 3. Deliver the final answer in 'answer'."

你可以扩展这些,或许以给出其角色和身份开头,例如
You are an expert Swift programmer.
然后简要说明。不要给它超过一两段的提示,因为可能会超出其 token 限制。记住这是一个小的设备上模型,不是 ChatGPT。

你的指令将打开 Chat 模式,你可以在其中输入问题。在我指示它展示其‘推理’后,我输入了
How many days are in the month of February?
它回应道
To determine the number of days in the month of February, follow these steps:
1. Recall the standard calendar structure: each month has a specific number of days.
2. Note that February varies based on leap years, but the standard count is typically 28 or 29 days.
3. For a common year, February has 28 days; for a leap year, it has 29 days.
Since the question does not specify a year, we use the standard count: February has 28 days in a non-leap year and 29 in a leap year. Generally, it is considered 28 days unless a leap year applies.
Assuming a common year:
answer: 28

当你在 Chat 模式时,输入 /help 查看可用命令,或 /quit 退出聊天。你会被告知可以用来恢复该对话的命令,例如
Resume conversation with: fm chat --resume february-days
你可以在需要时这样做。

Transcripts

因为这是在设备上进行的,所以它不会出现在 AIR 中。相反,fm 将记录隐藏在 ~/.fm/sessions/ 中,采用 JSON 格式。与 AIR 相比,这些记录很轻量,因此使用好的文本或 JSON 编辑器应该很容易浏览。

更多技术信息见 Foundation Models 框架文档,不过它更面向使用 Swift 的开发者。也许很快就会有那么一天。

玩得开心!

来源:Hacker News · eclecticlight.co