I don’t have a category for this…
A couple of details before we continue, and after updating the OS:
First, I had to go through some lengths to get rid of all the Siri/AI stuff. Same on the iPhone. (And I’m finding in spite of that, my battery there is draining faster… Although there are confounding factors, so IDK.)
But on the other hand, it does come (the Mac in its latest version) with a built-in on-device inference model, “fm”. It stands for, quite simply: “Foundation Model”.
And there is an option to serve it. Aptly calling it like so:
$ fm serve
(Yes, I did recently get myself an M6 MacBook Pro. It was a long wait, and not the easiest of decisions. And the red thing… I just don’t know how the code above is calculated, probably just some hash, but just in case… hide a bit of it just in case…)
Relevant note: One must accept the license for the foundation model beforehand.
$ sudo fm license(I have done my very best to go through the MacOS 27 License to ensure none of what I intend to do is going against it, and as far as I can tell, asking the chatbot locally on a Mac simple questions with nothing weird or questionable, should be just fine. Even over loopback to the API, which it provides. But I’m no lawyer, so please be responsible with your approval of the license!)
Right, and so what?
Well, I was at a conference last week and someone discussed basically harnesses with {ellmer}. And that gave me an idea. What the colleague proposed: in educational settings (in a conference about R), to develop your own agents for your course. You would use an LLM (whichever you choose, I believe he used an OpenAI model) and create skills/tools for it, so that maybe for instance, it answers questions about your course from your course material.
And the thing is, while I don’t believe creating our own harnesses is necessarily the most efficient way to go (there is no lack of ways to create skills from Claude Code or Github Copilot for instance, and it’s pretty easy), well at least surely it will be fun.
So the “system” model of fm is small, as per the apple web-page:
[…] 3 billion parameters, 4-8K tokens context […]
But I wonder, well, how bad is it? For people used to recent Claude or OpenAI LLMs, pretty bad I would guess. I have tried the agent itself, and indeed, given the capabilities of today’s models (I use some “frontier” stuff at work), one can definitely feel the difference. Even a rather simple demo code generation (e.g. a function for creating a decorator in R) is risky without some care. And that’s absolutely fair!
But does that make it useless? I’d argue no.
So a harness with a small model
Now here my doubt: can you make a useful agent from a mix of tools you create and small language model?
See this is in fact the current trend: On device, small-but-capable models, and made useful through harnesses and tools. So now, should I try to create a function to become a skill or tool, and get it to become an LLM chatbot that can run my functions? Or even an MCP server of some sort? That sounds like a fun exercise…
Apparently {ellmer} supports calling tools.
But first
I don’t know that I’ll have much time for this little exercise, but first I’ll need to try and see whether I can connect {ellmer} to the Mac’s “fm”…
Let’s see!
Setting parameters
After installing {ellmer}, you will need one detail (took me a minute there…).
In your project directory (ideally you always work within a project?), if you don’t have it, create a “.Renviron” file, save some bogus value for the “openai api key”, like so:
OPENAI_API_KEY="fm"Restart R.
Use the ellmer package
Next up, it’s “as easy as…” this:
library(ellmer)
chat <- chat_openai_compatible(
base_url = "http://localhost:1976/v1",
model = "system",
credentials = NULL
)
chat$chat("What is the capital of France?")
Conclusion
It worked! You can even easily start a local chatbot interface, with one more command..
## ...
## Or even more fun:
chat_app(chat) ## Interactive web-chatbot :)
Well not much, just an open door for a fun side project (just what I needed, less time! :D).
Jokes aside, it might be an idea. See I like the concept: Small, local model. Limited, granted, but good enough for simple “natural” interactions. And then, call tools whenever possible.
Reduce the responsibilities of the LLM itself. And yet create an environment for it you can use.
However I’m still far from actual applications that can use this and make sense. And I’m yet to test even creating tools… But for now, it’s a start!
Also, an aside: the Foundation Model itself, “fm”, can register tools too, apparently. It’s just that if I choose to play around with this idea some more, I will be doing things in RStudio, and so I’ll probably go the way of {ellmer} as the harness here.