---
id: 17146
lang: en
title: "AWS: If Code Handles 95% of Requests, Only One in Twenty Reaches an LLM"
published_at: "2026-11-21 01:58:00"
source_name: "AWS Machine Learning Blog"
source_url: "https://aws.amazon.com/blogs/machine-learning/cut-generative-ai-costs-code-for-rules-models-for-judgment/"
canonical_url: "https://news.hamidun.com/en/news/17146"
categories: ["llm", "business"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# AWS: If Code Handles 95% of Requests, Only One in Twenty Reaches an LLM

> **Краткая суть (BLUF):** Many teams send everything through an LLM, even format checks and routing decisions, and at production volumes that gets expensive. AWS advises asking whether a model is needed at each step. A message containing the word "refund" can be caught by a plain rule in milliseconds. In AWS's illustrative calculation, if rules handle 95% of requests, only 1 in 20 reaches the model, so savings should start with an audit of each step.  • Format, schema, keyword and range checks run in code in milliseconds • Choosing from a list is handled by a narrow call with an "unsure" option and escalation • A new model is first run against a benchmark set of tasks in CI

Picture a support assistant where every incoming message first goes to a large language model: check the order number, work out that the customer is asking about a refund, reformat the request. Each call costs pennies, but at production volumes those pennies add up to one of the biggest line items in the budget. AWS Machine Learning's blog published a breakdown built on a simple idea: first ask whether a model is needed at this step at all. If the message contains the word "refund", a plain rule will catch it in a few milliseconds. Suppose such rules handle 95% of requests. Then only 1 request in 20 reaches the model, and that is before you even start choosing a cheaper model. AWS itself stresses that the 95% figure is illustrative arithmetic, not a measurement from a real system.

## Why unnecessary model calls are expensive

AWS names three costs of an unneeded LLM call. The first is money: spending grows with the number of requests, even when the step adds no meaningful value. The second is latency: each call in a chain adds hundreds of milliseconds, and those add up. The third is unpredictability: the same input string can produce different answers. Temperature 0 reduces variability but does not guarantee an identical result. As a result, tests are harder to write and audits take longer.

In this comparison, ordinary code wins. It costs orders of magnitude less and responds in milliseconds. The rule lives in version control and can be shown to an auditor. Its behavior does not change unless you change it, whereas a model drifts when moved to a new version or when an old one is retired. That is why regulated industries tend to prefer rules.

## Three questions for every step

The authors suggest running each workflow step through three questions in order and stopping at the first one that applies.

1. Can success be verified with a rule: format, schema, keyword, range? If a rule covers only some cases, it goes first (the "fast path"), and the remainder is passed on.
2. Can a model write the rule once, for example a regular expression or a JSON schema? Then you verify the result, commit it to code, and from then on it runs at the speed and cost of code.
3. Is the output one answer chosen from a predefined list: a support queue, a class, yes/no? For this you need a narrow call with constrained output and a signal for when to escalate.

If the answer to all three is no, the task is open-ended, and a model of suitable size is brought in. This is the smallest model in Amazon Bedrock that clears your quality threshold.

In the support assistant example, this looks as follows. Order-number format is checked by validation in API Gateway or Lambda. Words like "refund" are caught by a Choice state in Step Functions using JSONata. The tracking number from the carrier's email is extracted by a regular expression that a model drafted first. One of four queues for the ticket is selected by a narrow call, and when the model is unsure, the ticket goes to a larger model. The reply to the customer is written by a model of suitable size.

## How to handle selection from a list without breaking quality

For these steps, AWS describes four options. A small model in Bedrock with structured outputs, where the answer is limited to an enumerated set of options plus "unsure". Nearest-neighbor lookup of a labeled example using embeddings. The experimental Strands Decider model under Apache 2.0, which you must host yourself, for example on SageMaker. According to its README, answers with 90% confidence or higher are correct in about 95% of cases on short classification tasks, but the result has to be verified on your own data. And a classifier trained on SageMaker. In every case, the escalation threshold has to be tuned on your own labeled sample. Authorization decisions, such as a refund limit, stay in rules.

The approach has its own risks. A generated regular expression needs testing on malicious inputs: nested quantifiers such as (a+)+ open the door to ReDoS, where matching hangs on a specially crafted string. If rules live in configuration, allow only known primitives and never execute arbitrary code from config.

## Where to start

AWS recommends four steps. Classify each call as code, a narrow decision, or a model, and calculate the cost per successful result. Move rules into Lambda or Step Functions, which is usually the largest and safest saving. For selection from a list, add calls with escalation. And keep a benchmark set of examples for each task in CI: a cheaper model that falls below the quality threshold counts as a regression. It is also worth putting the model behind a configuration flag so the replacement can be rolled back. In addition, it helps to run some of the requests that rules already resolve through the model in shadow mode: disagreements will show which steps need reclassifying.

The practical takeaway is simple: first ask whether a model is needed, and only then choose which one. Start with your single heaviest workflow and see what share of its calls never needed an LLM.

---
- **Первоисточник:** [AWS Machine Learning Blog](https://aws.amazon.com/blogs/machine-learning/cut-generative-ai-costs-code-for-rules-models-for-judgment/)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/17146
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
