Intro0:00
Hi there, I'm Rachel Lee Neighbors, and today I'm here to talk with you about how to use local models to stop paying for frontier models. Let's dig into it. So, I've worked on standards that power today's web, with Mozilla on Firefox dev tools and the W3C on web standards, and of course on Microsoft's Edge browser.
I've even been on the React team. Now, I've spent the past 3 years consulting with AI startups and some of our favorite LLM and browser companies on all things web, AI, and UI. And recently I've joined Arise. Have you ever had your CTO ruin your agentic workflow with a slight change of prompt or an LLM migration?
Have you ever been that CTO? Well, you probably need Arise's observability platform for models and the agents who love them. Anyway, I'll be actually using one of Arise's open-source projects today, Phoenix. We'll talk more about that later. But today, specifically, I'm here to talk with you about how AI is costing you.
Hidden Costs1:02
Every time you reach for foundation models like GPT-5 or Claude, it's costing you, your users, and the environment. Let's have a look at the costs of one-size-fits-all inference.
So first, there's security. Security costs trust. When you use a large LLM that's in the cloud, you're sending data to remote servers, and it always carries the risk of exposure, interception, and retention by third parties. We have cases where the use of remote AI chatbots has led to sensitive business data being stored, breached, or leaked to the public.
Latency costs the user experience. Now, there's been research on mitigating response delays in LLM chats in VR and found that 4 seconds is the limit of believability for users, and many calls that you will make to large models are going to take longer than 4 seconds, as we will see when we check Phoenix.
Then it costs your business. Third-party inference costs are uncontrollable compared to API costs. Agency compounding levels of inference, and this means even if the tokens are cheaper, you may be using more of them. Or if you're using 4 of them, they may be more expensive.
And of course, if you aren't connected, remote models simply aren't going to work, which means that unless your software is connected to the web, nobody can use it. Big inference going offline costs productivity. If there's an outage, if you're in a place where you cannot reach Wi-Fi or you're in a very secure environment.
Now, token costs have been falling as of late, but total inference spend has been rising because agentic and reasoning workloads consume tokens way faster than prices are dropping. But we can completely eliminate most of these costs, and it starts by asking ourselves: exactly how much is this costing?
Small Models2:57
Do we really need an LLM to do this job? Allright. You can use task-specific models, which are small in size and power consumption compared to an AI foundation. This is my little cheat sheet if you're looking for an expert model.
Is a camera pointing at something? Do you have vision? You know, is there a vision component? You can use a model like MobileNet, YOLO, MediaPipe. Is it a microphone recording something? There are audio models like Whisper and Wav2Vec2.
Chat, translation, or analysis? This is where you might use something like a small language model like Gemma or Quinn. These small models are called SLMs, or smaller language models. The definition of small is up to debate here. These are great for times when we do need the language power of a generative pre-trained transformer, a GPT, but we probably don't need the sum total of human knowledge in a black box at our disposal.
Or we don't need multimodal capabilities. We're not going to be analyzing images and audio at the same time. Now, SLMs, smaller language models, contain millions to billions of parameters. An LLM contains billions to, well, trillions. So you see the big dot there?
That's one of the smaller LLMs that's out there. But the little dot actually represents one of the larger SLMs. So you can see that there is a huge difference in parameter size, and this means that there is a vast difference in the size of machine you're going to need to run one of these models.
The good news is you don't need most of what's in the big green dot there. You don't need history, you don't need philosophy, you don't need all those Reddit chats, you don't need a lot of what the models have learned and been trained on.
Most of us are using our models for things like summarizing a chat thread or detecting if this person's being a jerkright now. And it takes a surprisingly smaller amount of parameters to determine those things.
Now, the nice thing about smaller language models is that they consume the same or less energy as large language models to produce correct awareness. We have correct responses. We have good research that shows this. Small language models, they come in all sizes and shapes.
Most small language models for mobile and web are deployed with quantization. That is to say, 8-bit, 4-bit, and that can have recorder disk and memory requirements. 1 billion parameters fits on about 2 gigabytes in FP16. This grid, by the way, gives upper-bound estimates.
So these are just to give you an idea of what will and will not fit on different devices. These are so lightweight that they can be put on devices. Speaking of, my Pixel Pro ships with one. And I, of course, bought the Pixel 10 Pro as soon as I could because I wanted to know what it would be like to work with an on-device model, an SLM of my very own.
The good news is that small language models are production-ready. NVIDIA called SLMs the future of agentic AI. Once again, great research paper from 2025 that found that SLMs are sufficiently powerful for running agentic task loads. And they consume less energy than language models.
Let me give you a bar chart here to take a peek. So let's say this is the total amount of energy consumed to perform a task that an LLM would take. An SLM takes about 25% of that, and a task-specific model takes about half of that over.
So as you can see, it's, from an energy perspective, much cheaper to run the smaller language models and task-specific models.
So what are the benefits? Once more, more secure, works offline, no fees, more efficient, and lower latency because it's on-device. No round trips. Now, I've been using local AI for some time. I, for instance, first started using local models.
You see on the left you've got Claude, but on theright you have Goose, which is an open agent harness that has a really nice interface for chatting with models. And this one here, it's running Gemma, and it's able to answer.
It takes a little longer. Smaller models can be a little longer depending on what device you're running and how big the model is. But one of my favorite questions to ask a model is: how likely is it that Ichthyosaurs, marine reptiles from the dinosaur era, had echolocation?
Because if you look at their skeletons, they look a lot like dolphins. And it takes reasoning about biology to be able to determine whether or not that's possible. And it's hilarious to me that even, I think this was Gemma 3, was able to come up with a good response that there is no evidence in the fossil record of their having developed a melan or the specialized bones required for conduction that dolphins have.
Right-Sizing8:14
Of course, Claude hazarded it by saying, "Well, we just can't, no," about 1 out of every 3 times, which was interesting. Claude has always been a little nervous about coming forth with an opinion. So how do you pick the best model for the job?
This is the hard part. I recent, I
so how do you pick the best model for the job? I built a framework with Google that I use on my own projects. You can find more about it at web.dev, but I'll run through it here. Now, first off, I like to think of this as prototype big, deploy small.
Just repeat this to yourself: prototype big. Think big, go big. Deploy smooth. You want to convert the parts of your system over to SLMs and specialized models for production. But you can prototype on a foundation model, no problem.
The first step in this process is to determine whether or not what you're trying to do is even possible at all. You use the largest, most capable model, and you just see if you can get it to do the thing.
See if you can get the model to recognize people by their handwriting or the way they write. If that is possible, then you know that another model can probably handle it too. So you could use a foundation model like Gemini, or you could use a really, really tough task-specific model for handwriting recognition, for instance.
Now, this is a feature of the product that I like to build on the side. It's Mima. It is a client for all your social networks. And I built a feature for it that summarizes long conversation threads. Because I don't know about you, but sometimes I go to bed and I wake up and there's 50 comments on something I posted, and I just want to know, are people angry at me?
And this is what a this is a feature that saves me a lot of heart attacks in the morning. So I first prototyped it out with Claude to prove that it's good enough. So you can see the little you can see the little summaries there, and it does a pretty good job of saying who's talking about what.
So first step for this was to collect a set of inputs and outputs. That is to say, in my case, I wanted to collect a set of threads and then how I would summarize them. Or in this case, how Claude summarized them seemed adequate to me.
Golden Data10:31
So I exported a golden dataset. Now, a golden dataset is a curated, high-quality collection of preferably human-labeled input-output pairs that you're going to use as the ground truth to evaluate, validate, and benchmark your model. This is what the data looked like.
This is all public knowledge, but you can see it's got the author handle, the content, created at, whether or not it came from me. And I created a big JSONL of all of these. So there were 14 threads, and I evaluated each one for summaries and annotations because some of the summaries actually link deeper
into the conversation. So it was the same threads but had two different outcomes for them. One was a short summary, and one was a summary with references. Allright. So that means 28 examples altogether. Yeah. So these are the things that I was going to be measuring.
Success Criteria11:50
You need to, before you start doing anything, you need to know what it is that you're measuring. What is success? In this case, was the JSON being output by the summarization process correct? An easy way to test is to try JSON parse, and if it works, yay.
If it doesn't, boo. The reference structural validity. If it's pointing to different parts of the conversation inside the summary, do those parts actually exist? Factual consistency. That is to say that it's actually able to summarize the content of the threads within reasonableness.
So if we're talking about cats, it doesn't give a summary saying we're talking about puppies. This is something that we need an LLM to judge, or humans, but the LLMs will be cheaper, I assure you. Length compliance, making sure it stays within a certain word count.
And of course, checking the latency. P50, this is the median across the eval set, and the P95 is the worst-case scenario. Allright.
So you collect these, and now you're going to test and do different models and compare how those models rank against the big models. You test from small to large. I had to choose a selection of models, but first I needed to find a framework, a tool to do the measuring.
Capability Eval13:01
And I chose Phoenix, which happens to be created by Arize. It is open source. It's free. And the engineers who work on it are pretty darn awesome, if I do say so myself. We're going to perform, first of all, what is known as a capability eval.
Capability eval asks, what can this agent do well? Where we compare the performance of the large model against the performance of a selection of smaller models. We say, this is what Claude Opus produced, and this is what Gemma 4 produced.
How do these two stack up against each other? Now, I used Claude Sonnet for the baseline. And you can see, actually, there in the bottom, number 1, you can see the baseline. It's looking pretty good. It's got an average latency of 2.9 seconds.
It costs about 0.22
cents to run
14 of these tasks. So I actually did some math, and it turns out I'm using about a dollar worth of inference every day using Mima. I don't have the money to pay for that many teenage girls using Mima every day.
So we're going to have to run this on-device. Good news is the total cost column for all these small local models is absolutely zilch because that inference has been pushed to the consumer. It runs on their device. They're the one who has to charge the phone so that it can draw energy from the battery to run the model.
Of course, you want it to not suck the battery dry, but that is another conversation for something that we could be testing and evaluating in the future. Now, I chose let's look at our contestants here. We've got Qwen 2.5 Instruct, weighing in at 1.5 billion parameters, only a handy 1 gigabyte on disk.
Model Showdown14:53
And its sister, Qwen 3, 1.7 billion, just a little bit bigger. LLaMA 3.2, weighing in at 3 billion parameters and a tidy 2 gigabytes on disk. And then there was Gemma 4 E2B, which is 5 billion parameters, a hefty 3.1 gigabytes.
But this was the one that so many engineers I spoke with when I was picking a model were like, "Oh, Gemma 4 is the best. You got to use Gemma 4." And I think that's important here because if I had just gone with what my buddies told me, I may have given the user well, pardon, not may have.
I would have given the user an extremely different experience, not a good experience. You're going to want to select the smallest model that gives acceptable responses for your use case, or as I like to call it, the sage model, the small and good enough model.
I'm trying to make this a thing. Bear with me. I hope we can make sage happen. Now, at first, I thought I wanted the Qwen 2.5 model because it was the fastest. You can see that Qwen is all the way here.
Let's see, where'd it go? Yeah, 2.5 is the gray circle in the lower left-hand corner. It came in around 1 second total in latency on the P50. That's amazing. That's really fast for an AI summary. The problem was that its accuracy was pretty low compared to everybody else.
The orange square is Gemma 4 E2B, and the blue diamond is Claude Sonnet, which is our ceiling. It's the most accurate, but it's also a little pudgy, a little slow. It's weighing in around 3 seconds in latency. So when we take accuracy into account, the winner was actually LLaMA 3.2, which is the big green circle that's weighing inright here around the 90% for accuracy.
And you can see that both
Claude and
LLaMA 3.2 are much faster than Gemma 4. Gemma 4 was coming in around 8 seconds. Now, maybe that was because Gemma 4 needed a different kind of prompt, but this was pretty consistent. I was testing each one of these three times and then averaging the results.
This is what the results look like. I recommend when you're running evals with something like Phoenix, you open up the experiment. You actually take a look. You can see what the raw responses were, what the expected responses were.
You can actually compare them against each other. I found that in many cases, LLaMA's response was so close to Claude's response as to be pretty much indistinguishable from one another. So yeah, LLaMA 3.2 was the ultimate winner, and I decided to move forward with them.
And this makes sense because LLaMA 3.2 is created by Meta, and Meta has a strong interest in creating models that do a good job with human inputs and summarizing human things on a social network. Makes sense,right? Mima is a social thing, benefits from a social model.
So recap. Here's how youright-size your model in four steps. Number 1, you prove it's possible. You test whether what you're trying to accomplish is possible at all by using the largest possible model. This could be a foundation model like Gemini or a task-specific model.
And you set success criteria. You collect a set of inputs and outputs that you want to see coincide with one another. This will be the bar. And then you test from small to large. You compare the outputs of small models against your test criteria, and you work your way up from the smallest model until you get within an acceptable range of that small and good enough model, that sage model.
And that's when you select your sage model, the smallest model that gives acceptable responses for your inputs.
Prompt Tuning19:24
But you're probably wondering, what are we going to do about that gap? I mean, 90% accuracy. That sounds like it could be a that could be a deal breaker. Well, we can squeeze better performance out of smaller models with prompt engineering.
This is important in cases where you can't control which model you're using. Some people might, for instance, create a distilled model that's been trained to do this one task really well. But if you're working, for instance, with a mobile app, you might not want to be using a distilled model because every time you add capabilities, you'll probably have to train the model slightly, and then you'll be shipping a new 1 or 2 gigabyte model every time to your user.
So this is a great example of, ooh, I don't think I'll be able to control that model. Once it's on the user's device, I'm not going to ask them to download new ones. That would eat up their data plan.
You might join a team, and they're already committed to Gemma 3, and they're just not going to be implementing Gemma 4 until they've rolled out an update that addresses all of the evals. So let's take a look at closing the gap between Sonnet and LLaMA.
Now, the green and blue dots in that upper left-hand quadrant.
So the measures I honed in on, the ones that they really seemed to have different results with, were JSON and reference structural validity, factual consistency, P50 latency, and P95 latency. And I decided that the P50 latency, the cutoff is 1 and a half seconds.
For P95, it would be 3 and a half because remember, 4 seconds is that worst-case scenario for people feeling disconnected from an AI-powered experience, as per the research.
So
where do we start? I recommend that you optimize one step at a time. You want to isolate one variable per prompt variant to test whether what you're trying to accomplish is moving the needle when you're using the different prompts.
So I created five prompts. Well, I created four prompts, and I had the original prompt as the baseline. The original prompt was pretty good. V2 used number input. The same prompt reformatted the thread as numbered messages instead of using JSON, the hypothesis being that smaller models could track natural language, indexing better than array offsets in a heap of JSON.
The second one was a few-shot. It added a couple of examples and outcomes to the prompt, the hypothesis here being that small models learn format from examples faster than from rules. Then there was the strict rules version. This one was a house-of-no prompt.
It had explicit negative constraints. No preamble. Don't count words before responding. I mean, do count words before responding. And the hypothesis was that small models respond to literal commands and that they like to be bossed around a bit.
And then lastly, there was chain-of-thought, which forced the model to identify key moments before writing, the hypothesis being that thinking out loud would improve grounding. So ran the tests again with these new prompts and
just to the LLaMA 3.2, and we discovered a couple of things. We, I mean, myself, just ran this locally on my machine and was able to compare the results. You can even put the results into something like Claude and have a conversation about the trades if you like.
So
stop that. Allright, we're back. So in this case, the baseline wasn't really good at determining how short it should be so it would fit within a certain section of content. The ref accuracy was 91.2%. It was factually correct 87.1% of the time, and the latency was 1 second.
Reformatted input didn't really make a difference. Explicit rules actually made things worse. The model responded very negatively to being told what it couldn't do, could and couldn't do. It was a naughty child. Didn't like to take instructions. Chain-of-thought didn't have that big.
It did a little bit better on the length, and unfortunately, that came at increasing the latency by 600 milliseconds. The best-performing one was the few-shot one that provided a couple of threads and a couple of examples. It was much better at getting the lengthright.
It was more accurate in its references. It agreed with the Claude model a little bit more about what was said, and it only increased the latency by 200 milliseconds. So that sounds like a pretty good deal,right? So it was the few-shot prompt that won.
It made the biggest improvement. Let's have a look at how it stacks up to the original. Bump, bump, bump. So you can see the bar here, Claude Sonnet versus LLaMA 3.23b. I actually did a couple of things at this point because I wanted to close that gap completely.
Gap Closed24:35
So
LLaMA 3.2b with the few-shot prompt was actually able to get within a reasonable area of a reasonable margin of error. The P50 latency went to less than one and a half minutes, so it was totally green. The structural validity, 91.7%.
Factual consistency was also at 92.9%. The P95 latency was well under 750 milliseconds, less than Claude. In general, its latency was really good. But let's see about those couple of those 10% here between structural validity and factual consistency.
This is why it's important to actually open up your evals and take a look at what's inside. When it came to factual consistency, it turned out that Claude was just being a very strict judge. I was using Claude to judge the responses and comparing.
Claude Opus was comparing Claude Sonnet's response to LLaMA 3.2's response. And of course, Claude was favoring its little sister, being like, "Yeah, I think that I don't think your interpretation of what Jenna said is accurate because you said she was being angsty, and she was actually being cross."
It was that sort of thing. And this is why it's important to crack them open. Now, as for ref consistency and length, those actually could be handled inside the harness and post-processing. So making sure that it's got theright number of references in the thread, that's something very simple to look at.
You can just see how long the thread is, and if there are more refs than there are members of the thread, that's incorrect. When it comes to how long the actual summary is, if it's too long, you can just truncate it.
And so when we added the post-processing, we're actually able to close that gap pretty solidly. Now we've got 100% JSON validity. Structural validity was 100%. Factual consistency, there's only a little bit of a disagreement there, and it turns out that it was the judge being too darn strict.
We got the P50 latency down to around 1 second, and P95, well, it was under 3
and a half seconds. So that's pretty good. It actually ended up meeting and beating Claude Sonnet after doing this little bit of extra effort. And I'm saving about a dollar a day in inference costs. So the important thing is, after you've done something like this, you don't want to lose one ground.
Regression Evals27:53
You'll want to make sure that you can update the prompt in the future or upgrade the model. You don't want to lose one ground. You want to ensure that you can upgrade the model or change the prompt in the future, and it won't cause summaries to expand to be a paragraph long or to start hallucinating things that are untrue.
You'll want to keep your evals running for that. And that would be a regression eval. And you run these sort of like you run CI/CD tests. It's how you keep your CTO from blowing away your agentic experience by accident one morning.
True story happened to a founder friend of mine. So where do you get started? How many Claude calls could be LLaMA calls? I challenge you to go home today and take a look at what you're sending to LLMs and ask yourself, is this something that a smaller model could handle, and how much money would I save if I did that?
Go Local28:35
When working on AI projects, keep an eye out for SLMs and specialized models that might be on-device already. For instance, Chrome and the Prompt API, they access Gemini Nano, which ships with Chrome natively. And that can be really useful because that means you don't need to be shipping a model to anyone using the browser.
You can take advantage of what'sright there.
Keep in mind that these models are more efficient, and they meet your users where they are. Their information stays on-device. You don't have to worry about PII. And the energy consumption is, well, a blessing for the environment, so to speak.
Remember to prototype big and deploy small. You may want to prototype your system with a foundation model and then convert parts of it to small language models and specialized models for production. Keep in mind you want to prove it, define it, test it, and then select your sage model that passes the tests.
You can use prompt engineering to help get better results from SLMs and close that gap with remote models.
So I challenge you to consider your current implementation of prototype and convert one feature to use a smaller local model. Go home, try it out for yourself, and you might be surprised. Anyway, I look forward to seeing you out there on the web.
If you enjoyed talking about small local models or the agentic web, you can follow me. I'm at nearestneighbors.com. If you want to try running some evals with your current setup, you can start testing with Phoenix at phoenix.arize.com. And lastly, you can sign up for the beta for Mima at mima.social.
I've been Rachel Neighbors, and it's been awesome chatting with you today. Go forth and build your own inference stack.





