Concepts / Latency Metrics for Foundation Models

Latency Metrics for Foundation Models

Output length is the lever that moves total latency most directly. If a response finishes too slowly, shortening the output is often the first thing to examine, before changing models.

  • Programming

When a Strong Model Still Fails

Picking a foundation model is easy to get wrong if you judge it by one number. Imagine a model whose answers are excellent but which takes so long to respond that users give up before it finishes. Now imagine a model that answers quickly and well but costs so much per request that the product cannot pay for itself. In both cases the model is a poor choice, even though its raw quality looks impressive on paper.

Evaluating a model therefore means keeping three forces in view at the same time: the quality of what it produces, how long users wait for it, and what it costs to run. This article follows how those three forces interact, which latency metrics describe the waiting part of the experience, and how to make a sensible choice among them.

Following One Response Through Time

Latency sounds like a single quantity, but for foundation models it is measured in several ways. Each metric captures a different part of the experience a user has while waiting. Read the timeline below from left to right: a request is sent, the first token arrives, further tokens follow one after another, and the response finishes with its final token. Each metric covers a different stretch of that path.

Request sentuser submits promptFirst tokenfirst words appearLater tokensone token after anotherFinal tokenresponse completetime to first tokentime between tokensremaining tokens
Which stage of waiting does each latency metric measure, and how do they add up from the moment the request is sent to the final token?

What do you think happens?

Two requests go to the same model. One asks for a one-line answer and the other asks for a long multi-paragraph report. Which request has the longer total wait, and why?

  • The one-line answer, because the model has to think harder about short questions

  • The long report, because it requires many more tokens to be generated one after another

Reveal answer
Answer:

The long report has the longer total wait, because the model generates output one token at a time and each new token takes its turn after the previous one.

Autoregressive language models produce output token by token, so the more tokens the model must generate, the longer the whole response takes to finish. Output length is a central driver of total latency.

Latency Metrics and What Drives Each

The common metrics are separated by the part of the response they describe. A streaming chat interface cares a great deal about when the first words appear, while a batch report generator may care only about when the entire response is finished. Choosing the right metric depends on what your application is trying to protect. The three metrics below are the ones you will meet most often.

What Controls the Wait

Latency is not a fixed property of a model. It also depends on the prompt that is sent and on the sampling settings used to generate output. Output length is the most direct driver, because each extra output token adds generation work before the response can finish. That gives builders a practical lever: the wait a user observes can be shaped by how the request is written and how generation is controlled.

  • Careful prompting can ask the model to be concise, which shortens the output and therefore the total wait.
  • A stopping condition for generation can end the output at a defined point rather than letting it run on.
  • Other optimization techniques can also reduce the time a response takes.
  • In every case the aim is to control the latency that users actually observe, not an abstract figure.
Key point

Output length is the lever that moves total latency most directly. If a response finishes too slowly, shortening the output is often the first thing to examine, before changing models.

Filtering Before Comparing with Pareto Optimization

Optimizing several objectives at once is a field of study known as Pareto optimization. The core technique is to rank your objectives by how firm they are. A firm objective acts as a filter: any candidate that fails it is removed outright. Only after filtering do you compare the surviving candidates on the softer objectives.

This ordering matters. If you compare everything on one blended score, a strong result on one dimension can quietly excuse a failure on a dimension you cannot give up. Ordering the objectives stops that from happening: a model that breaks a firm requirement never reaches the comparison stage, however good its other numbers look.

Worked example

Filtering three candidate models

A team needs a chat assistant. Firm requirement: the first words must appear quickly enough for a live conversation. Soft goals: higher answer quality and lower cost per request. Three candidates are under review.

  1. 1
    Apply the firm requirement first

    Candidate C fails the firm response-speed requirement, so it is removed outright, even though it has the best quality on paper.

  2. 2
    Compare the survivors on soft goals

    Candidates A and B both pass. Candidate A gives somewhat better answers, while candidate B costs less per request.

  3. 3
    Decide whether the trade is worth making

    The team looks at what the application needs. If cost pressure is high, a slightly weaker but cheaper model like B may be the deliberate choice.

Result

Candidate C is eliminated by the firm requirement, and the final choice between A and B depends on how the team weighs the remaining soft goals.

Where Cost Comes From: Tokens and Deployment

The source of cost depends on how the model is delivered. The two main routes are calling a model through an API and hosting your own model. The diagram below contrasts what you pay for in each case. The cost of an API is tied to tokens, while the cost of self-hosting is tied to compute.

Input and outputtokensevery token raises the billComputemachines that run the modelCost per tokenstays fairly steady asvolume growsFixed memory sizeshapes which models fitCost per tokencan drop as volume grows
How do the cost components differ between paying per token through an API and running the model on your own infrastructure?

Why Scale Flips the Economics

Scale changes which delivery approach is cheaper. With a model API, the cost per token stays fairly steady as your volume grows, so the total bill rises in direct proportion to usage. With a self-hosted model, the cost per token can drop substantially as volume grows, because the compute spending is largely fixed once a cluster is in place.

Worked example

A self-hosted cluster at two volumes

Suppose you have already built a cluster able to serve one billion tokens a day. Compare the per-token cost of serving one million tokens a day with serving one billion tokens a day.

  1. 1
    Identify the fixed cost

    The cluster is already built, so its compute cost is the same whether you serve one million tokens or one billion.

  2. 2
    Spread the fixed cost over each volume

    A fixed cost divided by one million tokens yields a much larger per-token figure than the same cost divided by one billion tokens.

  3. 3
    Compare the results

    The per-token cost at the lower volume is far higher, so an underused cluster is an expensive way to serve tokens.

