Skip to content

LLM into Code: Intelligence without a GPU

By Yair Alon, Ashwin Baluja, Michele Covell, Nash Luxsuwong, and Saurabh SinghAuthors are listed in a random order that changes on every visit.

November 24, 2026


Using LLMs for every decision is not only expensive but also non-deterministic. However, in the past few years, LLMs are now an integral part of various enterprise systems for high-volume tasks such as ticket routing, claim tagging, and complaint triage. For these, and many other common tasks, there are much simpler methods that rely on well-studied and well-understood machine learning algorithms.
We show how, during design, the Poetiq Metasystem can be used to distill the knowledge of LLMs into executable code that makes the decision directly.
During deployment, an LLM is invoked only as a fallback for inputs that the code cannot resolve. We call this distillation “reducing to code.”

Why reduce to code?

In enterprise settings, there are numerous reasons to prefer code to LLM calls.
  • Cost and Latency. Cost and response latency are the most obvious motivations. For high-throughput applications, rising token costs and uncertain latencies can make large-scale deployments challenging.
  • Consistency. An LLM may return different outputs for the same input, shift behavior when the provider updates the underlying model, and respond differently to minor changes in prompt wording. Code can be deterministic: the same input always produces the same output, and the classifier validated during testing is exactly the one running in production. Also, code can be unit-tested, version-controlled, and rolled back.
  • Understandability. When a decision is wrong, a code-based classifier can be inspected directly. You can trace a wrong decision to the logic that produced the result, fix that logic, and explain the outcome to a customer, an operator, or an auditor.
  • Privacy. The data processed by code never leaves the organization’s own infrastructure; third parties never have access to that potentially personal or private data.
  • Availability. Even with budget in hand, getting enough GPU capacity to run a high-volume workload can be hard: GPUs are scarce, and providers enforce rate limits and quotas. Code needs no GPU and runs in microseconds on commodity CPUs, often on hardware that is already there.

What can be reduced to code?

A substantial share of enterprise LLM usage consists of selecting among a fixed set of options given an input, such as determining the product category of a consumer complaint or routing a query to the appropriate model. Once a task is expressed in this form, it becomes a candidate for reduction to code, with an LLM retained only for the cases the code cannot confidently resolve. Even tasks that are less obviously classification problems (such as WikiRacer) often can be cast as a sequence of closed-set selection processes.

How?

When asked to optimize for cost, the Poetiq Metasystem automatically decides which aspects of the classification/decision problems are better represented as code vs answered via LLM.
The move to code is an emergent property of the Poetiq Metasystem. The Metasystem was not instructed to write rules in code. Its code-writing behavior emerged organically once cost was incorporated into the objective. The Metasystem was simply given labeled examples and a score that penalized expenditure. That penalty alone pushed the optimization to move decisions into code while maintaining quality.

Two tasks, three decisions

We show this on two tasks: ticket routing for consumer complaints, and path finding in WikiRacer. Between them, they require three kinds of decisions. Each task starts from a harness where a model makes every decision, and each is scored with a penalty for what the model costs.
  • Categorization (Task 1, Consumer Complaints): which product is this complaint about? Code answers the complaints it is confident about and passes the rest to a model.
  • Model routing (Task 1, Consumer Complaints): which model should answer the complaints the code passes on? Code picks a model based on the kind of complaint, and it is trained together with the categorization code.
  • Sequential selection (Task 2, WikiRacer): which link should be clicked next for a short path between pages? Here the secondary cost is time, not dollars: how long does it take to find that path?

Task 1: Consumer Complaints

The U.S. Consumer Financial Protection Bureau (CFPB) publishes complaints about financial companies, including the consumer’s narrative about what went wrong. The classification task is to take in the consumer narrative and decide which of five financial products it refers to: checking/savings, credit card, debt collection, money transfer, or student loan.1

Jointly Training For Two Code-Based Decisions

Starting with a harness that makes a single LLM call per complaint, we applied the Metasystem to optimize it with an objective that penalizes cost. Answers from code are free while LLM calls are penalized according to their actual cost. Across several runs, the Metasystem consistently chose to use a statistical model, also choosing a fallback LLM2 for each problem that could not be confidently resolved with code. Note that the code and routing parts of the solution depended on each other: whether the code should answer a complaint depended on which LLM would answer it instead, and which LLM would be worth paying for depends on the type of complaint the code could not answer. Both decisions came from one Python function, and they were trained jointly, without manual intervention.

Results

In Figure 1, we show each LLM alone along with the code+routing classifiers that are on or near the Pareto frontier.
Code+Routing beats every LLM alone. From the cheapest classifier to the most accurate, every point on the Pareto frontier is code that routes.3 Each LLM alone sits below or to the right of the frontier. For about a fifth of DeepSeek's 47¢ (10¢), one solution reaches 94.08%, a 1.56% improvement over DeepSeek. The same point is more accurate than Luna's 93.34% at less than half the cost. One solution matches Gemini-alone accuracy (94.08) at under 2% of its cost. At one frontier extreme, a code (plus unused routing) solution matches Jev's accuracy for free instead of 8¢. At the other extreme, a code+routing solution bests Opus's 95.06% for $41.41 instead of Opus's $61.25.
The starting point matters little. A run, started from Jev as the fallback LLM, ended on the same frontier as the other routing runs. Its code solved 92% of the complaints and routed most of the rest of the complaints to Luna and DeepSeek, sending only 1% to Jev. This solution reached 92% accuracy for 2¢, very close to another Pareto point that started from Gemini. The cost weighting, not the starting LLM, decided where each run ended up.

