GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
arXiv preprint

FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance

Ask a cheap model first and escalate only when a small scorer doubts its answer. On a news task this matched GPT-4 at 2% of the cost, because cheap models are sometimes right where GPT-4 is wrong.

Breakdown by FDE Interviews · 11 min read · Updated

About the original · 2023
AUTHORS
Chen, Zaharia, Zou
FROM
Stanford University
PUBLISHED
May 2023 · arXiv preprint
CITED BY
1,156Semantic Scholar · Oct 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 17% of this breakdown.

01

The paper in one minute

In early 2023, a company could call a dozen LLM APIs whose prices differed by two orders of magnitude: 10 million input tokens cost $30 on GPT-4 and $0.20 on GPT-J hosted by Textsynth. The paper's example: a customer-service bot answering 360,000 questions a month with 1,800-token prompts on GPT-4 costs about $21,000 a month.

The authors sort ways to spend less into three families. Prompt adaptation shrinks what you send: fewer in-context examples, or several queries sharing one prompt. LLM approximation replaces the expensive call: cache answers to similar queries, or fine-tune a small model on the big model's outputs. LLM cascade chooses which model answers each query.

FrugalGPT implements the cascade. Queries go through an ordered list of APIs. After each answer, a small scoring model (a DistilBERT regressor trained on labeled examples) estimates whether the answer is correct; if the score clears that step's threshold, the answer is returned, otherwise the next API is asked. The list (up to three APIs) and the thresholds are chosen on labeled training data to maximize accuracy under a budget, with a search pruned to model combinations that disagree often enough to be worth combining.

On HEADLINES (gold-price direction from news headlines), the learned cascade was GPT-J, then J1-Large, then GPT-4, with thresholds 0.96 and 0.37. It reached GPT-4's accuracy for $0.6 instead of $33.1, and at one-fifth of GPT-4's cost it was 1.5% more accurate. The reason is complementarity: on about 6% of HEADLINES queries, GPT-4 is wrong and a cheap model is right. Across three datasets, savings at equal accuracy were 59% to 98%.

THE IDEA, VISUALLY
THE LEARNED CASCADE ON HEADLINES (FIGURE 3) query GPT-J score > 0.96? yes: return answer no J1-Large score > 0.37? yes: return answer no GPT-4 always answer scorer: a DistilBERT regressor trained to predict whether an answer is correct from the query and the answer; list and thresholds chosen on labeled data under a budget TWO OTHER LEVERS (SECTION 3) prompt adaptation: fewer in-context examples, several queries sharing one prompt LLM approximation: cache answers to similar queries, fine-tune a cheap model on an expensive model's answers COST TO MATCH THE BEST SINGLE MODEL (TABLE 3) HEADLINES (GPT-4) $33.1 $0.6 (98% less) OVERRULING (GPT-4) $9.7 $2.6 (73% less) COQA (GPT-3) $72.5 $29.6 (59% less) API PRICES SPREAD ~150x (TABLE 1, MARCH 2023) USD per 10M input tokens / 10M output tokens GPT-4 30 / 60 GPT-3 (175B) 20 / 20 J1-Jumbo 0 / 250 + $0.005 per call ChatGPT 2 / 2 GPT-J (Textsynth) 0.2 / 5 AT A FIFTH OF GPT-4'S COST (HEADLINES) budget $6.5: 80% cheaper than GPT-4 and 1.5% more accurate; cheap models are right on about 6% of the queries GPT-4 gets wrong, so mixing can beat the best model 12 APIs from 5 providers; cascades of length 3
An LLM cascade asks cheap models first and stops as soon as a small scorer trusts the answer, so expensive models only see the queries cheap ones get wrong.
Research notes: the problem, approach and results
98%

lower cost than GPT-4 at GPT-4's accuracy on HEADLINES, a gold-price news classification task ($33.1 to $0.6)

59-98%

cost saved while matching the best single API across HEADLINES, OVERRULING and CoQA

~150x

price spread for input tokens across the 12 APIs in March 2023 ($0.2 to $30 per 10M tokens)

THE PROBLEM

LLM APIs differed in price by up to two orders of magnitude in 2023 (GPT-4 cost 150 times GPT-J per input token), and high-volume applications sent every query to the best, most expensive model.

THE IDEA

Three ways to cut cost: shorter or shared prompts, cheaper approximations (caching, fine-tuning a small model on a big one's answers), and an LLM cascade. FrugalGPT implements the cascade: query a list of APIs in order, score each answer with a small trained model, return it once the score passes a learned threshold; the list and thresholds are optimized on labeled data under a budget.

THE RESULT

On three classification-style datasets with 12 APIs, FrugalGPT matched the best single model's accuracy at 59-98% lower cost (GPT-4 on HEADLINES: $33.1 to $0.6), or improved on it by up to 4-5% at the same cost.

02

Why it matters to an FDE

Cost is usually what stops an LLM pilot from scaling. The cheapest fix rarely involves new infrastructure: route easy requests to cheap models and keep the expensive one for the rest.

Start with labeled data from the customer's traffic. The cascade's thresholds and the scorer are trained on labeled examples from the same distribution. Without them, savings are guesses.

The scorer is the product. Everything depends on a cheap model that can tell when a cheap answer is wrong. In the paper's setting answers are short labels, which makes scoring easy; for open-ended answers it is much harder.

Use all three levers. Prompt trimming and caching often save more with less risk than routing, and they compound with a cascade.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 149 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    Pricing quirks, complementarity, the cascade's parts, its limits and three misreadings

    Free account
  2. 04How it works

    The cost model, the cascade loop, the scorer, the optimizer and the experimental setup

    Premium
  3. 05The numbers that matter

    Prices, savings at equal accuracy, the HEADLINES case and complementarity

    Premium
  4. 06Try it yourself

    Redo the cost arithmetic, price one query across 12 APIs, and train and stress a cascade

    Premium
  5. 07Where it breaks

    Short-answer tasks, labeled data needs, scorer drift, latency, stale prices and slips

    Premium
  6. 08Using it on a deployment

    Collecting labels, building a scorer, setting thresholds, and monitoring for silent failure

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →