How to Objectively Evaluate LLM Capabilities and Control Token Costs
Many users still judge a large language model by whether an answer "felt smooth" or "looked right." That kind of single, intuitive judgment is unreliable, and anyone who runs LLM services in production needs something better: a way to measure capability across dimensions, and a way to keep token spend under control. This article covers both sides — how to build reproducible evaluations, how token billing actually consumes your budget, and the engineering practices (trimming context, caching, model routing, backoff, degradation, budget monitoring) that keep quality stable at a predictable cost.
1. From Subjective Impressions to Multi-Dimensional Evaluation
Many users evaluate a model at the level of “did the answer feel smooth” or “was the answer accurate.” The problem with this approach is that a single unlucky failure may come from a poor prompt, insufficient context, or a task beyond the model’s scope — it says little about the model’s overall capability. To reach a reliable conclusion, evaluation has to be broken into measurable, reproducible dimensions.
1. Key dimensions of capability evaluation
A reasonably complete evaluation should cover at least the following:
- Task correctness: given a clear input, does the output meet the task goal (factual accuracy, whether the code actually runs, whether the logical reasoning is self-consistent)?
- Instruction following: can the model respect format, word count, role and other constraints, and how does it behave under complex, multi-constraint requirements?
- Context handling: over long documents and long conversations, does it keep information consistent, or does it suffer from “lost in the middle”?
- Stability and consistency: when the same input is run repeatedly, is the variance in results under control?
- Engineering metrics: time to first token, throughput, concurrency capacity, service availability.
- Cost efficiency: the tokens and time consumed to complete a task of equal quality — not simply a comparison of per-token prices.
2. Scenario-based evaluation instead of a “generic score”
A “general-purpose rating” detached from your own scenario has limited reference value. A more reliable approach is to build an eval set that mirrors your actual business:
# Pseudocode: building a minimal viable eval seteval_cases = [{"input": "...", "expected_key_points": [...], "constraints": [...]},...]def evaluate(case, model_response):# Combine rule matching + human review + semantic similarity into an overall scorereturn score
The eval set should include normal cases, boundary cases and “trap” cases (for example ambiguous, out-of-scope, or strictly format-constrained requests) so that it reflects how the model actually behaves in real business usage. For important conclusions, add A/B comparisons and human review to cover the blind spots of automated metrics.
2. Understanding the Billing Model: How Tokens and Quotas Get Consumed
To control cost, first understand where it comes from. The vast majority of LLM services meter usage in tokens (roughly, the smallest billing unit after text is split), bill input and output separately, and usually apply different rates to each — output is often more expensive. In practice, this means the longer the context you feed in and the longer the answer you generate, the more you spend.
1. Common token consumption traps
- Redundant system prompts and fixed prefixes: shipping a long, unchanging preamble with every request means it gets billed over and over.
- Unbounded accumulation across turns: multi-turn conversations resend the entire history each time, so the per-call cost grows with the number of turns.
- Feeding the same context repeatedly: when asking many questions about the same batch of long documents, resending them each time causes a large amount of duplicated computation.
- Using an expensive model for low-value tasks: sending simple classification or format conversion to the same top-tier model is a very poor trade-off.
Below is a rough cost-estimation function (the values are empirical approximations for estimation only and do not represent the billing rules of any specific product):
def estimate_tokens(text, kind):# Empirical approximation: Chinese ~1-2 tokens per character, English ~1 token per 4 charactersif kind == "zh":return int(len(text) * 1.5)return int(len(text) / 4) + 1total = estimate_tokens(prompt, "zh") + estimate_tokens(expected_answer, "zh")
3. Practices for Cutting Calling Costs
Once you understand where consumption comes from, you can optimize it directly. The core principle is: use the right model, in the right way, sending only the necessary information.
1. Trim prompts and prune context
System prompts should be as concise as possible, with repetitive and unnecessary wording removed. In multi-turn conversations, summarize or truncate early history that is no longer relevant, keeping only what relates to the current task. For long-document processing, retrieve or chunk the content first and send only the relevant fragments to the model instead of the entire document.
2. Caching and reuse
For requests that repeat identically (fixed FAQs, the same summarization input), return a cached result directly and skip the call. Cache keys should be built from normalized input, with a sensible expiry policy.
3. Tiered model routing
Not every task needs the strongest model. Classify tasks by complexity, route simple ones to a lightweight model, and send complex reasoning to a more capable one — balancing quality against cost:
def route(task):if task.is_simple: # classification, extraction, format conversion, etc.return lightweight_modelreturn strong_model # complex reasoning, code generation, etc.
4. Batch processing and streaming output
For large offline workloads, prefer batch processing to raise throughput and spread unit cost. For interactive scenarios, streaming output preserves the user experience while letting you detect invalid generation early and abort it, reducing waste.
4. Queues and Rate Limits: Building Resilience on the Client Side
As concurrency rises or the service gets busy, requests may be queued or hit rate limits (server-side constraints on request rate). Retrying blindly does not solve this — it needs systematic design on the client.
1. Backoff and retry
When a rate limit is hit, use exponential backoff with jitter so that all clients do not retry at the same moment and cause a second wave of load:
import time, randomdef call_with_backoff(request_fn, max_retries=5, base=0.5):for i in range(max_retries):try:return request_fn()except RateLimited:sleep = base * (2 ** i) + random.uniform(0, 0.2)time.sleep(sleep)raise RuntimeError("Retries exhausted, please try again later")
2. Concurrency control and task queues
Add a request queue and a concurrency limit (semaphore) on the client side to smooth bursts into a controllable rate. For long-running tasks, go asynchronous with a task queue so that a backlog does not drag down the entire system.
3. Timeouts, circuit breaking and graceful degradation
Set a sensible timeout for each call so that an individual slow request cannot hold resources indefinitely. Circuit-break a downstream dependency that keeps failing, and prepare a fallback for when it is unavailable (return a cached result, switch to a backup model, or show a friendly message) so the overall chain does not break.
5. Resource Governance: Getting Every Unit of Budget to Count
Finally, cost and quota must be continuously observed, not discovered to be over budget at the end of the month.
- Budget and quota monitoring: set thresholds on token usage and call counts, and alert in advance as limits approach, so the allowance is not drained by the wrong tasks.
- Usage attribution analysis: break consumption down by business, scenario and user to identify where the real cost sits.
- Cost-quality balance: periodically review the “quality delivered per unit cost” of each task, and optimize or retire high-consumption, low-value tasks.
A simple budget guard:
def with_budget(budget_state):def guard(fn):def wrapper(*args, **kwargs):if budget_state.used >= budget_state.limit:raise BudgetExceeded() # trigger degradation or a noticeresult = fn(*args, **kwargs)budget_state.used += result.tokensreturn resultreturn wrapperreturn guard
Conclusion
A model cannot be judged from a single subjective experience, and an intelligent service cannot be managed while ignoring the billing logic and engineering constraints behind it. Break evaluation into measurable dimensions, attribute cost to concrete scenarios, use routing and caching to eliminate unnecessary consumption, use backoff and degradation to absorb queues and rate limits, and add continuous budget monitoring — that is how you get stable, reliable intelligence at a controllable cost. It is both a methodology for choosing a model and a basic skill for using one over the long term.
