What you will be able to do
- Compare candidate LLMs on quality, cost and latency using one shared evaluation set and harness
- Define TTFT, TPOT, end-to-end latency and throughput and calculate latency from them
- Pick the smallest model that clears a measured quality bar, and assign different models to different pipeline steps
- Use architecture (mixture of experts versus all-parameter models) and context window size as quantitative inputs to model selection
Key concept
Threshold, then trade-off — First set a quality bar measured on your evaluation set. Among the candidates that clear it, pick the one with the best cost and latency, which is usually the smallest. Model size and architecture only matter through their effect on these measured numbers.
1.Quality, cost and latency as the comparison dimensions
Choosing an LLM is a measurement problem. A 70B model and an 8B model are not "better" or "worse" in general. Each one produces numbers on your workload, and you choose from those numbers. Databricks groups the numbers into three dimensions: quality (retrieval and response quality), cost (token consumption) and latency (how long the app takes to run). A model choice that only looks at quality leaves out two of the three numbers the business is paying for.
| Dimension | Metric | Measured by | Needs ground truth? |
|---|---|---|---|
| Response | correctness | LLM judge | Yes |
| Response | relevance_to_query | LLM judge | No |
| Response | groundedness | LLM judge | No |
| Response | safety | LLM judge | No |
| Cost | total_token_count, total_input_token_count, total_output_token_count | Deterministic | No |
| Latency | latency_seconds | Deterministic | No |
The two kinds of measurement behave differently. Cost and latency are deterministic: they come straight from the app's outputs and token counts, so two runs of the same model on the same inputs give comparable values. Quality mostly comes from LLM judges, where a separate model grades each response. When you swap the generator model, the judges stay the same. That is what keeps their scores comparable across candidates.
A fair comparison runs every candidate through one harness: the same evaluation set, the same scorers, and only the model changed. This is the same one-variable discipline as Comparing versions with one variable changed, applied to model size and architecture. mlflow.genai.evaluate() provides the harness. Its model_id argument lets you tag each candidate's run so the results sit side by side.
def mlflow.genai.evaluate(
data: Union[pd.DataFrame, List[Dict], mlflow.genai.datasets.EvaluationDataset], # Test data.
scorers: list[mlflow.genai.scorers.Scorer], # Quality metrics, built-in or custom.
predict_fn: Optional[Callable[..., Any]] = None, # App wrapper. Used for direct evaluation only.
model_id: Optional[str] = None, # Optional version tracking.
) -> mlflow.models.evaluation.base.EvaluationResult:Ground truth needs special care. Judges such as correctness grade each answer against a human-labeled expected answer (see Judges that require ground truth (expectations)). Their scores are only comparable if every candidate is graded against the same labeled rows. If the 8B model is scored on 40 labeled questions and the 70B model on a different 40, the gap between them measures the question sets as much as the models. Databricks recommends at least 30 questions, ideally 100–200. It also recommends a held-out test and validation split, so that the winning model isn't chosen by overfitting to one set of questions.
Checkpoint 1 of 9· Check yourself
A team compares Llama 3.3 70B and Llama 3.1 8B as the generator for their app. They report only correctness and groundedness scores from LLM judges. Which part of the recommended comparison is missing, and how is it measured?
Databricks compares app versions on quality, cost and latency. Cost (token counts) and latency (latency_seconds) are deterministic metrics taken from the app's outputs, not LLM-judge scores. If you look only at quality, you leave out two of the three dimensions.
“Cost and latency metrics can be computed deterministically based on the application's outputs.”Source: docs.databricks.com
Checkpoint 2 of 9· Fill the gap
You run the 8B and 70B candidates through the same data and scorers. Which parameter tags each run with the version that produced it, so the results sit side by side?
def mlflow.genai.evaluate(
data: Union[pd.DataFrame, List[Dict], mlflow.genai.datasets.EvaluationDataset], # Test data.
scorers: list[mlflow.genai.scorers.Scorer], # Quality metrics, built-in or custom.
predict_fn: Optional[Callable[..., Any]] = None, # App wrapper. Used for direct evaluation only.
? : Optional[str] = None, # Optional version tracking.
) -> mlflow.models.evaluation.base.EvaluationResult:In mlflow.genai.evaluate(), model_id is the optional argument for version tracking. You keep data and scorers the same for every candidate and tag each run with its model_id, so the only thing that changes is the model.
Source: docs.databricks.com2.TTFT, TPOT, latency and throughput
"Latency" on an LLM endpoint is several numbers, not one. LLM inference has two phases. In prefill, all the prompt tokens are processed in parallel. In decoding, output is generated one token at a time, and each new token is fed back into the model to produce the next one. Each phase maps to a metric.
Databricks defines four metrics:
- Time to first token (TTFT): how long until the user sees any output. It covers processing the prompt and generating the first token. It matters a lot for real-time interaction and much less for offline jobs.
- Time per output token (TPOT): how long each further token takes for one user. This is the "speed" a user perceives. A TPOT of 100 ms is 10 tokens per second, faster than a person reads.
- End-to-end latency:
TTFT + TPOT × number of tokens generated. - Throughput: output tokens per second across all concurrent requests. This is an endpoint-level figure, not a per-user one.
The formula shows why answer length matters so much. With a 200 ms TTFT and a 20 ms TPOT, a 50-token answer takes 1.2 seconds, while a 500-token answer takes 10.2 seconds. When you compare models, check how long each one's answers are as well as its per-token speed. A model that talks more can lose on latency even with a faster TPOT.
Latency and throughput pull against each other. An endpoint processes concurrent requests together, so more load raises total tokens per second but also raises each request's latency. Eventually throughput plateaus at what the provisioned capacity allows, and extra requests just wait in a queue. Databricks recommends maximizing throughput within a latency budget. A real-time app such as a support chat should send fewer concurrent requests so latency stays low. Batch inference and other non-user-facing jobs should saturate the endpoint, because there throughput is worth more than any single request's latency.
Model size enters through these numbers. Smaller models give faster inference, which feeds directly into TTFT and TPOT. For a user-facing app, a strict latency budget can rule out a larger model even when it scores slightly higher on quality.
Checkpoint 3 of 9· Check yourself
Two candidate models both clear your quality bar for a user-facing assistant. Model A has a 100 ms TTFT and a 20 ms TPOT, and its answers average 600 tokens. Model B has a 400 ms TTFT and a 25 ms TPOT, and its answers average 150 tokens. Which model gives the lower end-to-end latency?
End-to-end latency is TTFT + TPOT × tokens generated. Model A takes 0.1 + 0.02 × 600 = 12.1 s and Model B takes 0.4 + 0.025 × 150 ≈ 4.2 s. Output length dominates, so the model with shorter answers wins even though its first token and per-token speed are slower.
“Latency = TTFT + (TPOT) * (the number of tokens to be generated)”Source: docs.databricks.com
Checkpoint 4 of 9· Match them up
Match each endpoint workload or load condition to what happens or what Databricks recommends
Tap a term, then the definition that fits it.
Latency and throughput trade off through concurrency. Low-latency apps should limit concurrent requests, and batch jobs should saturate the endpoint. Once provisioned capacity is reached, throughput stops growing and queued requests only add latency.
“If you have a low latency use case, you want to send fewer concurrent requests to the endpoint to keep latency low.”Source: docs.databricks.com
Sources4
3.Choosing model size from the evidence
Start small and scale up only when the metrics demand it. Reaching for the most capable model first feels safe, but smaller models often give satisfactory results at lower cost and with faster inference. This holds especially for tasks that don't need complex reasoning or broad world knowledge. Scaling up is justified by evidence: the smaller model fails a specific kind of query, or its answers fall short of the accuracy bar on the evaluation set.
Here is how the threshold logic plays out. A support chatbot needs answers within a tight response-time budget and at least 85% task accuracy. Both an 8B and a 70B candidate clear 85% on the held-out set. Once both clear the bar, the extra parameters of the 70B model buy nothing the requirement asks for. They still cost more tokens' worth of compute and add latency. The 8B model wins because it meets the accuracy threshold and its smaller size gives lower inference latency. Provisioned throughput is a way to serve a model on dedicated capacity instead of the shared pay-per-token capacity, which is why teams sometimes assume it belongs with big models. Two wrong arguments come up often here:
- "Larger models are always more reliable." The measured accuracy already answers the reliability question. A parameter count does not override a measured result.
- "Provisioned throughput needs a large model." Provisioned throughput workloads include small models such as Meta Llama 3.2 1B and 3B, so deployment mode doesn't force a size.
Passing the threshold once does not end the evaluation. Keep assessing the chosen model's performance and limits as the chain changes, and re-measure quality, latency and cost whenever you change the model. Prompts also often don't transfer between models. A prompt tuned for the 70B model may need rework before the 8B model's scores are a fair comparison.
You also don't need one model for the whole pipeline. A RAG chain may call an LLM to understand the query, for example to classify intent or rewrite the query, before it calls the generator. Expensive general-purpose models can be overkill for intent detection. Giving that step a small, fast model and keeping a larger model for generation lets each step meet its own quality bar at its own cost. You measure each step's model the same way you measure the generator's.
Checkpoint 5 of 9· Check yourself
A support chatbot needs at least 85% task accuracy and has a tight response-time budget. On the held-out set, Llama 3.3 70B scores 91% and Llama 3.1 8B scores 87%. Which model should the team deploy, and why?
Both models clear the measured 85% bar, so the remaining decision is about cost and latency, and the smaller model wins on both. Scaling up is justified only when the smaller model fails the bar or struggles with specific queries. Provisioned throughput also serves small models such as Llama 3.2 1B and 3B.
“smaller open-source alternatives like Llama 3 can provide satisfactory results at a lower cost and with faster inference times.”Source: docs.databricks.com
Checkpoint 6 of 9· Exam question
A team is building a customer support chatbot that must respond within 300 milliseconds to feel conversational, and offline evaluation shows a 70-billion-parameter model and a 8-billion-parameter model both clear the required 85% task-accuracy threshold on the held-out evaluation set. Based on these quantitative results, which model choice best fits the deployment requirement?
Correct answer: A — Deploy the 8-billion-parameter model, since it clears the accuracy bar and its lower compute per generated token shortens the time to produce each reply.
- A. Correct. Both models clear the accuracy threshold, so accuracy no longer separates them and latency decides. The 8-billion-parameter model does less computation per generated token, so it is the one more likely to answer within the 300 ms budget.
- B. Incorrect. Both models already meet the same accuracy threshold on the evaluation set, so there is no measured quality gap to justify the larger model. Its extra compute per token works against the 300 ms response requirement. A claim about live-traffic robustness is not backed by the quantitative results.
- C. Incorrect. An offline accuracy result says nothing about how fast the model responds under serving conditions. Passing the accuracy threshold does not confirm the 300 ms target, so latency still has to be measured before launch.
- D. Incorrect. Provisioned throughput reserves serving capacity and avoids queueing and throttling, but it does not reduce the computation the 70-billion-parameter model needs for each token. The smaller model that already meets the accuracy bar fits the 300 ms requirement better.
4.Architecture and context window as quantitative inputs
Architecture changes how much compute each token costs, so it shows up in your cost and latency numbers. Model cards on Databricks Foundation Model APIs state the relevant facts directly. Some models use a mixture of experts (MoE) design: the model holds many parameters in total but activates only a subset of them for each token.
DeepSeek V4 Flash has 284 billion total parameters but only 13 billion active ones, and its card describes it as optimized for fast, cost-efficient work. Llama 4 Maverick adopted MoE specifically "for compute efficiency". So when an MoE model and a model that activates every parameter tie on a quality metric, the MoE model is likely to show lower per-token cost and latency. That gives it the edge. Architecture is not a quality guarantee, though. Routing tokens to experts does not promise better accuracy on future tasks, so quality still has to be measured on your evaluation set.
| Endpoint | Size / architecture | Positioning in the model card |
|---|---|---|
| databricks-meta-llama-3-1-8b-instruct | 8B, context of 128,000 tokens | optimized for dialogue use cases |
| databricks-meta-llama-3-3-70b-instruct | 70B, context of 128,000 tokens | optimized for dialogue use cases |
| databricks-deepseek-v4-flash-0731 | MoE: 284 billion total, 13 billion active parameters | fast, cost-efficient reasoning, coding, and agentic tool use |
| databricks-llama-4-maverick | mixture of experts architecture | compute efficiency |
| databricks-gpt-oss-20b | lightweight reasoning model, 128K token context window | real-time copilots and batch inference tasks |
The context window is a pass/fail gate that comes before any quality comparison. Each model card states a maximum context, such as 128,000 tokens for Meta-Llama-3.3-70B-Instruct. Suppose your inputs average 25,000 tokens, for example regulatory filings to summarize. A candidate with an 8,000-token window cannot take a whole filing in one call. The document would have to be split, and splitting loses information that models with 32K or 128K windows keep. That candidate drops out even if its summarization scores look similar on shorter test inputs. Above the gate, a bigger window is not free. The number of input tokens strongly affects the memory needed to serve each request, so feeding long documents raises serving demands whichever model you pick.
No. It fails a hard requirement: it can't ingest one document in a single pass, so it would need lossy chunking that the larger-window candidates avoid. Cost and latency only decide between candidates that pass every gate.
Checkpoint 7 of 9· Check yourself
DeepSeek V4 Flash, a mixture-of-experts model with 284 billion total and 13 billion active parameters, is on your shortlist. Which statement about weighing it against other candidates holds up?
An MoE model activates only a subset of its parameters for each token, so its cost and latency follow the active count. That is why the model card calls it fast and cost-efficient. Architecture does not guarantee quality, though, so it still has to clear the quality bar on your own evaluation set.
“284 billion total parameters and 13 billion active parameters developed by DeepSeek. The model is optimized for fast, cost-efficient reasoning, coding, and agentic tool use.”Source: docs.databricks.com
Checkpoint 8 of 9· Exam question
A financial services company is evaluating three candidate LLMs to summarize long regulatory filings that average 25,000 tokens per document. During evaluation, one candidate model has a maximum context window of 8,000 tokens, while the other two support 32,000 and 128,000 tokens respectively, and all three otherwise score similarly on summarization quality metrics. What should the team conclude from this quantitative comparison?
Correct answer: A — Drop the 8,000-token model, because an average filing runs about three times its input limit and must be split or truncated before it can be summarized
- A. Correct. Filings average 25,000 tokens, about three times the 8,000-token limit, so that model can only see a document after it is split into pieces or cut short. The other two models take a document of that size whole, so with similar quality scores this limit is the deciding difference.
- B. Incorrect. Window size sets how much of a document the model can read in one call, so it is not only a cost or latency matter. Similar benchmark scores do not offset a window that is far smaller than the 25,000-token filings the team needs to summarize.
- C. Incorrect. The data gives no basis for ranking the 32,000-token model above the 128,000-token one. Filings only average 25,000 tokens, so many are longer, and the prompt and the generated summary also use the window, which leaves the 32,000-token model little room. The claim that a larger window adds nothing is unsupported.
- D. Incorrect. An 8,000-token window cannot hold a 25,000-token filing, so the model would read only fragments or a truncated version. A narrower window does not make the model focus better, and the summary would miss content from the parts of the filing that are cut or processed separately.
Checkpoint 9 of 9· Exam question
A team evaluates a dense transformer model and a mixture-of-experts (MoE) model of comparable total parameter count for a code-generation task. The MoE model activates only a subset of its parameters per token during inference, while the dense model activates all of its parameters for every token. Both models score similarly on the code-correctness evaluation metric. Which quantitative outcome would this architectural difference most likely produce?
Correct answer: A — The MoE model shows lower per-token compute and serving latency than the dense model, because only the experts the router selects run for each token during a forward pass
- A. Correct. The router sends each token to only a few experts, so the MoE model does less computation per token than a dense model of similar total size. That typically gives lower per-token inference cost and latency.
- B. Incorrect. Both models already score similarly on the code-correctness metric, so the architecture is not producing an accuracy gain here. Sparse expert routing mainly changes how much compute each token needs, not how accurate the model is at a given parameter count.
- C. Incorrect. The dense model runs its entire parameter set for every token, so it does more computation per token than the sparse model. Higher accelerator utilization does not offset that extra work, and the dense model's per-token cost and latency are higher, not lower.
- D. Incorrect. Per-token inference compute depends on how many parameters are active, not on total parameter count. The two models activate very different numbers of parameters per token, so comparable total size does not give matching latency and cost.
Sources
(7)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/evaluate-assess-performanceOfficial docs
“Below is a summary of the metrics that Databricks recommends for measuring the quality, cost, and latency of your RAG application.”
↩︎ Quality, cost and latency as the comparison dimensions“Cost and latency metrics can be computed deterministically based on the application's outputs.”
↩︎ Quality, cost and latency as the comparison dimensions“Some LLM judges, such as answer correctness, compare the human-labeled ground truth vs. the app outputs.”
↩︎ Quality, cost and latency as the comparison dimensions - 2.
“This makes it easier to compare versions, track improvements, and share results across teams.”
↩︎ Quality, cost and latency as the comparison dimensions - 3.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/evaluate-define-qualityOfficial docs
“Databricks recommends at least 30 questions in your evaluation set”
↩︎ Quality, cost and latency as the comparison dimensions - 4.https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/prov-throughput-run-benchmarkOfficial docs
“This metric is driven by the time required to process the prompt and then generate the first output token.”
↩︎ TTFT, TPOT, latency and throughput“For example, a TPOT of 100 milliseconds per token would be 10 tokens per second”
↩︎ TTFT, TPOT, latency and throughput“Most production applications have a latency budget, and Databricks recommends you maximize throughput given that latency budget.”
↩︎ TTFT, TPOT, latency and throughput“High throughput use cases might include batch inferences and other non-user facing tasks.”
↩︎ TTFT, TPOT, latency and throughput“Meta Llama 3.2 1B”
↩︎ Choosing model size from the evidence“The number of input tokens has a substantial impact on the required memory to process requests.”
↩︎ Architecture and context window as quantitative inputs“Latency = TTFT + (TPOT) * (the number of tokens to be generated)”
↩︎ Exam trap 3“The number of output tokens dominates overall response latency.”
↩︎ Prediction“Latency = TTFT + (TPOT) * (the number of tokens to be generated)”
↩︎ Checkpoint“If you have a low latency use case, you want to send fewer concurrent requests to the endpoint to keep latency low.”
↩︎ Checkpoint - 5.
“smaller open-source alternatives like Llama 3 can provide satisfactory results at a lower cost and with faster inference times”
↩︎ Choosing model size from the evidence“If there are multiple steps in your chain that require an LLM”
↩︎ Choosing model size from the evidence“Recognize that prompts often do not transfer seamlessly across different language models.”
↩︎ Choosing model size from the evidence“Monitor the impact of changing models on key metrics such as response quality, latency, and cost”
↩︎ Key concept“smaller open-source alternatives like Llama 3 can provide satisfactory results at a lower cost and with faster inference times”
↩︎ Exam trap 1“More expensive, general-purpose models may be overkill for tasks like determining the intent of a user query.”
↩︎ Exam trap 4“smaller open-source alternatives like Llama 3 can provide satisfactory results at a lower cost and with faster inference times.”
↩︎ Checkpoint - 6.
“which provides dedicated capacity instead of shared pay-per-token capacity”
↩︎ Choosing model size from the evidence - 7.https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/supported-modelsOfficial docs
“It is the first of the Llama model family to use a mixture of experts architecture for compute efficiency.”
↩︎ Architecture and context window as quantitative inputs“Meta-Llama-3.3-70B-Instruct is a state-of-the-art large language model with a context of 128,000 tokens”
↩︎ Architecture and context window as quantitative inputs“The model is optimized for fast, cost-efficient reasoning, coding, and agentic tool use.”
↩︎ Exam trap 2“hybrid mixture of experts (MoE) language model with 284 billion total parameters and 13 billion active parameters”
↩︎ Prediction“284 billion total parameters and 13 billion active parameters developed by DeepSeek. The model is optimized for fast, cost-efficient reasoning, coding, and agentic tool use.”
↩︎ Checkpoint