How to Scientifically Evaluate Large Language Models: A Capability, Cost, and Experience Framework

    Choosing a large language model often comes down to leaderboard scores, list prices, and gut feeling about latency and quota usage. This article argues that while subjective experience is valuable, it must be translated into measurable metrics before it can support model selection and cost decisions. It presents a three-dimensional evaluation framework covering capability, cost, and experience; shows how to build a business-specific evaluation set and control token consumption; explains how to handle queuing and rate limiting; and closes with engineering practices and a practical checklist for making evaluation and cost governance a routine part of development.

    When developers choose a large language model, their decisions usually rest on three things: scores on evaluation leaderboards, the price list, and their own hands-on impression. Perceptions like “credits burn through too fast” or “requests often sit in a queue” fall into that third category.

    This article makes one central point: subjective experience feedback is valuable, but only once it is translated into measurable metrics can it support model selection and cost decisions. Starting from a breakdown of the causes, it builds a three-dimensional framework of capability, cost, and experience, then offers practical methods, illustrative code, and an implementation checklist.

    1. First, understand the problem: what two common impressions reveal

    Many developers and organizations run into two similar experiences when adopting a large language model.

    “Credits are never enough.” The membership or plan still has quota left, yet it drains within a handful of seemingly simple operations.

    “Requests always have to wait.” During peak hours, calls sit in a queue and response time grows noticeably. Some people switch to another option as a result, leaving their purchased quota idle.

    Behind these two experiences lie several problems that are independent yet interconnected:

    Symptom Possible root cause Quantifiable metric it can be turned into
    Quota consumed too quickly Verbose prompts; unbounded context and output length; repeated billing from retries; poor task granularity Input/output tokens per task, task-merging rate, retry rate
    Requests need to queue Server-side concurrency and rate limits; client-side synchronous call pile-up; missing queue and backoff mechanisms P95 time-to-first-token, error rate, rate-limit trigger rate
    Model quality below expectations Evaluation based only on leaderboards; mismatch between business scenarios and public test distributions Task pass rate, format compliance rate, manual rework rate

    One point needs to be clear first: fast quota consumption does not necessarily mean “the model is weak,” and queuing does not necessarily mean “the service is poor.” The former is usually tied directly to how you call the model — with the same model, different prompt design and task organization can change token consumption by several times. The latter is mostly determined by concurrency quota and resource-capacity constraints, and can be significantly eased through architecture design. Once you turn impressions into metrics, the question shifts from a subjective argument about “is it good to use” to an engineering proposition about “how to optimize it.”

    2. Build a “capability–cost–experience” three-dimensional framework

    The evaluation system should cover at least three dimensions:

    Dimension Core question Key metrics Data source
    Capability Can it get the task right and do it well Task pass rate, format compliance rate, manual rework rate Self-built eval set, human spot checks
    Cost How much does it cost to complete one unit of work Input/output tokens per task, cost per task, retry rate, cache hit rate Call logs and usage statistics
    Experience Is the service stable, fast, and predictable P95 time-to-first-token, generation speed, error rate, rate-limit trigger rate Monitoring and alerting, call tracing

    The three dimensions constrain one another, and a single dimension that is locally “optimal” can throw the whole system out of balance:

    • Chasing only quality: Stacking long contexts and complex prompts raises capability, but input tokens multiply and cost spirals out of control.
    • Chasing only low cost: Choosing a cheap model whose output fails quality checks leads to repeated rework and retries, and the total cost across multiple calls may actually be higher.
    • Chasing only speed: Ignoring rate limits means many requests are throttled or time out at peak, forcing users to resubmit — both experience and cost deteriorate.

    Therefore, judging whether a model suits a given business should be based on its overall performance in the target scenario, not a single leaderboard score or unit price.

    3. Capability evaluation: from “reading the leaderboard” to “testing your own business”

    3.1 The limits of public leaderboards

    • Distribution mismatch: The question types in an evaluation set may differ greatly from the distribution of your real business requests.
    • Data contamination risk: Some questions may already appear in the model’s training data, so scores struggle to reflect true generalization.
    • Single scoring dimension: Most look only at whether the final answer is correct, rarely measuring output format, length control, refusal boundaries, and other things you actually care about.

    Public leaderboards are good for initial screening, not for final decision-making.

    3.2 Design an evaluation set that fits your business

    • Data source: Real business requests and their expected results; desensitize them first, then add human annotation.
    • Size recommendation: 100–500 cases are enough for day-to-day regression; critical business scenarios can be expanded as appropriate.
    • Layered coverage: Sample by task type, difficulty, and edge cases, ensuring both high-frequency and tricky scenarios have enough samples.
    • Clear expected answers: Write out the judging criteria — keywords, structured fields, regex rules, or reference points — to avoid “scoring by feel.”

    An illustrative evaluation-set structure follows (plain-text format, easy to version):

    1. id, level, task_type, input, expected, judge_rule
    2. 1, high-freq, information-extraction, <desensitized input text>, {"name":"...", "amount":"..."}, json_equal
    3. 2, edge, instruction-following, <request with ambiguous wording>, <expected output points>, contains_all
    4. 3, hard, code-generation, <requirement description>, expected feature list, rule_check

    3.3 Standardize evaluation conditions

    • Fix inference parameters: The same model can behave very differently under different temperature settings, so fix temperature, top_p, max_tokens, and similar parameters during evaluation; if needed, run a separate sensitivity analysis on parameters.
    • Use a unified prompt template: All candidates use the same template, so differences in prompt length don’t skew the cost and quality comparison.
    • Sample multiple times to assess stability: Repeat generation tasks several times (e.g., 3 runs) and track both the average pass rate and its variance. A model with high variance is harder to use in an automated pipeline.
    • Validate output format: When structured results are required, validate the output format (e.g., JSON parsing, schema validation) and track “format compliance rate” as a separate metric.

    3.4 Sample code for offline batch evaluation

    The Python script below is illustrative. It relies on no third-party evaluation framework, making it easy to adapt to your business:

    1. import json
    2. import time
    3. def run_eval(client, prompt_template, cases, judge, pricing):
    4. total_in, total_out, passed = 0, 0, 0
    5. for c in cases:
    6. t0 = time.time()
    7. # Use fixed, deterministic parameters so results are reproducible
    8. resp = client.chat(
    9. messages=[
    10. {"role": "system", "content": prompt_template["system"]},
    11. {"role": "user", "content": c["input"]},
    12. ],
    13. temperature=0.0,
    14. max_tokens=1024,
    15. )
    16. u = resp.usage # Prefer the usage reported by the server
    17. total_in += u.prompt_tokens
    18. total_out += u.completion_tokens
    19. ok = judge(c, resp.text)
    20. passed += ok
    21. print(f"{c['id']} passed={ok} input={u.prompt_tokens} "
    22. f"output={u.completion_tokens} elapsed={time.time() - t0:.2f}s")
    23. cost = pricing["in"] * total_in + pricing["out"] * total_out # unit price is per 1M tokens
    24. return {
    25. "pass_rate": passed / len(cases),
    26. "total_input_tokens": total_in,
    27. "total_output_tokens": total_out,
    28. "cost_per_eval_run": cost / 1_000_000,
    29. }

    Pass rate measures “is the answer correct,” while token usage and cost measure “is the answer expensive.” Putting both in the same report is what makes them comparable.

    4. Cost breakdown: how tokens get consumed

    4.1 The token is the basic unit of measurement

    Large models bill by token. A token is the basic unit the model uses to process text, roughly corresponding to a morpheme: an English word may be split into several tokens; a Chinese character usually maps to one or more tokens, depending on the tokenizer.

    Recommended practice:

    1. Count tokens using the same tokenizer as the server;
    2. When reconciling, use the usage returned by the server as the source of truth;
    3. Retain a usage record for every call over the long term.

    4.2 Input and output are priced separately

    Most inference services price input and output tokens separately, with output usually costing more than input. So “the more detailed the input, the better” is not always true:

    • Every additional thousand input tokens raises cost linearly;
    • Long inputs also push up time-to-first-token and bring a “lost in the middle” problem — a model often uses information in the middle of a very long context less effectively than information at the beginning and end.

    4.3 Four sources of hidden consumption

    Source Symptom Optimization
    Verbose prompts The system prompt is stuffed with explanations and examples unrelated to the task Trim prompts per task; inject examples on demand
    Unbounded context History messages are appended endlessly in multi-turn conversations Sliding window, summary compression, retrieval on demand
    Duplicate calls Retries, timeouts, repeated user submissions Idempotency keys, result caching, timeout and backoff strategies
    Tasks too granular Many small tasks each carrying a full prompt Merge into a single batch call

    4.4 Example: how much can merging calls save?

    Suppose there are 10 structurally similar small tasks, with the illustrative values below (for demonstration only, not the pricing of any real product):

    • System prompt: 500 tokens
    • Each task’s own input: 200 tokens
    • Each task’s output: 100 tokens
    • Input price: 1 per million tokens; output price: 4 per million tokens

    Calling one by one, each call carries the full 500-token system prompt:

    • Total input: 7,000 tokens; total output: 1,000 tokens
    • Cost = (7,000 × 1 + 1,000 × 4) / 1,000,000 = 0.011

    Merged into a single batch call, the prompt is sent only once:

    • Total input: 2,500 tokens; output still 1,000 tokens
    • Cost = (2,500 × 1 + 1,000 × 4) / 1,000,000 = 0.0065

    Under these assumptions, cost drops by about 41%, and the number of requests falls from 10 to 1, easing rate-limit pressure at the same time.

    The trade-offs need weighing too:

    • A single output becomes longer and may hit the output limit;
    • If any sub-item is wrong, the whole batch must be rerun;
    • Result alignment and fault tolerance become more complex.

    So task granularity should be weighed against prompt length, task count, output length, and fault-tolerance requirements — not simply “the more merging the better.”

    4.5 Put budget control into the code

    Adding a “budget guardrail” to the call path prevents a single anomaly from snowballing into large-scale consumption:

    1. def guard(prompt, history, budget):
    2. est_in = count_tokens(prompt) + sum(count_tokens(m) for m in history)
    3. if est_in + budget["reserve_out"] > budget["max_tokens"]:
    4. history = summarize(history, keep=history[-budget["keep_turns"]:]) # Compress history
    5. remaining = budget["max_tokens"] - est_in
    6. return {
    7. "messages": build_messages(prompt, history),
    8. "max_tokens": min(budget["reserve_out"], remaining),
    9. }
    10. def call_with_limits(fn, params, retry_budget=2, timeout=30.0):
    11. """Give every call a timeout and retry cap so one fault can't amplify consumption without bound."""
    12. for attempt in range(retry_budget + 1):
    13. try:
    14. return fn(params, timeout=timeout)
    15. except (TimeoutError, RateLimitError, ServiceUnavailableError) as e:
    16. if attempt == retry_budget:
    17. raise
    18. time.sleep(base_delay * (2 ** attempt) + random.uniform(0, 0.5))

    What the sample code does:

    • guard() estimates input length and, when it exceeds the limit, compresses history and tightens the output cap dynamically;
    • call_with_limits() sets a timeout and maximum retry count for each call, using an “exponential backoff + random jitter” retry strategy;
    • If the server returns a suggested wait time, prefer that value.

    This both controls token consumption in error scenarios and reduces congestion from retry requests arriving simultaneously.

    5. Experience evaluation: how to handle queuing and rate limiting

    Queuing is a common feature of shared inference services. Concurrency capacity, rate limits, and current resource load together determine response speed. The client cannot unilaterally eliminate queuing, but it can significantly lessen its impact.

    5.1 First, determine whether the bottleneck is client-side or server-side

    Symptom How to tell Response direction
    Requests pile up on the client Client thread pool is saturated; request send times cluster Introduce a message queue for peak shaving; control concurrency
    A clear rate-limit signal is returned Rate-limit error codes or wait hints appear in the response Follow retry-wait suggestions; use exponential backoff; reduce burst traffic
    Server resources are insufficient Many timeouts; errors scattered without a clear pattern Reduce per-request resource usage; set timeouts and circuit breakers

    5.2 Use an async queue to shave peaks

    For latency-insensitive tasks (e.g., batch document processing, overnight report generation), a message queue for async processing is recommended:

    1. # Producer: only enqueues the job, does not wait for the model result
    2. def submit(job):
    3. message_queue.send(
    4. topic="llm-jobs",
    5. body={"job_id": job.id, "payload": job.payload, "priority": job.priority},
    6. )
    7. return job.id
    8. # Consumer: pulls jobs up to a concurrency cap, stores results and notifies the caller
    9. def consume(concurrency=4):
    10. with ThreadPoolExecutor(max_workers=concurrency) as pool:
    11. for msg in message_queue.receive("llm-jobs"):
    12. pool.submit(process_job, msg)
    13. def process_job(msg):
    14. result = llm_client.call(msg.payload) # Already includes timeout and backoff retries
    15. object_storage.put(f"results/{msg['job_id']}.json", result)
    16. notify_client(msg["job_id"]) # Notify the caller that the result is ready, via message or callback

    This brings three benefits:

    • Users get an immediate return on submission and don’t have to wait synchronously for the model;
    • During peaks, tasks queue up and are consumed at a steady, controlled rate;
    • Failed tasks can be re-enqueued instead of making users resubmit.

    5.3 Set up experience-metric monitoring

    It’s worth continuously tracking these metrics:

    • Time-to-first-token (TTFT): Drives the user’s intuitive sense of “fast vs. slow,” and is especially critical with streaming output.
    • Generation speed: The token rate of sustained output.
    • End-to-end latency: The time from sending a request to receiving the complete result.
    • Error rate and rate-limit rate: Distinguish retryable from non-retryable errors.
    • Cost per task: The average token consumption and cost of each business task.

    For example, with monitoring and alerting, you can set a threshold on “cost per task”; once it’s exceeded, the prompt or calling method likely needs optimizing:

    1. alerts:
    2. - name: unit-cost-high
    3. expr: avg_by_task(llm_cost_per_task) > baseline * 1.3
    4. for: 15m
    5. labels: {severity: warning}
    6. annotations:
    7. summary: "Cost per task is significantly above baseline; check prompt length and retry rate"

    6. Engineering practice: make evaluation and cost governance routine

    A one-off evaluation only answers “how are we doing now.” Only by embedding evaluation and usage tracking into the daily development workflow can you keep answering “did things improve after the change.”

    1. Version-control evaluation data
    Evaluation sets, prompt templates, and model configs should all be under version control, and each evaluation run should record the corresponding version number. Only then can quality changes be traced back to a specific change.

    2. Wire up a pipeline on a cloud platform
    Cloud platforms such as Baidu AI Cloud typically provide common building blocks — object storage, message queues, container platforms, logging, and monitoring/alerting — that can be combined as needed. A typical mapping:

    Common capability Typical use in large-model applications
    Object storage Store evaluation sets, call logs, and result files
    Message queue Peak shaving, async decoupling, failed-task re-enqueueing
    Container platform Host evaluation services and inference-call services with elastic scaling
    Logging Retain call records to support usage analysis and issue tracing
    Monitoring & alerting Track latency, error rate, and cost metrics

    3. Canary releases
    After changing a prompt or adjusting a parameter, validate on a small slice of traffic first. Compare pass rate, latency, and cost together, and only roll out to full traffic after confirming no regression. This effectively avoids “optimizing one metric at the expense of another.”

    4. Continuously clean up “wasted consumption”
    Periodically mine your logs for calls such as:

    • Calls that return empty output or invalid format;
    • Calls that fail and retry several times in a row;
    • Identical requests a user submits repeatedly within a short window.

    These calls consume tokens without producing value, making them the highest-priority target for governance.

    7. Practice checklist

    1. Evaluation set first: Build a layered evaluation set from real business data before comparing candidate models.
    2. Standardize evaluation conditions: Fix parameters and the prompt template to keep comparisons fair.
    3. Evaluate multiple metrics together: Look at pass rate, latency, and cost at once to avoid a single-point optimum.
    4. Make token accounting visible: Record input and output tokens for every call and aggregate cost by task.
    5. Trim prompts on demand: Inject examples and background only when needed, avoiding the high cost and “lost in the middle” effect of long contexts.
    6. Cap the context: Use a sliding window or summary compression to control multi-turn conversation length.
    7. Shave peaks with async: Introduce a queue for latency-insensitive tasks and control consumer concurrency.
    8. Handle failures robustly: Standardize timeouts, exponential backoff, maximum retry counts, and idempotency keys.
    9. Add budget guardrails: Estimate input length and cap output on the application side, with fast circuit-breaking on anomalies.
    10. Make canary and regression routine: Validate every change on a small traffic slice first, and run regression evaluations regularly.

    Back to the opening question: whether a model is worth using depends on whether, in your business scenario, it can deliver acceptable quality, controllable cost, and stable experience at the same time. Once impressions like “credits burn too fast” and “requests have to queue” are broken down into concrete metrics — token usage, time-to-first-token, retry rate — evaluation no longer relies on intuition, and optimization gains a clear direction.