Evaluating and Selecting LLM Assistants: A Task-Based Framework and Practical Workflow

    This article explains why one-off trials are unreliable for choosing an LLM assistant and presents a repeatable evaluation approach. It breaks requirements down by task type, defines six scoring dimensions, and shows how to build a fixed test set and scoring rules. A Python example illustrates batch comparison, result summarization, and raw-answer storage. The article also covers usage practices that improve output quality, common pitfalls, and practical rollout recommendations for teams.

    1. Why a Single Trial Is Not Enough

    Trying a few tools on the same question often produces very different impressions. These impressions come from a small sample and are easily affected by prompt wording, service load at the time, context length, and randomness. Making a selection decision based on such impressions can easily lead to conclusions driven by chance.

    A more reliable approach is to break tasks apart, repeatedly measure the same set of questions against unified criteria, and then compare average performance and variation across dimensions.

    2. Split Requirements by Task Type

    Different tasks place very different demands on model capabilities. They should be evaluated separately rather than merged into a single total score. Common task types include the following.

    1. Complex reasoning and expert Q&A. For example, explaining the structural tensions in a social institution. The focus is on whether the argument has clear layers, whether it distinguishes facts, opinions, and assumptions, whether conclusions are supported by evidence, and whether it addresses the core of the question.
    2. Code and long-text processing. The focus is on whether the model can locate key information in a long context, whether generated code compiles and passes unit tests, and whether edits accidentally affect unrelated logic.
    3. Information retrieval and citation. The focus is on whether answers provide traceable sources, whether those sources actually exist, and whether time-sensitive information is accurate.
    4. Content rewriting and creation. The focus is on style transfer, paragraph structure completeness, and whether the output contains repetition or empty phrasing.
    5. Everyday and domain-specific Q&A. The focus is on whether interaction is concise, whether coverage of common questions is stable, and whether answers fit the specific scenario.

    The same tool may perform well on the first type of task and only average on the fourth. Recording results by task is the only way to avoid replacing specific judgments with an overall impression.

    3. Build an Evaluation Framework

    3.1 Evaluation Dimensions

    It is recommended to build a scorecard around the following six dimensions:

    • Accuracy: the proportion of key conclusions in answers that match the reference answer.
    • Traceability: whether key conclusions include verifiable evidence and whether that evidence can be independently checked.
    • Timeliness: for recent events, whether the answer states the time range of the information or uses external retrieval to obtain the latest materials.
    • Stability: whether the same question asked multiple times produces consistent conclusions and whether variation remains within an acceptable range.
    • Response speed: record time to first token and total output time separately.
    • Cost and availability: call cost, quota limits, failure rate, and timeout rate during peak periods.

    3.2 Building the Test Set

    Prepare 30 to 50 samples for each task type, covering both common questions and edge cases. Samples should come from real business scenarios as much as possible rather than being selected because they favor a particular tool. Each sample should retain a reference answer or scoring rubric and be labeled with a difficulty level.

    Once the test set is defined, it should be used consistently. It should not be arbitrarily expanded or reduced; otherwise, results from different periods cannot be compared horizontally.

    3.3 Scoring Rules

    Objective items can use automatic judgment, such as comparing numeric values or checking code execution results. Subjective items require human or judge-model scoring. A five-point scale is recommended, with at least two reviewers scoring independently and calculating scoring agreement.

    If another model is used as a judge, a subset of samples should be manually reviewed to confirm that its scoring standards are broadly consistent with human judgment. Otherwise, bias in the judge model itself may be mistaken for the performance of the model under evaluation.

    4. Example Batch Comparison Script

    The example below shows the basic structure of batch evaluation. ask_fn and judge_fn are implemented by the user according to their own access method; the script itself does not depend on any specific service.

    1. import csv
    2. import time
    3. from dataclasses import dataclass, asdict
    4. from statistics import mean
    5. from typing import Callable
    6. @dataclass
    7. class TestCase:
    8. task_type: str # Task type, e.g., "reasoning", "code", "retrieval"
    9. prompt: str # Input question
    10. reference: str # Reference answer or scoring rubric
    11. @dataclass
    12. class Result:
    13. model: str
    14. task_type: str
    15. prompt: str
    16. answer: str
    17. latency_s: float
    18. score: float
    19. def run_benchmark(
    20. models: list[str],
    21. cases: list[TestCase],
    22. ask_fn: Callable[[str, str], str], # (model name, question) -> answer
    23. judge_fn: Callable[[str, str], float], # (answer, reference) -> score from 0 to 5
    24. repeat: int = 3,
    25. ) -> list[Result]:
    26. """Call each model on each sample multiple times and record answers, latency, and scores."""
    27. results: list[Result] = []
    28. for model in models:
    29. for case in cases:
    30. for _ in range(repeat):
    31. start = time.perf_counter()
    32. answer = ask_fn(model, case.prompt)
    33. latency = time.perf_counter() - start
    34. score = judge_fn(answer, case.reference)
    35. results.append(Result(
    36. model=model,
    37. task_type=case.task_type,
    38. prompt=case.prompt,
    39. answer=answer,
    40. latency_s=round(latency, 3),
    41. score=score,
    42. ))
    43. return results
    44. def summarize(results: list[Result]) -> dict:
    45. """Summarize average score, average latency, and score variation by model and task type."""
    46. groups: dict[tuple[str, str], list[Result]] = {}
    47. for r in results:
    48. groups.setdefault((r.model, r.task_type), []).append(r)
    49. summary = {}
    50. for key, items in groups.items():
    51. scores = [i.score for i in items]
    52. summary[key] = {
    53. "avg_score": round(mean(scores), 2),
    54. "score_range": round(max(scores) - min(scores), 2),
    55. "avg_latency_s": round(mean(i.latency_s for i in items), 3),
    56. }
    57. return summary
    58. def save_raw(results: list[Result], path: str) -> None:
    59. """Save raw answers for later traceability and manual review."""
    60. with open(path, "w", newline="", encoding="utf-8") as f:
    61. writer = csv.DictWriter(f, fieldnames=list(asdict(results[0]).keys()))
    62. writer.writeheader()
    63. writer.writerows(asdict(r) for r in results)

    There are two points to note when using this. First, ask_fn should avoid hard-coded keys; keys should be read from environment variables or a key management service. Second, raw answers must be saved, because when scoring rules change, the answers need to be re-scored rather than re-fetched from the service.

    5. Usage Practices That Improve Results

    Evaluation measures model performance under a certain way of using it, and the usage method itself can significantly affect results. The following practices usually improve answer quality.

    • Specify the role, goal, and output format. For example, saying “from a technical review perspective, list three risks, each with an example” is more likely to produce usable results than simply saying “analyze this.”
    • Input long documents in sections. First ask the model to list an outline, then go deeper section by section. This reduces the probability of missing key information.
    • Require supporting evidence. For key facts, require sources to be cited and verified by the user rather than accepted directly.
    • Limit output length. Specify word counts or item limits to reduce redundancy and repetition.
    • Control multi-turn context. Keep necessary prior context when asking follow-up questions, and remove history unrelated to the current question to avoid old information interfering with new judgments.

    6. Common Pitfalls

    1. Mistaking a long answer for a good answer. Length does not mean the argument is sufficient. Check whether conclusions are supported and whether steps are complete.
    2. Drawing conclusions from a single result. The same question may produce inconsistent conclusions across multiple attempts. Use statistical values from multiple results.
    3. Ignoring data security. When internal code, customer information, or unpublished materials are involved, first confirm the service’s data retention and usage terms. When necessary, de-identify inputs or use a local deployment option.
    4. Ignoring version changes. Models and services are continuously updated, and conclusions from a previous evaluation may quickly become outdated. Regular re-testing is needed.
    5. Treating a single metric as the whole standard. A fast, low-cost option is not necessarily suitable for high-risk tasks. Selection should comprehensively consider the task’s tolerance for errors.

    7. Rollout Recommendations

    Teams can first establish a fixed test set and scorecard, then re-test whenever a model version is updated or service conditions change. Selection decisions should be based on comparison data, and different teams should be allowed to choose different tool combinations based on task type. This helps control costs while ensuring the quality and security of critical tasks.