Result

Self-hosting is only cheap per token when the cluster is kept busy. At low volume the same fixed compute spreads over very few tokens.

Because the economics shift with scale, the choice between an API and self-hosting is not permanent. Companies need to reconsider it as their usage changes. For an API, the scale criterion has an extra dimension: the service must be able to handle your volume at all, not just at a reasonable price.

Building a Criteria Table

Turning the three forces into something you can check requires writing criteria down. A criteria table lists each dimension, the metric used to measure it, a benchmark that supplies the test conditions, a hard requirement that a model must meet, and an ideal target that a model should aim for. The table below is an illustrative example for a hypothetical chat application.

DimensionMetricBenchmarkHard requirementIdeal target
Response speedTime to first tokenFixed set of chat promptsMeets the agreed live-conversation thresholdFaster than the threshold with margin
Answer qualityTask accuracyInternal evaluation setMeets the minimum accuracy the product needsHighest accuracy within budget
CostCost per requestProjected monthly token volumeFits the product budgetLowest cost that keeps quality
Total waitTime per queryTypical output lengthCompletes within the time users will tolerateShortest completion time

Illustrative criteria table for a hypothetical chat application

Applying the Two-Step Selection Process

Once the criteria are written, selection proceeds in two stages. The first stage asks what the best achievable performance is, meaning how well the strongest candidates can do on the quality measures that matter, and it applies the firm requirements to remove candidates that cannot meet them. The second stage places the remaining candidate models on a map whose axes are cost and performance, and picks the one that delivers the most performance for the money.

Written criteriatablemetrics, benchmarks,requirementsStage 1: bestachievableperformanceremove candidates failinghard requirementsSurviving candidatespass every firm requirementStage 2: cost versusperformance mapcompare the softer goalsChosen modelmost performance for themoneyRevisit as usagechangesAPI versus self-hosting mayflipapplyfiltercompareselectusage shiftsrestart
In what order are the hard requirements and softer goals applied, and how does each step narrow the candidate set? The path loops back to the start because the choice is revisited as usage changes.

The process is more nuanced than two stages suggest, and it does not happen only once. The right model can differ across adaptation techniques. When you use prompt engineering, you might begin with the strongest available model to test whether the task is feasible at all, then work backward toward smaller models to see whether they are good enough. When you finetune, you might begin with a small model so you can test your code cheaply, then move toward the largest model that still fits your hardware constraints, such as a single GPU.

Mistakes When Comparing Models

  • Common mistake

    Ranking models by quality alone

    What it looks like

    Choosing the model with the best answers even though it fails the response-time requirement.

    Why it fails

    A model that users abandon before it finishes does not serve the product, however good its answers are.

    Do this instead

    Apply the firm requirements first to filter candidates, then compare the survivors on quality.

  • Common mistake

    Blending all objectives into one score

    What it looks like

    Adding quality, speed, and cost into a single number and picking the highest total.

    Why it fails

    A strong result on one dimension can hide a failure on a dimension that cannot be given up.

    Do this instead

    Rank objectives by firmness, treat firm ones as filters, and only then compare on softer goals.

  • Common mistake

    Assuming latency is one fixed number

    What it looks like

    Reporting a single speed figure for a model without saying which part of the wait it measures.

    Why it fails

    Time to first token, time between tokens, and time per query describe different parts of the experience.

    Do this instead

    Name the metric and match it to what the application protects, such as first words for streaming chat.

  • Common mistake

    Forgetting that output length drives total wait

    What it looks like

    Requesting long answers for a task that only needs a short one.

    Why it fails

    Autoregressive generation produces one token at a time, so more output means a longer total wait.

    Do this instead

    Ask for concise output or set a stopping condition when a shorter answer will do.

  • Common mistake

    Treating the API versus self-hosting choice as permanent

    What it looks like

    Keeping a self-hosted cluster that sits underused after usage has fallen.

    Why it fails

    Self-hosted cost per token rises sharply at low volume, and the economics shift as usage changes.

    Do this instead

    Revisit the build-or-buy decision whenever usage changes significantly.

Trying the Selection Yourself

MEDIUM

A product team is choosing a model for an internal tool that produces long summaries of documents. Their firm requirement is that every summary completes within a time users will tolerate. Their softer goals are answer quality and cost. Two candidate models both pass the firm requirement. Model X writes higher-quality summaries but is slower to finish. Model Y is slightly weaker but finishes sooner and costs less per request. Which model should the team consider first, and what should they examine before deciding?

Hints
  • Start with the firm requirement, since it filters candidates before any soft goal is compared.
  • Consider which metric the firm requirement is really measuring: the wait for the whole summary.
  • Output length is a direct driver of total wait, so think about whether the summaries can be shortened.

Key Takeaways

  • Model quality must be weighed against latency and cost, because a model that is excellent but too slow or too expensive can still be a poor choice.
  • Latency has several metrics: time to first token describes the wait before output begins, time between tokens describes the gap between successive tokens, and time per query describes the whole response.
  • Output length drives total latency because autoregressive models generate one token at a time, so prompting for concise output and using stopping conditions can reduce the wait.
  • API cost scales with input and output tokens, while self-hosted cost is driven by compute and can fall per token as volume grows, so the build-or-buy decision must be revisited as usage changes.
  • Choose a model by writing a criteria table, filtering candidates with firm requirements first, and only then comparing the survivors on cost and performance.

Related concepts

More concepts starting with L