重构 Token Maxing:以最小算力开销榨取极致模型智能 AI Engineer 2026-10-14

重构 Token Maxing:以最小算力开销榨取极致模型智能

4 节

破除算力迷思:从无谓消耗到智能密度

在当前的大模型与 AI 智能体生态中,Token Maxing(狂刷 Token)已经演变成一种奇特的行业模因。许多团队在内部搭建排行榜,攀比谁调用的 Token 数量最多;在 Meta,狂烧算力的人甚至会被冠以“Token 传奇”(Token Legend)的荣誉称号。然而,如果你是在严肃地交付一款工业级软件产品,将 Token 消耗量作为衡量成功的指标是极其荒谬的。Token 并不是工作成果本身,而是为了完成工作所支付的算力税。

以 OutRival 为例,我们的数字员工需要通过电话、短信与电子邮件全天候处理海量复杂业务。在应用层架构下,系统每天需要处理数十亿级别的 Token。在这样的生产规模下,任何一次冗余的模型调用都会被成倍放大,最终演变为灾难性的高延迟和数百万美元的额外算力开销。许多团队的生产提示词由于长期的补丁式迭代,已经严重结构性膨胀(Structural Bloat)——以虚构公司 HarborBite 的客户意图分类任务为例,单条提示词可能塞满了 20 多个边界情况、极度冗长死板的定义,以及通篇近乎恳求模型不要产生幻觉的套话。将这种提示词每天并发调用数百万次,本质上是在自残系统利润。我们必须彻底重塑 Token Maxing 的定义:它绝不该是狂烧 Token 的竞赛,而应当是用绝对最小的 Token 载荷,榨取出最大工作表面积的模型智能。

英文原文

Hey everyone, I'm Alvin, the head of agent intelligence at OutReval. By now, everyone's heard of token maxing. People have built leaderboards inside companies for who's using the most AI tokens. At Meta, they even had a title for this, tooken legend, a badge of honor for whoever's burning the most compute. It's a funny meme, but if you're actually shipping a product, token usage is a bizarre measurement of success. Tokens aren't the work. They're what you pay to get the work done. At OutRrival, our digital workers handle complex tasks over phone, text, and email. At the application layer, we're processing billions of tokens every single day. And when you operate at that scale, every redundant model call compounds into massive latency and millions of dollars in compute costs. Take a look at this prompt. I've built a synthetic proxy that mirrors what structural bloat looks like in a pipeline. Let's pretend we're classifying customer intents for a fictional company called HarborBite. We've all seen one of these. It's got 20 edge cases, overly pedantic definitions, and a paragraph practically begging the model not to hallucinate. When you're sending this much text on every single request, millions of times a day, it isn't just a prompt anymore. It's a massive self-inflicted compute tax. If you want to give your agents more capabilities, you need the architectural headroom to do it. So today, we're reclaiming token maxing. It shouldn't be about burning the most tokens, but about extracting the maximum surface area of intelligence from the absolute minimum token payload. So here's how to actually token max. Let's get into the playbook.

天花板测试:剥离基线方差的评估科学

想要优化系统,首要前提是建立精准的观测体系。利用 OpenTelemetry(开源可观测性框架)等工具对统一模型客户端进行埋点插桩,将每次调用的提示词版本、模型超参数、Token 消耗、端到端延迟和费用串联成可追溯的链路,从而刻画真实的生产基准。然而,绝大多数团队的优化尝试在第一步就撞了墙。常规做法往往是:工程师拿出一个庞大臃肿的旧提示词,直接喂给一个更小、更便宜的模型,并用数千条历史生产日志做离线回放。在 OutRival 的真实实验中,低成本候选模型与昂贵基线模型之间出现了约 18% 的预测分歧。团队通常会本能地得出结论:小模型不行,优化失败。

但这 18% 的分歧究竟代表了什么?在真实的非结构化复杂输入面前,模型本身存在固有的概率波动,分歧率本质上是一个复合指标。为了剥离这个隐藏的关键变量,我们必须先提出一个看似愚蠢但极其致命的问题:生产系统自己与自己能达成一致吗? 为此,我们设计了天花板测试(Ceiling Test / AA 测试):让当前昂贵的生产大模型在完全相同的输入上独立运行三次并对比输出。测试结果令人震惊——生产模型与自己自身的输出分歧率竟然高达 7%(自一致率仅为 93%)。换言之,许多团队在要求低成本模型达到绝对完美的复刻标准时,完全忽视了连昂贵的生产基准自身都无法达到该标准。唯有通过天花板测试校准出系统的固有方差基线,后续的所有降本动作才具备了科学的度量前提。

英文原文

