CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 6 · Lesson 47/56

    Choosing LLM size and architecture from quality, cost and latency metrics

    Select an LLM choice (size and architecture) based on a set of quantitative evaluation metrics

    17 min read
    1.2% of exam
    7 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    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.

    Metrics Databricks recommends for comparing app versions, including versions that differ only in the LLM
    DimensionMetricMeasured byNeeds ground truth?
    ResponsecorrectnessLLM judgeYes
    Responserelevance_to_queryLLM judgeNo
    ResponsegroundednessLLM judgeNo
    ResponsesafetyLLM judgeNo
    Costtotal_token_count, total_input_token_count, total_output_token_countDeterministicNo
    Latencylatency_secondsDeterministicNo

    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.

    Signature of mlflow.genai.evaluate(): the same data and scorers are reused for each candidate, and model_id tracks which version produced each runpython
    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?

    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:

    Sources123

    2.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?

    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.

    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?

    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?

    Sources546

    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.

    Size and architecture facts from Foundation Model API model cards that feed a quantitative comparison
    EndpointSize / architecturePositioning in the model card
    databricks-meta-llama-3-1-8b-instruct8B, context of 128,000 tokensoptimized for dialogue use cases
    databricks-meta-llama-3-3-70b-instruct70B, context of 128,000 tokensoptimized for dialogue use cases
    databricks-deepseek-v4-flash-0731MoE: 284 billion total, 13 billion active parametersfast, cost-efficient reasoning, coding, and agentic tool use
    databricks-llama-4-maverickmixture of experts architecturecompute efficiency
    databricks-gpt-oss-20blightweight reasoning model, 128K token context windowreal-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.

    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?

    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?

    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?

    Sources74

    Sources

    (7)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “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. 2.
      “This makes it easier to compare versions, track improvements, and share results across teams.”
      ↩︎ Quality, cost and latency as the comparison dimensions
    3. 4.
      “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
      “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
    4. 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
    5. 6.
      “which provides dedicated capacity instead of shared pay-per-token capacity”
      ↩︎ Choosing model size from the evidence
    6. 7.
      “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

    Spotted a mistake, or was something unclear? Tell us.