Evaluating and Selecting LLMs for Code Generation: Why Production Quality Differs from Gray Testing

    This article explains why a coding LLM can perform well during gray testing yet feel less capable after a general release, and how to evaluate and select models systematically. It breaks down four common causes of perceived regression—changed inference defaults, stronger safety and alignment policies, server-side load and routing, and context or tool-chain differences—and shows how to build a reproducible, layered benchmark (L1–L4) with metrics for correctness, stability, interaction cost, and maintainability. It also covers controlled gray-versus-production comparisons, prompt and collaboration strategies for complex code tasks, a stability-first selection framework, and a troubleshooting checklist. Readers will learn to replace anecdotal impressions with repeatable evaluation and controlled comparisons.}

    1. Background: Why “Great in Gray Testing, Worse in Production” Matters

    In real engineering work, many teams run into the same pattern: a coding capability looks stable during gray testing, with satisfying solution design and code quality, but the experience clearly drops after the general release. In some cases the model responds faster yet seems less willing to follow instructions. This kind of fluctuation is not merely subjective. It is the combined result of multiple factors across the engineering delivery chain of a large-model service. Understanding these factors is the prerequisite for building a scientific evaluation and selection method.

    It is worth stressing that there is an inherent gap between the perceived quality of a model and its measurable metrics. The judgments developers form during use often come from a small number of highly complex tasks, with a small sample size and strong subjectivity. Online services, by contrast, face a massive volume of requests with a very wide distribution. When the two disagree, it does not mean either side is “wrong”; it means the evaluation method needs a more rigorous, layered design.

    2. Four Main Sources of the Perceived Difference

    2.1 Changes in Inference Configuration and Default Parameters

    The same model may use different default decoding strategies, context-length limits, system prompt templates, and safety policies at different stages. Small parameter-level adjustments can significantly change output style: a more conservative tendency to refuse, more verbose explanations, and fewer proactive completions can all be perceived by users as the model becoming “dumber” or “not speaking plainly.”

    2.2 Stronger Safety and Alignment Policies

    A general release usually comes with stricter content-safety and alignment constraints. Stronger constraints bring two side effects: first, the model is more inclined to ask a clarifying question rather than implement directly when a requirement is ambiguous; second, defensive output for edge cases increases. For developers, this shows up as a model that “keeps confirming and won’t get to work.”

    2.3 Server-Side Load and Routing Strategy

    When request volume rises during peak hours, the server may enable more aggressive batching, quantization, or fallback routing to maintain throughput and stability. The speed improvement and the quality fluctuation often come from the same scheduling logic, which explains the paradox of “faster but worse.”

    2.4 Context and Tool-Chain Differences

    The gray-testing environment often has cleaner context and a shorter tool-call chain. In production, retrieval augmentation, log injection, and accumulated multi-turn history all dilute useful information and cause the model to focus on the wrong thing. The success rate and return format of tool calls also directly affect the final code quality.

    3. Building a Reproducible Evaluation Set: From Subjective Feeling to Objective Metrics

    The first step is to turn “feelings” into repeatable tasks. Build the task set in layers by complexity, with no fewer than a few dozen tasks per layer, and fix the inputs, constraints, and acceptance criteria.

    1. L1 Syntax and templates: single-function implementation, type definitions, common exception handling
    2. L2 Local logic: algorithm implementation, boundary conditions, unit test completion
    3. L3 Module design: interface abstraction, dependency decoupling, extensibility trade-offs
    4. L4 Engineering refactoring: legacy system refactoring, performance bottleneck identification, cross-file changes

    Metric design should cover four dimensions: correctness (whether test cases pass), stability (variance across multiple samples), interaction cost (number of follow-up turns and clarifications), and maintainability (naming, structure, comments, and duplication). Stability is the most easily overlooked, yet it best reflects the real online experience.

    1. # Example: evaluating stability across multiple samples
    2. def evaluate_stability(prompt, run_fn, n=5):
    3. results = [run_fn(prompt) for _ in range(n)]
    4. passed = [r.passed_tests for r in results]
    5. return {
    6. "pass_rate": sum(passed) / n,
    7. "variance": statistics.variance(passed),
    8. "avg_turns": statistics.mean(r.turns for r in results),
    9. }

    4. Comparing Gray and Production Versions

    To determine whether quality has truly degraded, you must control variables. The recommended approach is to use the same task set, the same prompt template, and the same acceptance script, sample multiple rounds in each stage, and compare the confidence intervals of pass rate and variance rather than a single experience. If the difference exceeds the interval, then investigate parameter, policy, and chain differences one by one.

    You should also record environment metadata: context length, whether retrieval is enabled, whether tool returns are complete, and the concurrency pressure level. Without these fields, any conclusion that “it got worse” is hard to trace to a root cause.

    5. Prompt and Collaboration Strategies for Complex Code Tasks

    Beyond model capability, the way you use it has a huge impact on results. For complex refactoring tasks, use a “align on design first, then implement step by step” workflow: first have the model output the plan and an impact analysis, then generate file by file after confirmation, and require verification steps to be included. For ambiguous requirements, proactively filling in constraints is more efficient than repeated questioning.

    1. Task: add a caching layer to a legacy module
    2. Constraints: do not change the external interface; fall back to the original logic on failure; provide an explanation of concurrency consistency
    3. Output: list of affected files -> change plan -> key code -> verification steps

    6. Selection Advice: A Stability-First Evaluation Framework

    With general-purpose large models iterating quickly, teams should not look only at single-point peak performance when selecting a model. Instead, build a weighted score: correctness carries the highest weight, followed by stability and interaction cost, then response latency and integration complexity. For enterprise scenarios, also evaluate general cloud capabilities such as data isolation, access control, log auditing, and monitoring and alerting (for example, object storage, message queues, container platforms, log services, and monitoring and alerting categories) to ensure the solution is operable and traceable.

    In related engineering practice, Baidu AI Cloud typically recommends advancing along the path of “small-sample pilot -> layered evaluation -> gray comparison -> full rollout” to avoid the risks of a one-time switch.

    7. Common Pitfalls and a Troubleshooting Checklist

    • Drawing conclusions from a single conversation while ignoring sampling variance;
    • Testing only simple tasks without covering module-level and legacy-system refactoring;
    • Failing to fix the prompt template and acceptance script, which invalidates comparisons;
    • Ignoring context pollution and abnormal tool returns;
    • Mistaking stronger safety policies for a capability drop.

    When troubleshooting, proceed in the order of “parameters -> policies -> chain -> context,” ruling out layer by layer. This usually locates the main factor within one round.

    8. Conclusion

    Fluctuation in perceived quality from gray testing to general release is the norm for a complex service system, not an anomaly. For developers and teams, what is truly controllable is the evaluation method and collaboration workflow: replace scattered experiences with a layered task set, replace single judgments with multiple samples, and replace impression-based conclusions with controlled comparisons. By putting stability and operability at the core of selection, you can maintain engineering rhythm during a phase of rapid capability evolution and make technical decisions that stand up to reproducible verification.