Amazon用决策模型替换Sonnet 4.6,成本降98%
Amazon saves millions by replacing Sonnet 4.6 with Strands Decider
Agent开发必看,用决策模型替代LLM做分类能省98%成本,附完整架构与踩坑细节,直接照做即可落地。
For a while, Amazon and AWS teams relied on Claude Sonnet 4.6 to label tickets in an internal system without breaking the bank.
有一段时间,亚马逊和 AWS 团队依靠 Claude Sonnet 4.6 在一个内部系统中对工单进行标注,且无需花费巨资。
Sonnet 4.6 fit the goldilocks choice of balancing intelligence with cost. Considering it dealt with one of the world’s largest internal ticketing systems, the nine month old model did well. However, two Amazon engineers recently swapped out Sonnet 4.6 for Strands Decider, a decision model we launched a month ago, that performed just as well at 98% less cost. This change will save millions of dollars of token costs in a year.
Sonnet 4.6 在智能与成本之间取得了恰到好处的平衡。考虑到它处理的是全球最大的内部工单系统之一,这个仅九个月大的模型表现良好。然而,最近两位亚马逊工程师将 Sonnet 4.6 替换为 Strands Decider——这是我们一个月前推出的决策模型——它在性能相当的情况下,成本降低了 98%。这一变化将在一年内节省数百万美元的 Token 成本。
Carr and Mehul, who work on the internal ticketing system, walk through how this happened below.
负责内部工单系统的 Carr 和 Mehul 在下方详细介绍了这一过程是如何发生的。
Replacing an LLM’s job with a decision model
用决策模型取代大语言模型(LLM)的工作
We had Sonnet 4.6 labeling tickets at enormous scale. The tickets could be customer escalations, capacity requests, automated alarms, security findings, or anything else across the company that needed to fit within 20 category types. The agent ran with a long system prompt on every ticket, generating JSON and reasoning against a fixed set of labels.
我们曾大规模使用 Sonnet 4.6 对工单进行标注。这些工单可能包括客户升级投诉、容量请求、自动警报、安全发现或公司内部任何其他需要归类到 20 种类别类型中的事项。代理程序在每个工单上运行一个冗长的系统提示词,生成 JSON 格式的输出,并针对一组固定的标签进行推理。
A decision model can’t generate text. It’s first given some state and a question with a set of options, then the decision model returns a probability for each option plus a confidence score. We saw this method fit perfectly with ticket labeling: the state is the ticket, the options are the label catalog.
决策模型无法生成文本。它首先接收一些状态信息和一个带有选项集的问题,然后返回每个选项的概率以及一个置信度分数。我们发现这种方法非常适合工单标注:状态即工单本身,选项即标签目录。
We started with the original Strands Decider 2B. On a test set of tickets, the E4B Gemma 4 build got clearly better results, so we switched to it. Afterwards, we tuned how confident the model needed to be before applying a label. The results showed E4B beating production Sonnet on a separate set of our tickets.
我们从原始的 Strands Decider 2B 开始。在一组测试工单上,E4B Gemma 4 版本取得了明显更好的结果,因此我们切换到了它。随后,我们调整了模型在应用标签前所需的置信度阈值。结果显示,E4B 在我们另一部分生产工单上的表现优于正在使用的 Sonnet。
We ran E4B on SageMaker ml.g5.xlarge instances (one A10G, 24 GB each). The model used about 19 GiB, and one request took about 640 ms on one instance. The endpoint autoscales with traffic, but its network was isolated, preventing outbound access to the container. SageMaker copies the model weights in from S3 before start-up.
我们在 SageMaker ml.g5.xlarge 实例(每台配备一块 A10G GPU,显存 24 GB)上运行 E4B。该模型占用约 19 GiB 空间,单个请求在一个实例上耗时约 640 毫秒。端点会根据流量自动扩展,但其网络是隔离的,阻止了对容器的出站访问。SageMaker 会在启动前从 S3 复制模型权重。
Customers can do this too! Apart from our ticketing APIs, everything in the path is a standard AWS service. Ticket events land in an SQS queue that then triggers a Lambda function. It reads the ticket data and calls the model, a SageMaker AI Endpoint with Strands Decider. AppConfig holds the switch (described below), and CloudWatch carries the logs, metrics and alarms. The stack is defined in CDK with deployment stages for Beta, Gamma, and Prod.
客户也可以这样做!除了我们的工单 API 外,路径中的所有组件都是标准的 AWS 服务。工单事件进入 SQS 队列,进而触发 Lambda 函数。Lambda 读取工单数据并调用模型,即搭载 Strands Decider 的 SageMaker AI 端点。AppConfig 持有开关配置(如下所述),CloudWatch 负责记录日志、指标和告警。整个架构通过 CDK 定义,并为 Beta、Gamma 和 Prod 部署阶段设置了相应的部署环境。
Running Sonnet 4.6 and Strands Decider on the same tickets
在同一批工单上运行 Sonnet 4.6 和 Strands Decider
We didn’t want to flip a switch and hope. The labeling Lambda reads a three-way setting from AWS AppConfig on every message:
我们不想简单地打开开关然后碰运气。标记 Lambda 会在每条消息上从 AWS AppConfig 读取一个三路设置:
- BEDROCK: Sonnet labels every ticket, but Strands Decider isn’t called.
- DUAL: Both the Sonnet and Strands Decider models are called in parallel. The results from the Sonnet model are applied to the ticket and compared with Strands Decider results.
- DECIDER: Strands Decider labels every ticket and Bedrock isn’t called.
- BEDROCK:Sonnet 标记每张工单,但不会调用 Strands Decider。
- DUAL:并行调用 Sonnet 和 Strands Decider 模型。将 Sonnet 模型的结果应用于工单,并与 Strands Decider 的结果进行比较。
- DECIDER:Strands Decider 标记每张工单,不调用 Bedrock。
What we measured
我们测量的内容
| Claude Sonnet 4.6 | Strands Decider E4B | % Improvement | |
|---|---|---|---|
| Average time per call | 4,215 ms | 897 ms | 78% |
| Input tokens per ticket | 6,554 | 2,009 | |
| Output tokens per ticket | 170 | 1 | |
| Total tokens, per ticket | 6,724 | 2,010 | 70% |
| Claude Sonnet 4.6 | Strands Decider E4B | % 提升 | |
|---|---|---|---|
| 每次调用的平均时间 | 4,215 毫秒 | 897 毫秒 | 78% |
| 每张工单的输入 token 数 | 6,554 | 2,009 | |
| 每张工单的输出 token 数 | 170 | 1 | |
| 每张工单的总 token 数 | 6,724 | 2,010 | 70% |
The token drop had two sources. Strands Decider produced one output, the choice, instead of a JSON answer. Its prompt was also much shorter than Sonnet 4.6’s. Production’s label descriptions alone are longer than Strands Decider’s 4,096-token window, so we rewrote each of the 20 labels as a one- or two-sentence criterion and sent them as the options of a single choice question, plus a “none” option. The ticket data is the same as what Sonnet gets, except that on long tickets Strands Decider drops the oldest comments to fit.
Token 的减少有两个来源。Strands Decider 只产生一个输出,即选择结果,而不是 JSON 答案。它的提示词也比 Sonnet 4.6 短得多。生产环境中的标签描述本身就已经超过了 Strands Decider 的 4,096-token 窗口限制,因此我们将 20 个标签中的每一个重写为一到两句的标准,并将它们作为单个选择题的选项发送,外加一个“无”选项。工单数据与 Sonnet 获取的数据相同,只不过对于长工单,Strands Decider 会丢弃最旧的评论以容纳更多内容。
Below is a graph of our Lambda durations on the day we turned off the Sonnet usage, showing the average Lambda execution duration dropping 74%.
下图展示了我们在关闭 Sonnet 使用当天 Lambda 持续时间的情况,显示平均 Lambda 执行持续时间下降了 74%。
What it costs
成本分析
At published us-east-1 on-demand prices:
按 us-east-1 地区的公开按需价格计算:
| Claude Sonnet 4.6 (Bedrock, global endpoint) | Strands Decider E4B (SageMaker, ml.g5.xlarge) | |
|---|---|---|
| Price | $3.00 per 1M input, $15.00 per 1M output tokens | $1.408 per instance-hour |
| Per ticket | $0.0222 | about $0.0005 |
| Per million tickets | about $22,200 | about $500 |
| Claude Sonnet 4.6 (Bedrock, 全局端点) | Strands Decider E4B (SageMaker, ml.g5.xlarge) | |
|---|---|---|
| 价格 | 每 1M 输入 token $3.00,每 1M 输出 token $15.00 | 每个实例每小时 $1.408 |
| 每张工单 | $0.0222 | 约 $0.0005 |
| 每百万张工单 | 约 $22,200 | 约 $500 |
Sonnet’s cost per ticket comes straight from the token counts above. Strands Decider’s depends on how busy each instance is. At about 640 ms per request, one instance can handle about 5,600 tickets an hour, which would be $250 per million tickets at full use. We keep headroom for bursts, and in practice it comes to about $500 per million. That is about 44 times cheaper than Sonnet, a 98% reduction.
Sonnet 的单张工单成本直接来自上述 token 计数。Strands Decider 的成本取决于每个实例的繁忙程度。按每次请求约 640 毫秒计算,一个实例每小时可以处理约 5,600 张工单,在全负荷使用时,每百万张工单的成本约为 $250。我们为突发流量保留了余量,实际上每百万张工单的成本约为 $500。这比 Sonnet 便宜约 44 倍,减少了 98%。
These are published list prices. They leave out the Lambda, which also runs for less time per ticket now.
这些是公开的列表价格。它们未包含 Lambda 的费用,而 Lambda 现在每张工单的运行时间也更短了。
One thing that surprised us was that JSON key order changed the answer. Sending the same content with keys in a different order moved the output probabilities by up to 0.19. We now send every request with sorted keys, so if you serve a decision model behind an API, check this before you compare runs.
令我们惊讶的一点是,JSON 键的顺序会影响答案。以不同顺序发送相同的内容会使输出概率变化高达 0.19。我们现在对所有请求都发送排序后的键,因此如果你通过 API 提供决策模型服务,请在比较运行结果之前检查这一点。
Our lessons
我们的经验教训
This worked because the task is a closed choice from a known catalog, the volume is high, and the latency of the old path mattered. If your labels need explanation text, if the catalog changes weekly, or if you can’t fit the useful context into a few thousand tokens, a decision model probably can’t replace the LLM’s job.
这一方案之所以奏效,是因为该任务是从已知目录中进行的封闭式选择,数据量庞大,且旧路径的延迟至关重要。如果你的标签需要解释性文本、目录每周更新,或者无法将有用的上下文压缩到几千个 token 以内,那么决策模型可能无法取代大语言模型(LLM)的工作。
The part we’d copy regardless of model is the three-way switch. Running both on real traffic, then judging every disagreement, told us more than any offline eval would have. It also meant going back was a 45-second config change.
无论采用何种模型,我们都会保留三路切换机制。在真实流量上同时运行两者,并对每一个分歧进行评判,这比任何离线评估都能提供更多洞察。这也意味着回滚只需进行一次耗时 45 秒的配置更改。
The world of agents gets a lot more exciting (and less costly) with decision models. If you’re running a classification agent, try the Strands Decider repo and its serving notes.
有了决策模型,智能体(agents)的世界变得更加令人兴奋(且成本更低)。如果你正在运行一个分类智能体,可以尝试 Strands Decider 仓库及其部署说明。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力