First, observe. You can't fix what you can't measure. Instrument your shared model client so each attempt becomes part of a trace connecting the model calls, tools, and retries for a single task. Record the prompt version, model settings, token usage, latency, and cost. Open telemetry is a great framework for tracking this. Now that you have that telemetry, you can actually build a benchmark of how production is behaving. But here's where most optimization efforts hit a wall. Let me tell you how it usually goes. You take your massive prompt, you hand it to a smaller, cheaper model, and you run it against a few thousand of those historical production examples. We did this. Our cheaper candidate model disagreed with our expensive production baseline about 18% of the time. So naturally, we threw it out. It wasn't good enough. But what does that 18% actually represent? Because language models in production are dealing with inherently ambiguous real life inputs, that 18% is actually a composite metric. It introduces a critical hidden variable, the baseline variance of the model itself. When the input is messy, your production prompt will inevitably disagree with its own past decisions. So to isolate that hidden variable and understand what your rewrite actually changed, we asked a really dumb question. Does prod even agree with prod? We ran an AA test. We call this the ceiling test. We took our massive expensive production model and ran it three separate times on the same inputs and compared the answers. We discovered that it disagreed with itself roughly 7% of the time. Production's own agreement was only about 93%. So we were demanding a standard of perfection from the cheap candidate that our existing expensive system couldn't even hit. Once you establish that ceiling test benchmark, you finally have a measured baseline. Now you can start making the work cheaper.

降本三阶杠杆:缓存、自动搜索与小模型路由

在确立了科学度量基线后,推进工程降本有三个按序执行的核心杠杆:

  • 前缀缓存优化:第一阶杠杆是系统性重构提示词布局,最大化前缀缓存(Prefix Caching)命中率,这是以极低改造成本大幅降低调用单价的最直接手段。
  • 自动化指令压缩:第二阶杠杆是缩减提示词本身的尺寸。HarborBite 案例中的提示词之所以膨胀至近 5,000 个 Token,是因为历史维护中各个工程师不断打补丁,堆砌了诸如“严禁将客户热情误判为授权确认”等条规以及大量硬编码的长对话范例。由于害怕“删掉一行就搞崩线上”,没人敢轻易精简。解决方案是放弃人工编写,引入 DSPy(斯坦福开源的声明式语言模型编程框架)与 GEEPA 等提示词优化器,将提示词工程转化为参数搜索问题。开发者只需定义清晰的接口契约、输入输出 Schema 和打分函数,优化器便会在测试集上展开搜索闭环,利用失败反馈重写指令。这一步直接剔除了所有笨重的样例,替换为紧凑的规则,在保证下游契约不变的前提下实现了 51% 的指令 Token 缩减。
  • 模型降级与架构拆分:第三阶杠杆是在紧凑提示词的基础上缩减模型尺寸。此时有两种高级策略:其一是流水线拆分,将复杂任务拆解,用极便宜的小模型负责前置路由分类与实体提取,仅在涉及重度推理时才激活昂贵的前沿模型;其二是跨模型蒸馏搜索,复用 DSPy 优化循环,直接让小模型作为优化主体,搜索其自身的最佳提示词形态以拟合大模型的任务表现,从而实现对特定领域任务的精确适配。

然而,将大模型的复杂行为强行压缩到小模型中并非坦途,极易引发过拟合与全新失效边界,许多降级实验最终都因提示词泛化能力不足而无法上线,这直接引出了最后一个关键壁垒——如何确信重构没有破坏线上业务。

英文原文

There are three technical levers I like to pull and they run in a sequence. The very first is caching. Specifically, structuring your prompts to maximize your prefix cache rate is a really easy and really effective way to bring down the cost to run given tasks. The second lever is to actually shrink the footprint of the prompt itself. So, let's bring that Harborbite prompt example back up. This prompt is almost 5,000 tokens long. And why? Because over time, developers kept bolting on paragraphs of rules. For example, do not confuse enthusiasm with authorization is one such example. Uh, plus massive hard-coded transcripts that were acting as worked examples. Nobody wants to be the one who deletes a line and breaks prod. So what do you do? You automate it. You turn prompting into a search problem. With a framework like DSPI, you can actually stop manually writing instructions. You define the exact interface contract, the inputs, the required output schema, and the scoring function. And then you hand it off to an optimizer like Jeepa. The optimizer treats your prompt as a search space. It runs against your benchmark attempting to match those historical labels. And it uses feedback on failures to revise the instructions. It stripped out almost all of our long worked examples and replaced them with compact rules. A 51% reduction in instruction tokens with the same application contract. Now we can move to test whether quality holds. That is instant margin. The third lever is to actually downsize the model. Now that you have a tight prompt and a measurable search loop, you don't always need a massive frontier model. You can start aggressively cutting compute. There are two interesting strategies here. First, you can break a massive prompt into smaller components. you use a cheaper model to handle something like initial routing or data extraction and only wake up your expensive frontier models for heavy reasoning. Second, you can use that exact same DSPI search loop we just built, but plug a smaller model into it. You let the smaller model search its own prompt space to match the benchmark answers generated by your large production model. You're essentially using Jeepa to teach a tiny model to match the task performance of a massive one for your specific data set. But the reality of optimization is not quite so easy when it comes to these small models. Um if you're trying to compress the behavior of a large model into a smaller one, you'll notice that you introduce new points of failure and overfitting. Um, and in many of our downsizing experiments, uh, we found that the prompts weren't good enough to release, which brings us to the final hurdle. We've cut Harbor's prompt in half, but now we have to prove that we actually didn't break the product.