Accuracy on holdout set

100% code 99% code, 1% Jev 97% code, 3% Jev 85% code, 12% Luna, 3% Jev 76% code, 24% Luna 69% code, 16% DeepSeek, 15% Luna 69% code, 15% Luna, 9% DeepSeek, 7% Gemini 45% code, 25% Luna, 18% Gemini, 11% DeepSeek, 0.9% Jev, <0.1% Opus 51% code, 15% Gemini, 13% Luna, 12% DeepSeek, 6% Opus, 3% Jev 42% code, 45% Opus, 13% Gemini Jev alone Luna alone DeepSeek alone Gemini alone Opus alone $0 $0.0001 $0.001 $0.01 $0.10 $1 $10 $100 90%91%92%93%94%95%96% LLM cost (log scale) Accuracy on holdout set

Code + routing, on the frontier Code + routing, off the frontier One model alone (hover for range) Frontier, randomly mixing the two neighboring solutions

Figure 1: Accuracy and cost on the holdout complaints, using jointly learned code-based classification and routing of those complaints that the code did not categorize. The labels show the percentage of complaints handled by code and the percentage sent to each model based on the routing decisions. Some sub-Pareto solutions are marked to show that our solution set is not brittle: if any of the current best solutions were not found, the loss in performance would be small. The curved appearance in Pareto lines is due to the log scaling on the cost axis.

A Look Inside

The Metasystem jointly designed the product-classification and routing systems.
For the product classification, our Metasystem combines a statistical model (logistic regression over word features) and a decision tree (see example below). The paired statistical and decision-tree models whether the code is sure enough to answer by itself.
The only LLM call is the one the router chose; Gemini, the default fallback LLM for the run, would have given the same answer for 78 times the price. Taken from the point on the Pareto hull at 94.96% accuracy and $8.94 cost (“51% code, 15% Gemini, 13% Luna, 12% DeepSeek, 6% Opus, 3% Jev”)
Routing, when needed, is done by a decision tree which chooses an LLM based on the kind of complaint. These routing rules include:
  • Relating to money movement or scams → Luna. Keywords: transfer, wire, Zelle, ACH, electronic funds, Regulation E, crypto, bitcoin, Coinbase, wallet, scam, impersonation. With these keys, Luna gets the product right as often as Gemini does, at 4% of the price.
  • Relating to banking or credit reporting → DeepSeek. Keywords: bank, checking, savings, debit, deposit, direct deposit, payroll, Social Security, benefits, unemployment. These often involve several products at once, but a cheap model gets most of them right. Gemini would cost over 12 times as much for little or no gain in accuracy.
  • Relating to legal or prepaid issues → DeepSeek. Keywords: UCC, holder in due course, notice of understanding, prepaid, Netspend, Direct Express. These cross product boundaries.
  • Relating to overdrafts → Jev. Keywords: overdraft, insufficient funds, NSF. These are usually clear-cut, but some turn out to be about a collector or a credit card.
There was no human intervention in the design of the product classifier or the router. The Metasystem chose the features, fit the weights, and set the thresholds. It documented its design decisions so that its reasoning can be inspected. The product classifier and the router were trained together, each is tuned to the other: whether the code should answer depends on who would otherwise answer.

Ablation Study: Classification without Routing

We investigated how much of the cost savings is due to using code and how much is due to routing. We reran the Metasystem from scratch to solve this task, but restricted it to only use a single model on each run. On the peak accuracy parts of the Pareto frontiers, code answered most of the complaints on its own and was right on more than 95% of those. Figure 2 shows cost and accuracy for the discovered solutions with each of the five fallback models.
Claude Opus 5.5 (max)

Accuracy on validation set

Opus alone 96–99% code 66–77% code 28–50% code $0 $10 $20 $30 $40 $50 $60 $70 90%91%92%93%94%95%96% LLM cost Accuracy on validation set

Code + Opus, on the frontier Code + Opus, off the frontier Opus alone (hover for range) Frontier of cost against accuracy

Figure 2: Accuracy and model cost on the validation complaints. Each tab shows one fallback model, on the same accuracy scale. Rings are classifiers that combine code with the model, larger where they sit on the frontier, and the gray dot is the model alone.

