Evaluating Lightweight Models for Office Scenarios: Balancing Cost and Performance
This article explores a practical evaluation methodology for selecting lightweight language models in office scenarios. It discusses the limitations of simple pricing models, how to build a realistic evaluation task set, and how to design quantifiable metrics. Additionally, it provides a sample evaluation framework in Python and covers tiered routing strategies along with engineering best practices to effectively balance cost and performance.
1. Why Office Scenarios Need Lightweight Models
Office scenarios are characterized by high request volumes, short single tasks, and high sensitivity to response speed. Tasks such as meeting minutes organization, email polishing, table field extraction, and weekly report generation usually do not require the strongest reasoning capabilities but demand stable output formats and fast responses. If every request calls a high-parameter model, both cost and latency will exceed actual needs. The value of lightweight models lies in completing most routine tasks at a lower cost, reserving high-cost models for the few complex problems.
Therefore, model selection can be broken down into two questions. First, can the candidate model achieve acceptable quality on the target task? Second, among the models that pass the quality threshold, which one offers the most suitable overall cost and response performance?
2. Why Unit Price Alone is Not Enough
Model pricing typically only includes the unit price of input and output tokens, but actual cost is determined by several factors.
First is the unit price itself. Pricing for input and output is often different, with output tokens usually being more expensive. When estimating, you should separately calculate the average input and output lengths in your business, rather than multiplying the total volume by an average price.
Second is the pricing time period. Some service providers distinguish between peak and off-peak call prices. Office requests are usually concentrated during working hours, meaning peak pricing may account for a large proportion of total costs. Specific pricing should be based on the rules published by the service provider; verify each item before evaluation rather than estimating based on impressions.
Third is the hidden cost. When a model’s output format is unstable, the program needs to retry or undergo manual review. The tokens consumed by retries and the manual time spent must be accounted for. Models that output verbose responses or include irrelevant explanations will also drive up the output token count.
Fourth is the experience cost brought by latency. Excessive waiting time reduces the willingness to use the tool. This cost is difficult to convert directly into monetary terms but should be recorded as an independent metric.
Overall, a more reasonable metric is the “effective cost per task,” which is the total cost divided by the number of tasks that pass quality acceptance. This way, retries, discarded drafts, and failed requests are all included.
3. Building a Realistic Evaluation Task Set
Whether evaluation results have reference value depends on whether the task set comes from real business operations. It is recommended to sample from actual tickets, historical documents, and daily requests, covering the following types of tasks:
- Meeting minutes: The input is a voice-to-text transcript, and the output is a list of topics, conclusions, and action items.
- Email rewriting: Requires adjusting the tone or compressing the length while retaining key information.
- Table extraction: Extracting fields like amounts, dates, and names from unstructured text and outputting a fixed-structure JSON.
- Weekly report generation: Summarizing several work records into structured paragraphs.
- Clause summarization: Extracting key points from longer policy or contract texts and checking if restrictive conditions are omitted.
For each task type, it is recommended to prepare 30 to 100 samples and write reference answers or scoring points for each. Samples should include both simple and difficult difficulties, and retain some inputs with non-standard formatting to test the model’s ability to handle abnormal inputs.
4. Designing Quantifiable Evaluation Metrics
It is recommended to evaluate across five dimensions:
- Task accuracy: Whether the output contains key information without factual errors. It can be manually scored, or rule-based comparison can be used for quantifiable fields.
- Format compliance rate: Whether the structured output can be directly parsed by a program. For automated workflows, this often has a greater impact than text quality.
- Response latency: Simultaneously record the first-token latency and full response time, focusing on the P50 and P95 percentiles. P95 better reflects the impact of occasional slow requests on user experience.
- Stability: The consistency of results across multiple calls with the same input, as well as the proportion of failures and timeouts.
- Effective cost per task: Calculated as defined previously.
Weights should be determined by the business according to the scenario. For automated table extraction, the weight of format compliance rate should be higher. For summaries intended for human reading, accuracy and language quality are more important. The following weights are just an example: accuracy 0.4, format compliance rate 0.2, latency 0.15, stability 0.15, cost 0.1.
Note that a weighted sum is not the most reliable decision-making method. A more prudent approach is to first set a minimum accuracy rate for each task type, directly eliminating models that fall below the threshold, and then comparing cost and latency among qualified models.
5. Evaluation Process and Sample Code
The following script demonstrates a general evaluation framework. The call_model is a placeholder function that needs to be replaced with the actual client call of the service used. The script calculates the format compliance rate, latency percentiles, and average cost per task. Price parameters should be passed in by the caller according to the pricing published by the service provider and should not be hardcoded.
import jsonimport timeimport statisticsdef call_model(model_name: str, prompt: str) -> dict:"""Placeholder function: returns {'text': str, 'input_tokens': int, 'output_tokens': int}"""raise NotImplementedError("Replace with actual model client call")def is_valid_json(text: str) -> bool:try:json.loads(text)return Trueexcept json.JSONDecodeError:return Falsedef evaluate(model_name, samples, price_in, price_out):"""price_in / price_out are the prices per million tokens"""latencies, valid, costs = [], 0, []for sample in samples:start = time.perf_counter()resp = call_model(model_name, sample["prompt"])latencies.append(time.perf_counter() - start)if is_valid_json(resp["text"]):valid += 1cost = (resp["input_tokens"] * price_in+ resp["output_tokens"] * price_out) / 1_000_000costs.append(cost)latencies.sort()p95_index = min(len(latencies) - 1, int(len(latencies) * 0.95))return {"model": model_name,"format_pass_rate": valid / len(samples),"p50_latency": statistics.median(latencies),"p95_latency": latencies[p95_index],"avg_cost_per_task": statistics.mean(costs),}
This script only covers format compliance rate, latency, and cost. Accuracy requires a separate evaluation step. For field extraction tasks, the output can be compared field by field with the standard answer. For summarization and rewriting tasks, you can first use manual spot-checks to establish a baseline, and then decide whether to introduce automated scoring. Automated scoring results should be regularly compared with manual results to confirm their reliability.
6. Result Analysis and Tiered Routing Strategy
After obtaining the metrics of each model, it is recommended to make decisions in the following order:
Step 1: Threshold filtering. If the accuracy or format compliance rate of any task type falls below the threshold, eliminate the model’s eligibility for use in that task type directly.
Step 2: Cost comparison. Among the qualified models, compare the effective cost per task, and calculate the cost range for peak and off-peak times separately to observe the actual load distribution of the business.
Step 3: Latency and stability checks. Focus on P95 latency and timeout rates. Even if the average latency is the lowest, a model with excessively high P95 is not suitable for interactive scenarios.
Step 4: Design tiered routing. Most teams will eventually adopt a tiered approach: assigning simple, fixed-format tasks to lightweight models; and escalating tasks that require complex reasoning or long-text understanding to more capable models. Routing rules can be triggered based on task type, input length, or number of failed retries.
The prerequisite for tiered routing is accurately identifying the task type. If the routing judgment itself is incorrect, the escalation strategy will fail, so routing rules also need to be included in the evaluation.
7. Engineering Implementation Points
- Prompt versioning: Incorporate prompts and task configurations into version control. Rerun the evaluation set after each modification and record the differences in results.
- Structured output validation: Parse and validate the fields of the model output. Limit the number of retries on validation failure, and transfer to a manual processing queue if the limit is exceeded.
- Fallback strategy: When the primary model times out or is unavailable, switch to a backup model and record the downgrade event for post-mortem analysis.
- Rate limiting and batching: Use batch processing for non-real-time tasks (such as nightly batch generation of weekly reports) to reduce concurrency pressure and facilitate taking advantage of pricing time period differences.
- Data desensitization: Meeting minutes, contracts, and HR materials contain sensitive information. Evaluation samples and live requests should filter personal information before calling, complying with data retention regulations.
- Monitoring and alerting: Record token consumption, failure rates, and latency by task type. Integrate with logging services and set up monitoring alerts for sudden cost spikes or increased failure rates.
- Periodic retesting: After the service provider adjusts model versions or pricing, the evaluation set should be run again. Selection conclusions have a time validity and should not be retained long-term without verification.
By following the above process, teams can compare candidate models under a unified standard and translate the selection results into a maintainable calling strategy.