成对置信发布:用统计检验终结玄学交付

在提示词体量砍半后,如何严密证明系统未发生衰退?鉴于大模型的概率特性,生产环境始终存在自我波动,候选版本亦然。我们不能依赖粗暴的整体匹配率,而必须执行大规模影子流量部署(Shadow Deployment),从三个维度同步比对同一批线上请求:

  1. 基线自洽测试:生产模型对比生产模型(Prod vs Prod);
  2. 候选自洽测试:候选模型对比候选模型(Candidate vs Candidate);
  3. 跨版本对照测试:候选模型对比生产模型(Candidate vs Prod)。

这里的数学核心在于:从两个版本之间的表面分歧率中,扣除两个版本内部各自的平均内在方差,剩下的差值才是两者决策概率分布的真实漂移量。更重要的是必须明确一个认知——不同并不等同于变差。如果提示词优化器切实发挥了作用,分布产生差异恰恰是因为压缩后的提示词修复了旧生产系统的缺陷。在 HarborBite 的人工抽样复核中,虽然标记出 443 处退化,但同时确认了 2,463 处真正的正向改进,正反比高达将近 6 比 1。

但工程决策绝不能押注于单点均值估计,必须抵御采样噪声。我们必须建立配对样本置信区间(Paired Confidence Interval):将相同会话请求严格成对绑定评估,计算净收益的置信下限(Lower Confidence Bound)。只有当下限严格大于 0 时,才能得出新模型确实更优的统计学结论;一旦区间穿透 0,则表明需要更多样本支持。最后一道防线是分层意图校验:必须将全局统计拆解到核心业务意图维度单独计算,防止亮眼的全局平均值掩盖致命垂直分类的崩溃。当核心指标的置信下限全线越过零轴,团队便能果断敲定发布,从而彻底用严密的统计发布准则取代传统玄学调优,让每一枚 Token 的算力开销都转化为真实的业务价值。

英文原文

Remember, these models are probabilistic. Production doesn't always agree with itself. And likewise, our new cheaper candidate is also going to have its own internal variance. So you run a massive shadow deployment on the exact same inputs and measure the system from three angles. Production against production, candidate against candidate, and candidate against production. There's a useful bit of math here. You take the disagreement between the two versions and subtract the average disagreement inside each one. What's left gives you a measure of how different their decision probabilities are. This is where that ceiling test pays off. We aren't guessing. We have a mathematical baseline for how much these answers move around when we haven't changed a thing. And here's the secret about that drift. Different doesn't automatically mean wrong. If your optimizer did his job, the distributions should be different because the cheaper prompt is actually doing a better job. We aren't necessarily trying to build a perfect clone of a production system that may already have some flaws baked into it. So, you stop panicking about the raw differences, you pull the diffs, and you manually review some of them. Was the candidate better? Was production better? or were they just two different equally acceptable ways to handle an ambiguous input? For Harbor Bite, let's say the completed review confirmed 443 regressions, but it also found 2,463 outright improvements. That is almost six improvements for every one regression from a prompt that is half the size. But you do not ship on a point estimate. You have to account for sampling noise. We measured a massive gain on this specific batch of requests, but we need to know exactly how much statistical confidence we can put behind it. So, we calculate a confidence interval around that net gain. You keep the comparison strictly paired, both versions answering the exact same request, and you keep the repeated runs of the same conversations grouped together. To say the candidate is better, we want the lower confidence bound above zero. If the interval crosses zero, we need more evidence before making that claim. And one final sanity check is that you have to run this math on your critical categories separately. A great global average can actually uh silently hide that one vital customer intent is tanking. If your critical categories hold up and your lower confidence bound is above zero, you have your answer. Ship it and keep measuring. So this process is how you can replace the guesswork of prompt engineering with an explicit release rule. Cache the obvious stuff. Let an optimizer shrink your instructions. Rightize your model and use the ceiling test to understand the variation. Then test whether quality holds. So here's your homework for Monday morning. Go pick your most expensive task. Measure your baseline variance. put it through a search loop and find out exactly how much bloat you're paying for. We need to reclaim token maxing. Let the rest of the industry fight for the high score on the leaderboard. The real token legends are the ones making every single token count.

文中提及的人物和组织

公司/组织: OutRival, Meta

产品/模型: DSPy