Code+LLM can beat the LLM alone for a fraction of the price, without loss of accuracy. With all 5 fallback models, using code as a first step matches or improves accuracy at a lower cost. The most extreme improvement is with Jev. When the code decides 78% of the complaints, the combination of code+Jev is more accurate than Jev alone (91.4% vs. 90.9%) at less than a quarter of the cost. Even when the code decides 99% of the complaints, it gives up only 0.6 points and costs less than 1% of the Jev-only bill.
Jev provides the most extreme example of how many decisions we can move into code without a loss in accuracy. In contrast, on the other extreme in fallback-LLM accuracy, we can only move 45% of the problems to code-based classification without a loss in accuracy. Even so, across all of the fallback LLMs, making around three quarters of the decisions in code reduces accuracy by less than a point.

Task 2: WikiRacer

Many problems in the real world require a sequence of decisions, often with latency requirements. A good solution not only solves the problem, but does so while taking as little time as possible. We use the WikiRacer benchmark as a testbed for our Metasystem and demonstrate that it can produce harnesses that are not only more accurate, but more efficient.
The WikiRacer benchmark uses both solution quality and latency in finding that solution as its criteria. The game is simple: given two random Wikipedia pages, quickly find the shortest path from one to the other by clicking links. The model is allowed to read only the title and summary of the start and target pages. It is given a list of the outgoing links from the current page to select from, as well as a list of the pages it has already visited. At each step, it picks one link and repeats until it reaches the target page.
This is a natural use case for decision models like Jev: every step consists solely of picking one option from a given set (in this case a set of links) and decision models do this very quickly. But under our latency-constrained setting, even the relatively-quick Jev noticeably hurts the total time.
We gave the Jev-based model to our Metasystem and optimized it to find shorter paths more quickly. Just as optimizing for cost pushed classifications of some complaints to code, here optimization pushed some of the link selections into Python code. The code drops links that cannot help, such as pages already visited, and picks the link itself when Wikipedia’s structure makes the answer obvious: for example, to reach “1987 in Brazil”, it steps through neighboring years like “1986 in Brazil”, which is likely to link to the target.

Hops saved vs. Jev alone (higher is better)

1.91 s, 12% fewer hops $0.08 LLM cost, 66% code 2.38 s, 37% fewer hops $0.26 LLM cost 2.82 s, 24% fewer hops $0.31 LLM cost 1.76 s, 33% fewer hops $0.28 LLM cost, 32% code 2.36 s, 39% fewer hops $0.33 LLM cost, 1% code Jev alone 4.15 s, 41.7 hops 1.5 2.0 2.5 3.0 3.5 4.0 0%10%20%30%40%50% Decision seconds per race (lower is better) Hops saved vs. Jev alone (higher is better)

Poetiq solution, on the frontier Poetiq solution, off the frontier Jev alone Frontier of hops saved against decision time

Figure 3: Hops saved relative to Jev alone against decision time per race, excluding the time spent loading Wikipedia pages (a race that hits the 100-hop cap counts as 100 hops).
As Figure 3 shows, the resulting Poetiq frontier dominates the Jev-only baseline. While plain Jev averaged 41.7 hops and spent 4.1 seconds per race making decisions, our solutions took 33% to 39% fewer hops and spent 1.8 to 2.4 seconds, at about half of Jev’s cost, with code alone choosing up to 32% of the links.

Conclusions

The two tasks asked for three different decisions: which product a complaint is about, which model should answer a question, and which link to click next. Each task started with a model making every decision. Each went to the Poetiq Metasystem with a score that was penalized by what those models cost, in dollars or in seconds. And each time, the optimization moved the routine decisions into code and kept the LLM for the hard ones. We did not ask the system to write code, nor did we give hints as to what type of statistical classifier to use, if it chose to use one. The resulting systems not only decreased the explicit cost (latency or spend), but also the other cost (optimizing for latency reduces the spend and vice versa).
LLMs offer a straightforward and effective tool for addressing enterprise decision-making tasks. Nonetheless, incorporating them directly into production pipelines can be inefficient. Allowing LLMs to construct systems that minimize their own role in production can yield benefits in both cost and accuracy.

Optimize With Us.

Poetiq is a rapidly growing technical team with backgrounds from Google, DeepMind, Apple, Microsoft, and ByteDance, all focused on the goal of creating AI systems that rapidly improve themselves.
Running a classification workload that is running up an LLM bill? We would like to hear from you. And if you want to be a part of the team, please join us.
Poetiq technology by: Yair Alon, Ashwin Baluja, Shumeet Baluja, Michele Covell, Benjamin Darnell, Ian Fischer, Michael Hale, Nash Luxsuwong, Matteo Simone, Saurabh Singh, and Stanley YangNames are listed in a random order that changes on every visit.
1 The set we use is a sample of the 568,887 complaints with narratives balanced across the five product areas (checking/savings, credit card, debt collection, money transfer, or student loan). ↩
2 The models that were available as fallbacks were (from most to least expensive): Claude Opus 5.5 (max), Gemini 3.6 Flash (high), DeepSeek V4 Flash (0731), GPT-6 Luna (low) and Jev 1.13 (Typesafe). Unlike the other four models, Jev is a decision model, not an LLM. ↩
3 The 100% code point is a degenerate version of this: it would have routed, if any of the complaints had not been handled by the code. ↩