云端大模型的痛点与端侧智能的兴起
作为一名曾深度参与 Mozilla Firefox 开发者工具、W3C Web 标准制定、微软 Edge 浏览器研发以及 React 团队的前端与标准专家,我在过去三年中转型为 AI 初创公司、大模型厂商和浏览器公司的技术顾问。在最近加入 AI 观测平台 Arize 后,我更加深刻地意识到,每一次我们向 GPT-5 或 Claude 等前沿模型(Frontier Models)发起请求时,我们不仅在支付高昂的账单,还在牺牲用户体验、数据安全甚至是地球的环境。云端大模型的这种“万能推理模式”实际上存在四个巨大的痛点:
- 安全性与信任成本:云端推理需要将数据发送到远程服务器进行处理,这必然伴随着敏感数据被曝光、拦截和保留的潜在风险。过去我们已经见到了太多由于员工使用云端 AI 聊天机器人而导致敏感商业机密在服务器端被留存,最终遭受数据泄露的真实事故。
- 延迟对用户体验的蚕食:根据针对虚拟现实(VR)等实时交互场景中用户等待延迟的研究,4秒是用户保持沉浸感与真实可信度的物理极限。而当我们将请求发往云端大模型时,很多网络往返加上庞大参数的计算时间经常会突破这个极限。
- 失控的商业开销:当多步推理的智能体工作流(Agentic Workflows)开始普及,系统内部的推理链条会呈复合级增长。即使单 token 的价格在下降,但由于智能体需要自主规划和多次调用,消耗的 token 总量会呈指数级上升,导致推理费用不断增加。
- 离线环境下的生产力归零:如果软件运行在无网络连接、Wi-Fi 极其不稳定,或者处于物理隔离的超安全高涉密环境中,云端模型将彻底瘫痪。
为了消除这些不确定性,我们需要转变思路:如何用更低成本、更安全且能离线运行的本地小模型来替代它们。
Original English
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 DevTools 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 Arize. 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 Arize's observability platform for models and the agents who love them. Anyway, I'll be actually using one of Arize'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. 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, and 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. It cost your business. Third-party inference costs are uncontrollable compared to API 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 four 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 agent can reasoning workloads consume tokens way faster than prices are dropping.
任务特定型与小语言模型(SLM)的硬实力
面对昂贵的大模型,我们可以引入更具性价比的任务特定型模型(Task-Specific Models)与小语言模型(Small Language Models: 参数量在数百万至数十亿级别的轻量化语言模型)。正如我的端侧 AI 备忘清单所展示的那样:
- 视觉分类或目标检测任务,可直接使用
MobileNet、YOLO或MediaPipe等视觉专属小模型。 - 语音转文字或语音识别任务,可使用
Whisper或Wav2Vec2等语音专家模型。 - 文本翻译、内容分析与聊天对话,则是
Gemma或Qwen(千问)这类小语言模型的用武之地。
与参数量动辄上千亿甚至万亿的大语言模型(LLM)相比,SLM 的参数规模通常在百万(M)到几十亿(B)级别。两者的硬件需求天差地别。事实上,云端大模型之所以庞大,是因为它们在预训练阶段塞入了整个人类文明的历史、哲学、甚至海量的 Reddit 社区灌水贴。然而在实际业务中,我们的大多数需求往往只是简单的“总结一段社交对话”或“检测当前用户是否在爆粗口(情绪判定)”。要完美解决这类单一任务,其实只需要极少量的参数即可。
更令人振奋的是,SLM 在能耗效率上展现出了惊人的硬实力。根据 2025 年的一项权威研究,在执行特定智能体任务负载时,SLM 完全可以提供比肩大模型的表现,但能耗却只有大模型的 25% 左右,而更垂直的任务特定型模型则能将能耗拉低到大模型的 12.5%。此外,借助量化技术(Quantization: 通过降低权重数值精度来压缩模型体积的技术),例如将浮点数精度压缩为 8-bit 或 4-bit,模型所占用的磁盘空间和运行时内存可以缩减到原来的四分之一。例如,一个 10 亿参数(1B)的 FP16 精度模型原本需要约 2GB 的内存,量化后能变得极其轻量,这使得它们能够完美运行在个人移动设备上。比如我的 Pixel 10 Pro 手机以及当下主流的 Chrome 浏览器,都已经在底层原生内置了可直接通过 Web API 调用的 Gemini Nano 端侧小模型,彻底免去了用户下载模型的负担,从能耗和隐私角度看,这无疑是端侧部署的一大突破。
Original English
But we can completely eliminate most of these costs and it starts by asking ourselves exactly how much [snorts] is this costing? Do we really need an LLM to do this job? All right. You can use task-specific models, which are small in size and power consumption compared to an AI foundation. Uh this is my little cheat sheet. If you're looking for an expert model, is a camera pointing at something? Division uh you know, is is there a 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 Wave2Vec2. Chat translation or analysis? This is where you might use something like a small language model like Gemma or Quinn. These uh small models are called SLMs uh or smaller language models. The the definition of small is up to debate here. Uh these are great for times when we do need the language power of a generative pre-trained trans- 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 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 jerk right 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 uh awareness. We have uh correct responses. We have good good research that shows this. Small language models um they come in all sizes and shapes. Most small language models uh for mobile and web are deployed with quantization, that is to say, 8-bit, 4-bit, and that can have a quarter disk and memory requirements. 1 billion parameters fits on about 2 GB in FP16. Uh this 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 I of course bought the 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 Let me give you a bar chart here to take a peek. So, let's say this is the total amount of, you know, 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.
“大处原型,小处部署”与 SAGE 模型评估实战
在多年的本地 AI 应用实践中,我发现即使像老版本的 Gemma 3 这样的本地小模型,在被问举诸如“鱼龙(ichthyosaurs)是否拥有回声定位能力”这种复杂的生物学推理问题时,也能通过化石记录的细节证据(如缺乏海豚般的甜瓜形器官或骨骼传导特征)给出极为专业、准确的回答,而云端大模型 Claude 反而会有三分之一的概率和稀泥。为了在业务中高效应用本地模型,我总结出了一套由 Google 联合制定的**“大处原型,小处部署”**(Prototype Big, Deploy Small)的评估与落地框架,其核心步骤如下:
- 第一步:验证可行性。首先使用行业顶尖的云端大模型(如 Gemini 1.5 Pro 或 Claude 3.5 Sonnet)测试你的设想是否能够实现。例如,在我的社交客户端项目 Mima 中,我设计了一个自动总结 50 条长对话讨论线程的功能,以帮我省去清晨醒来时的信息焦虑。我首先用 Claude 验证了该功能的逻辑可行性。
- 第二步:制定成功标准,提取黄金数据集(Golden Dataset: 用于模型基准测试的、高质量且通常由人工标注的数据集)。我导出了 14 个社交对话线程,并针对“简短总结”和“带引用的深入总结”两类场景生成了 28 个预期输出样例。这些数据被整理为 JSONL 格式作为评测基准。我们评估的维度非常严苛,包括:
JSON.parse校验、引用的信息块是否在原始文本中真实存在、事实一致性(Factual Consistency: 确保不张冠李戴,由大模型充当裁判打分)、长度合规性以及 P50/P95 延迟(将 4 秒作为用户可信度的硬性上限)。 - 第三步:由小到大测试,寻找 SAGE 模型。我选择使用 Arize 开源的评测平台 Phoenix 作为观测与评测工具,将小模型与云端大模型 baseline(Claude Sonnet)进行同台竞技。参赛选手包括:
Qwen 2.5 1.5B(延迟约 1s 极快,但准确率低)、Qwen 3 1.7B、Llama 3.2 3B、以及被许多工程师推荐但实测极慢的Gemma 4 5B(延迟高达 8s)。 - 第四步:锁定最适配模型。评测数据表明,在排除感情偏见和严格对齐后,Llama 3.2 3B 脱颖而出,其准确率达到了约 90%,且 median 延迟只有 1 秒多。由于 Llama 3.2 是由 Meta 开发的,其在社交文本、网络会话总结这一特定任务上显示出了极强的针对性,成为了我们寻找的 SAGE 模型(Small And Good Enough: 刚刚好够用的轻量化模型)。
Original English
Um 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 the right you have Goose, which is an open an open agent harness that has a 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 cuz 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 a good response that there is no evidence in the fossil record of their having developed a melon or the specialized bones required for conduction that dolphins have. Of course, Claude hedged it by saying, "Well, we just can't know." Uh about one out of every three times, which was interesting. Claude has always been a little nervous about about coming forth with an opinion. So, how do you pick the best model for the job? This is the hard part. Uh 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 small. Um 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. Uh 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 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 they write. If that is possible, then you know that another model can probably handle it, too. So, you could use like a foundation model like Gemini, or you could use a really really tough uh task-specific model for like handwriting recognition for instance. Now, this feature of the product that I like to build on the side. It's Mima. It is a 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 uh this is a feature that saves me 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 says a pretty good job of 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 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. So, I I exported a golden data set. Now, a golden data set 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 the data looked like. Um this is all public knowledge, but you know, 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 to ex 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. All right. So, that means 28 examples all together. Um yeah. So, these are the things that I was going to be measuring. Um 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? Um an easy way to test is to try JSON parse. And if it works, yay. If it doesn't, boo. Um the reference structural validity, you know, 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. Uh this is this is something that we need an LLM to judge or humans, but the LLMs will be cheaper, I assure you. Um length compliance, making sure it stays within a certain word count, and of course checking the latency. P50, this is, you know, the median across the eval set, and the P95 is the worst-case scenario. All right. So, you collect these, uh 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 need to find a framework, a tool to do the measuring. 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 a what is known as a capability eval. A capability eval asks, you know, 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 one, you can see the the baseline. It's looking pretty good. It's got an average latency of 2.9 seconds. It costs about $0.22 $0.22 to run this 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 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 Let's look at our contestants here. We've got Quen 2.5 Instruct weighing in at 1.5 billion parameters, only a handy 1 GB on disk, and its sister Quen 3, 1.7 billion, just a little bit bigger. And Llama 3.2, weighing in at 3 billion parameters and a tidy 2 GB on disk. And then there was Gemma 4 E2B, which is 5 billion parameters, a hefty 3.1 GB, 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 What? 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 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 P P50. That that's amazing. Like, that's really fast for for an AI summary. The problem was that its accuracy was pretty 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 in right here around the 90% for accuracy. And you can see that both uh both Claude and uh 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 like like Phoenix, you open up the experiment and you actually take a look. You can see what the raw responses were, uh what the expected responses were. You can actually compare them against each other. Um 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. Uh 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? I mean, it's a social thing. Benefits from a a social model.
提示词工程与后处理的极致优化
虽然 Llama 3.2 3B 表现优异,但其基础准确率相比 Claude 依然有 10% 左右的差距。如果我们为了这点差距就去走模型微调(Fine-tuning)或知识蒸馏路线,每次升级功能都会迫使移动端用户重新下载数 GB 大小的模型权重,这会吃光用户的数据流量包。更明智的办法是利用提示词工程(Prompt Engineering)在代码层控制变量来抹平这个性能鸿沟。我设计了 5 个提示词变体在 Llama 3.2 上进行了控制变量实验:
- 基线提示词(Baseline):原始的长文本提示,基本能输出合格结构,但长度控制不稳定。
- 编号输入变体(Numbered Input):将输入的讨论数据从 JSON 结构改写为带编号的消息列表。我们的假设是:本地小模型在追踪自然语言索引(如“第1条、第2条消息”)时的表现会远好于追踪 JSON 数组的偏移量。不过,实测发现性能改进有限。
- 少样本提示变体(Few-shot):在 Prompt 中直接附带了两个讨论线程及其预期总结的输入输出示例。我们的假设是:小模型从真实示例中学习输出格式与规则的速度,远快于从抽象的书面规则中学习。实验证明这是最成功的尝试——输出长度得到了完美控制,准确率和参考一致性飙升,延迟仅微微增加了 200 毫秒。
- 严格否定规则变体(Strict Rules):使用了大量强烈的否定限制词,如“不要输出开场白”、“必须数出字数再回答”。然而,小模型对此表现出了强烈的抗拒,规则越生硬,它的幻觉反而越多。
- 思维链变体(Chain of Thought: CoT):强迫模型在输出总结前,先逐步分析并列出对话中的关键时刻。虽然事实对齐度略微提升,但延迟代价非常惨重,额外增加了 600 毫秒。
除了选择最佳的 Few-shot 提示词,我们还在业务系统代码中引入了后处理校验(Post-processing Checks)。如果小模型生成的 JSON 中的引用对象超出了原始讨论组人数,我们就直接剔除该引用;如果总结文本超出了规定长度,就直接进行物理截断。这套“Few-shot + 后处理”的组合拳产生了令人惊叹的化学反应:Llama 3.2 3B 最终在 Phoenix 测试集中实现了 100% 的 JSON 正确率和 100% 的引用有效性,在实际体感上甚至战胜了 Claude,成功为我每天节省了 1 美元的推理费用。
最后,在生产环境中,我们需要建立像软件工程 CI/CD 一样的回归评估(Regression Evals)机制,确保每次更新提示词或升级本地模型时不会让历史功能倒退,防止团队一觉醒来不小心搞崩整个端侧智能体验。大处原型,小处部署,让我们告别昂贵的云端 API,走向自由安全的端侧推理时代!
Original English
So, recap. Here's how you right-size your model in four steps. Number one, 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 um that 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 you within an acceptable range of that small and good enough model, that sage model. That's when you select your sage model, the smallest model that gives acceptable responses for your inputs. But you're probably wondering, what are we going to do about that gap? I mean, 90% accuracy, that sounds like it could be uh you know, 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 GB model every time to your users. So, this is a great example of like, "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." Um 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 an an update that uh you know, addresses all of the evals. So, let's take a look at closing the gap between Saona and Llama. Now, the the green and blue dots in that upper left-hand quadrant. So, the measures I I honed in on, the ones that they really seem to have different results with, were JSON reference uh JSON and reference structural validity, factual consistency, um P50 latency, and P95 latency. And I decided that the P50 latency the cutoff is, you know, one 1 and 1/2 seconds for P95 would be 3 and 1/2 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 threat the threat as numbered messages instead of using JSON. The hypothesis being that smaller models could track natural language indexing better than array offsets in 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 just being that thinking out loud would improve grounding. So, [snorts] ran the tests again with these new prompts and just just just to the llama 3.2 and we discovered a couple of things. We I mean, myself. I 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 have conversation about the trades if you like. So, stop that. All right, we're back. So, in this case, the baseline wasn't really good at at the 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 didn't made things worse. The model responded very negatively to being told what it couldn't do couldn't couldn't do. It um it was a a naughty child didn't like to take instructions. Chain of thought didn't have that big a it 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 length right. It was more accurate and in its references it agreed with the Claude model a little bit more about what was said and it only increased the the latency by 200 milliseconds. So, that sounds like a pretty good deal, right? So, it was the few shot prompt that one that made the biggest improvement. Let's have a look at how it stacks up to the original. Bum bum bum. So, you can see the bar here Claude Sonnet versus Llama 3.2 3B. Um I actually did a couple of things at this point because I wanted to close that gap completely. So, Llama 3.2B with a few shot prompt was actually able to get within a reasonable error area of um a reasonable error margin of error. The P50 latency went to less than 1 and 1/2 minutes, so it was totally green. Uh the structural validity 91.7% factual consistency was also at 92.9% Uh the P95 latency was well under 750 milliseconds uh less than Claude. In general, its latency was really good. But, let's see about those uh those couple of those 10% here between structural validity and factual consistency. This is why it's important to actually open up your e-vows and take a look what's inside. Uh 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, you know, Claude Opus was comparing Claude Sonnet's response to uh Llama 3.2's response, and of course Claude was favoring its little sister and being like, "Yeah, um I think I think that uh you know, I don't think your interpretation of what Jenna said is accurate because you said she was being angsty and uh 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 rough consistency and length, those actually could be handled inside the harness and post-processing. So, making sure that it's, you know, got the right 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 uh when it comes to, you know, how long the actual uh 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 uh 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 P5 uh P50 latency down to around a 1 second, and P95 uh it was under 300 and uh three three three three and a half seconds. So, that's pretty good. It actually ended up meeting and beating Claude's on it 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. You'll want to make sure that uh 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 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 want to keep your evals running for that, and that would be a regression eval, and you run these sort of like you run um CICD tests, you know, uh 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? Uh how many Claude calls could be Llama calls? I I challenge you to go home today and take a look at what you're sending to LLM's and ask yourself, is this something that a smaller model could handle and how much money would I save if I did that? When working on AI projects, keep an eye out for SLM's and specialized models that might be on device already. For instance, Chrome and the prompt API, they access Gemini Nano which ships with Chrome um natively and that can be really useful cuz that means you don't need to be shipping a model to anyone using the browser. You can take advantage of what's right 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 you know, 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 it 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 test. You can use prompt engineering to help get better results from SLM's 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 see you out there on the web. If you enjoyed talking about small local models or the attentive 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.arise.com. And lastly, you can sign up for uh the beta for Mima uh 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.
📌 文中提及的人物和组织
公司/组织: Arize, Meta, Google, Nvidia
产品/模型: Phoenix, Llama 3.2, Claude Sonnet, Gemini Nano