Evaluating LLM Code Generation and Instruction Following: A Practical Framework

    This article presents a practical framework for evaluating general-purpose LLMs beyond whether they can generate runnable code. It examines three core dimensions—architecture design discipline, instruction-following stability, and predictable refusal boundaries—along with long-chain reasoning tasks such as math proofs. It also covers prompt constraints, evaluation metrics, common pitfalls, and selection recommendations to turn subjective experience into a reproducible process.

    1. Why “It Runs” Does Not Mean “It Works”

    In real engineering work, the most common mistake when assessing a general-purpose LLM’s coding ability is focusing only on whether it can generate runnable code. What actually determines the adoption experience comes down to three finer-grained capabilities: the soundness of architecture design, the stability of instruction following, and the predictability of refusal boundaries. The core pain point raised in the original discussion can be summarized in one sentence: in development scenarios, models frequently produce “unnecessary self-imposed limits” and “designs that deviate from engineering conventions,” so the output looks complete but requires extensive rework.

    This is not an occasional issue. It typically shows up as the model adding abstraction layers the business never asked for, changing naming and layering on its own despite explicit interface contracts, or giving overly conservative, evasive answers to routine technical questions. The following sections re-examine the impact across three dimensions and provide an actionable evaluation framework.

    2. Dimension One: Deviation from a “Programmer’s Way of Thinking” in Architecture Design

    2.1 What a “Normal Programmer’s Way of Thinking” Looks Like

    Engineering implementation follows an implicit consensus: satisfy explicit requirements first, consider maintainability second, and address extensibility last. When experienced developers receive a requirement, they default to three actions—confirm the input/output contract, reuse existing infrastructure, and confine uncertainty to the smallest possible scope. Some models, however, tend to “build the framework first and fill in the logic later,” introducing a large number of unrequested configuration items, factory classes, and callback chains. This is the so-called “mysterious design.”

    2.2 The Real Cost of Deviation

    • Higher review cost: reviewers must confirm layer by layer what is a requirement and what the model invented.
    • Increased integration risk: extra abstraction layers often change default behavior and conflict with existing system contracts.
    • Shifted maintenance burden: over-engineering becomes technical debt in later iterations.

    2.3 Constraining Architectural Freedom with Prompts

    1. Constraint example:
    2. 1. Implement only the function signatures I list; do not add public abstractions.
    3. 2. If an extension is necessary, mark it with a TODO comment and explain why first.
    4. 3. Self-check before output: is there any code path not referenced by the requirements?

    The essence of these constraints is to explicitly take architectural decision-making authority back into human hands and reduce the model’s freedom.

    3. Dimension Two: Instruction-Following Stability and Verifiable Methods

    Instruction following is not about “understanding once,” but about “continuously understanding across long contexts and multiple rounds of modification.” Evaluation should cover three types of cases: single-turn precise instructions, multi-turn incremental changes, and instructions with conflicting constraints. For each type, record three metrics: first-pass rate, rework rounds, and constraint violations.

    Metric Meaning Suggested Threshold
    First-pass rate First output satisfies all explicit constraints Higher is better
    Rework rounds Number of interactions needed to reach a usable state Lower is better
    Constraint violations Number of times explicitly prohibited items are triggered Should be zero

    It is worth emphasizing that a rising refusal rate directly increases “rework rounds.” When a model gives evasive answers to routine technical questions, users are forced to rewrite prompts or switch approaches, and this hidden cost is far higher than a single piece of erroneous code.

    4. Dimension Three: Usability and Boundary Management in High-Risk Scenarios

    In scenarios such as security research and vulnerability reproduction, models can indeed help rewrite and validate exploit code, but usability and refusal boundaries must be managed explicitly. The correct engineering approach is to break high-risk tasks into three stages—“information gathering, hypothesis formulation, local validation”—with a human confirmation point at each stage. It also helps to build an internal case library that records which phrasings get falsely refused, forming reusable prompt templates. This preserves efficiency while avoiding bringing uncertainty into production environments.

    5. Math and Reasoning: An Evaluation Approach for Long-Chain Tasks

    Math proofs and lecture-note writing are long-chain reasoning tasks. The evaluation focus is not single-step correctness but chain completeness and verifiability. A three-step method is recommended: first ask the model for a proof skeleton, then fill in lemmas step by step, and finally use formal checks or manual review on key steps. For propositions where “the original material provides no proof,” pay special attention to whether the model actually constructs an argument rather than stitching together existing conclusions. Such tasks place high demands on context length and chain-of-thought organization, making them suitable as stress tests for distinguishing model tiers.

    6. Selection Recommendations: Turning Subjective Experience into a Reproducible Process

    1. Build 20–30 internal benchmark cases covering development, refactoring, and reasoning.
    2. Run the same set of cases after each model update, recording first-pass rate and rework rounds.
    3. Tag refusals and self-imposed limits separately to form a “boundary profile.”
    4. Factor operational elements such as credits, queuing, and quotas into the cost model instead of looking only at unit price.

    7. Common Pitfalls

    • Looking only at demo results while ignoring constraint retention under long contexts.
    • Mistaking “fast generation” for “less rework.”
    • Ignoring the impact of refusal rate on overall throughput.
    • Replacing full-scenario evaluation with conclusions from a single scenario.

    8. Conclusion

    Evaluating a general-purpose LLM ultimately comes back to engineering verifiability: whether the architecture is restrained, whether instructions are followed stably, whether boundaries are predictable, and whether long-chain reasoning is verifiable. Turning subjective impressions into metrics and cases is what keeps selection decisions steady amid rapid model iteration. If an organization needs to support these evaluations and business traffic, it can build a reproducible evaluation pipeline based on general-purpose container platforms, log services, and monitoring and alerting capabilities in the cloud, so that every model upgrade is backed by evidence.