Methodology and Practices for Evaluating LLM Programming and Creative Capabilities

    This article explores methodologies for evaluating Large Language Models (LLMs) from an engineering perspective, focusing on high-frequency tasks like programming and creative writing. It discusses why parameter size alone is insufficient for model selection, details specific evaluation dimensions, sample set design, and automated and manual evaluation processes. The goal is to provide a reproducible and interpretable evaluation framework to help teams make informed technical decisions based on actual output quality.

    Introduction

    LLM capability evaluation has become a standard step in technology selection. However, many teams still rely on parameter size and public benchmark rankings as their primary criteria, though the correlation between these metrics and actual business outcomes is often inconsistent. From an engineering perspective, this article discusses how to design a reproducible and interpretable evaluation framework, focusing on two high-frequency task categories: programming and creative writing.

    1. Parameter Size Is Not a Sufficient Selection Criterion

    Parameter count reflects the upper limit of a model’s capacity but does not directly indicate its performance on specific tasks. Factors such as training data distribution, instruction tuning quality, long-context handling, and output format stability all affect the final results. Models of the same parameter scale can perform vastly differently in code generation versus copywriting. Therefore, evaluation should return to the task itself, using output quality as the primary judgment criterion.

    2. Define Evaluation Dimensions

    Before evaluating, the concept of “good” must be decomposed into scorable, specific dimensions.

    2.1 Programming Capabilities

    • Functional Correctness: Whether the generated code passes preset test cases. This is the most basic and easily quantifiable metric.
    • Readability: Whether variable naming, function partitioning, and comments are clear and comply with team code styles. Poorly readable code increases maintenance costs even if it runs.
    • Boundary Handling: Whether edge cases like empty inputs, oversized inputs, or type exceptions are considered. Many generated codes fail under boundary conditions while working fine with normal inputs.
    • Contextual Understanding: When modifying existing code snippets, whether the model only changes the necessary parts instead of rewriting everything and introducing irrelevant changes.
    • Security Awareness: Whether there are obvious injection risks, hardcoded credentials, or insecure default configurations.

    2.2 Creative Writing Capabilities

    • Requirement Alignment: Whether constraints in the prompt, such as word count, tone, target audience, and prohibited content, are accurately met.
    • Structural Completeness: Whether the introduction, development, and conclusion connect naturally, with clear logical relationships between paragraphs.
    • Language Quality: Whether word choices are accurate and free of repetitive expressions, clichés, or grammatical errors.
    • Originality: Whether the text heavily copies common templates or shows obvious traces of existing texts.
    • Multi-turn Consistency: After modifications based on feedback, whether character settings, narrative perspectives, and terminology usage remain stable.

    3. Sample Set Design

    Sample quality determines the credibility of evaluation conclusions.

    • Coverage: Programming tasks can include string processing, data structure operations, API data parsing, and concurrency basics. Creative tasks can include short copywriting, story fragments, polishing/rewriting, and style imitation.
    • Difficulty Stratification: Divide samples into easy, medium, and hard tiers, keeping the quantity balanced. This allows observation of the model’s performance degradation curve across different difficulties rather than just getting an average score.
    • Mitigate Data Leakage Risks: Prioritize self-authored prompts. If using public prompts, check if they have appeared in the model’s training corpus; otherwise, scores will be artificially inflated.
    • Version Management: Once samples are published or used for decision-making, record their version numbers. Subsequent comparative experiments are only meaningful if conducted on the same sample version.

    4. Automated Evaluation Process

    Programming tasks are suitable for fully automated evaluation. Below is a simplified evaluation framework for comparing a generated function’s performance across a set of test cases.

    1. from dataclasses import dataclass, field
    2. from typing import Any, Callable, List, Tuple
    3. @dataclass
    4. class TestCase:
    5. args: Tuple[Any, ...]
    6. expected: Any
    7. @dataclass
    8. class EvalResult:
    9. task_id: str
    10. passed: int
    11. total: int
    12. errors: List[str] = field(default_factory=list)
    13. @property
    14. def pass_rate(self) -> float:
    15. return self.passed / self.total if self.total else 0.0
    16. def evaluate_function(task_id: str, func: Callable, cases: List[TestCase]) -> EvalResult:
    17. result = EvalResult(task_id=task_id, passed=0, total=len(cases))
    18. for case in cases:
    19. try:
    20. actual = func(*case.args)
    21. except Exception as exc:
    22. result.errors.append(f"{type(exc).__name__}: {exc}")
    23. continue
    24. if actual == case.expected:
    25. result.passed += 1
    26. else:
    27. result.errors.append(
    28. f"input={case.args}, expected={case.expected!r}, got={actual!r}"
    29. )
    30. return result
    31. # Example: evaluating a word-reversing function
    32. def reverse_words(s: str) -> str:
    33. return " ".join(reversed(s.split()))
    34. cases = [
    35. TestCase(args=("hello world",), expected="world hello"),
    36. TestCase(args=("",), expected=""),
    37. TestCase(args=(" a b ",), expected="b a"),
    38. ]
    39. print(evaluate_function("reverse-words-001", reverse_words, cases).pass_rate)

    Note that the code above assumes the function is already loaded into the current process. In actual evaluations, code generated by the model is untrusted input and must be executed in an isolated environment first. The isolated environment should restrict network access, CPU time, and memory usage, and be destroyed after each task. Otherwise, malicious or anomalous code could compromise the evaluation machine itself.

    Creative writing tasks are difficult to fully automate but can undergo rule checks first, followed by manual scoring:

    • Count words to determine if they fall within the required range;
    • Check for required keywords and prohibited words;
    • Detect paragraph count, punctuation usage, and repetitive sentence structures;
    • Calculate similarity with known texts for long texts to assist in judging originality.

    Rule checks cannot replace the judgment of language quality; their role is to filter obviously unqualified outputs and reduce manual workload.

    5. Manual Review and Consistency Control

    Creative writing and some complex programming tasks require manual scoring. To reduce subjective bias, the following practices can be adopted:

    1. Blind Review: Reviewers do not know which model or version the output comes from, focusing only on the text content.
    2. Unified Scale: Use a 1-to-5 scale for each dimension and specify the criteria for each score. For example, “Requirement Alignment: 5 points” can be defined as “fully meets all constraints with no extraneous content.”
    3. Multi-person Scoring: Arrange at least three reviewers to score independently, then calculate inter-rater reliability. Samples with low consistency should be discussed, and the criteria unified before re-scoring.
    4. Regular Calibration: Before each review round, conduct a trial evaluation using a set of samples with prior consensus to ensure reviewers have a consistent understanding.

    6. Common Pitfalls

    Single Sampling. LLM outputs are stochastic; a single result might be accidentally high or low. Sample the same prompt multiple times and report the mean and variance.

    Inconsistent Prompts. If different models use different system prompts, temperature parameters, or output length limits, the comparison is meaningless. Fix all controllable variables in comparative experiments and list the complete configuration in the report.

    Focusing Only on Pass Rate. Code passing tests doesn’t mean it can be merged directly. Readability, complexity, and security must also be evaluated.

    Focusing Only on Fluency. Creative text reading smoothly doesn’t mean it meets requirements. Requirement alignment and structural completeness often determine actual value more than surface-level fluency.

    Sample Leakage. When using public prompts, the model may have seen similar content. Regularly update some self-built samples and compare performance differences between old and new samples.

    7. Implementation Recommendations

    • Establish a small-scale baseline sample set covering main business scenarios, updating it weekly or monthly.
    • Integrate evaluation scripts into the continuous integration pipeline to run automatically when the model version, prompts, or inference parameters change, detecting regressions promptly.
    • Feed back online data, such as code review rejection rates and user rewrite ratios, into the weight design of evaluation dimensions, making offline evaluations closer to real-world usage.
    • When evaluation results of two models are close, incorporate cost, response latency, data privacy compliance requirements, and deployment methods into the comprehensive judgment. Evaluation scores are just one input for decision-making.

    Conclusion

    The core of LLM evaluation lies in transforming the vague concept of “good performance” into observable and reproducible metrics. As long as dimensions are clearly defined, samples are reliable, and processes are controllable, teams can continuously determine whether a model meets their needs at a low cost.