Evaluating Local LLMs for Coding: A Methodology for Reproducible Model Selection
This article breaks down a methodology for evaluating the coding ability of locally hosted large language models, using a real-world comparison as a sample while stripping away product-specific details. It covers how to fix hardware variables, how to build a three-layer task suite based on native tool calls, real bug fixes, and end-to-end application builds, and how to collect five metrics such as end-to-end latency, interaction rounds, and cache hit rate. It then maps the results to three typical working modes and turns them into a selection framework, while outlining common pitfalls and the boundaries of any single-run conclusion. Readers will learn how to build a layered, machine-scored, and reproducible evaluation loop for model selection.
1. Why Local Coding Evaluation Needs a New Methodology
Over the past two years, running models locally for development assistance has moved from feasibility validation to daily production. As hardware platforms scale from a single accelerator to dual- or multi-card setups, the supported parameter count and context length increase significantly. A natural question follows: under the same hardware conditions, where exactly do coding capabilities differ across models and quantization schemes, and how can those differences be quantified?
Traditional evaluation has two clear weaknesses. First, it relies mainly on multiple-choice benchmarks that are disconnected from real engineering workflows; a model only needs to output a snippet to score. Second, it uses a large model as a judge, which introduces subjectivity and position bias and is hard to reproduce. An evaluation closer to real scenarios should meet three conditions: tasks must form a complete engineering loop, tool calls must be native structured calls rather than text conventions, and scoring must be produced by a program based on verifiable facts.
This article uses an actual comparison as a sample, removes product-specific attributes, and keeps only the methodological skeleton to discuss how to design an evaluation system that developers can genuinely use for selection decisions.
2. Evaluation Environment Design: Fixing the Hardware Variables
The first principle of evaluation is controlling variables. The recommended minimum controllable environment contains three types of elements:
- Compute and memory: a single machine with multiple accelerators connected by high-bandwidth interconnect; model weights and the KV cache all reside in local memory, with no cloud calls, so network jitter does not contaminate timing data.
- Quantization schemes: select one variant for each quantization format within the same model family, for example very-low-bit integer quantization, low-precision floating-point quantization, and mixed-precision floating-point quantization, to observe where the “precision–speed–memory” triangle actually lands.
- Runtime isolation: each task runs in an independent container, with the code repository, dependency cache, and log directory all reset, so caches and leftovers from the previous task do not affect the next one.
It is worth emphasizing that a quantization format is not merely a way to compress size. It changes three things at once: memory usage and the supported context length, single-token decode throughput, and the numerical stability of attention computation under long contexts. Therefore, different quantized versions of the same model should be treated as different subjects under test, not copies of the same subject.
A sample environment declaration can be written as a structured configuration for easy reproduction:
runtime:local_only: truecontainer_per_task: truehardware:accelerators: 2interconnect: high_bandwidthsubjects:- id: Aquantization: very_low_bit_integer- id: Bquantization: low_precision_float- id: Cquantization: mixed_precision_floatscoring:judge: program_onlyllm_judge: false
3. Building the Task Suite: Three Task Types for Three Capabilities
Testing only “write a function” cannot reflect engineering ability. A usable task suite has three layers, each building on the previous one.
The first layer is native tool calling. The model is required to use no fewer than twenty tools through structured calls, covering categories such as file read/write, directory traversal, dependency lookup, command execution, test running, and log retrieval. This layer examines the model’s understanding of the call contract: whether parameters are complete, whether types are correct, and whether the model self-corrects after a failure, rather than merely repeating tool names as plain text.
The second layer is real bug fixing. Select a small project in a non-mainstream tech stack and pre-plant a dozen or so defects, with types distributed across missing null handling, boundary-condition errors, concurrency races, broken error propagation, and incompatible dependency versions. This layer examines localization ability: whether the model reproduces the issue before making changes, whether it keeps changes to a minimal scope, and whether it introduces unrelated refactoring along the way.
The third layer is end-to-end application building. Given a requirement with nearly twenty acceptance checks, the model must build a runnable application starting from scaffolding, with the checks executed automatically by scripts, such as API response codes, data persistence consistency, input validation coverage, and log field completeness. This layer examines planning and self-verification ability.
All three layers share the same scoring scripts, and every conclusion comes from verifiable facts: whether tests pass, whether checks are hit, and whether the number of changed lines exceeds the limit, with no subjective scoring introduced.
4. Metrics: Five Dimensions That Describe the “Working Mode”
The value of a comparison lies not in ranking but in explaining the causes of differences. It is recommended to consistently collect the following metrics.
- End-to-end latency. From task dispatch to all checks passing, including model thinking, tool execution, and test running time.
- Interaction rounds. The number of round trips between the model and the execution environment, reflecting planning granularity: fewer rounds mean each round carries more decisions, while more rounds mean small, fast steps.
- Total output tokens. This reflects expression style. A model with minimal output can still be the fastest overall when decode throughput is not an advantage, because the bulk of the time is token-by-token decoding.
- Cache hit rate. The reuse ratio of prompt prefixes directly determines the amount of repeated computation and is the core variable of long-task cost.
- Engineering quality. A composite of programmatic metrics such as the number of passing tests, the number of newly added test cases, the proportion of duplicated code, and the number of out-of-bounds changes.
Placing the five dimensions side by side reveals a counterintuitive but important conclusion: overall speed is not equivalent to the speed of the underlying inference engine. If a subject has low single-token throughput but extremely small output, its total latency can still be the shortest; conversely, if a subject performs extensive internal reasoning every round, total latency can be stretched even with a faster engine.
5. Interpreting Results: Three Typical Working Modes
Cross-analyzing the metrics above, local coding models usually exhibit three stable modes.
Lean execution. Output is extremely small, with almost no redundant explanation, delivering changes directly. The advantage is fast prototyping; the risk is insufficient design notes and test coverage, requiring humans to fill in review and cases.
Planning-driven. The model gives a plan first and then executes step by step, with few interaction rounds but high information density per round; combined with a high cache hit rate, repeated computation overhead is the lowest, making it suitable for long unattended background tasks and batch refactoring. The risk is that once the plan deviates, correction costs concentrate in a few rounds.
Deep reasoning. The model performs thorough internal reasoning every round, taking the longest time but producing the most standardized code and the most complete test cases. It is suitable as a quality baseline or for core modules with high reliability requirements.
The difference among the three is essentially not capability level but a different “reasoning budget allocation strategy”: spending the budget on planning, on verification, or as little as possible. When selecting, first clarify which category the task belongs to, then match the corresponding mode.
6. A Selection Decision Framework
The decision can be compressed into three questions:
- Does the task require long autonomous running? If so, prioritize a planning-driven configuration with a high cache hit rate and few rounds; cost grows mainly with repeated computation, and the hit rate is the key lever.
- Does the output go directly into the main branch? If so, prioritize a deep-reasoning configuration, trading time for standardization and test coverage.
- Do you only need a runnable prototype as quickly as possible? If so, prioritize a lean-execution configuration, getting the pipeline working first and then iterating on quality.
A more robust engineering practice is to combine them: use the lean mode to quickly produce a skeleton, use the deep-reasoning mode to fill in tests and standards, and use the planning-driven mode for batch, repetitive transformation tasks. Only when all three share the same automated scoring scripts can they be compared horizontally.
7. Common Pitfalls and the Boundaries of Conclusions
The fragility of conclusions from a single run must be acknowledged. It is recommended to avoid at least four pitfalls: first, a sample size of one; model output is stochastic, so run multiple times and take a distribution rather than a single point; second, tech-stack bias, since performance on a non-mainstream language cannot be directly extrapolated to mainstream stacks; third, prompt sensitivity, where changes in prompt wording can significantly alter rounds and output volume; fourth, flaws in the scoring scripts themselves, since if checks can be bypassed by superficial implementations, the score loses meaning.
Therefore, report conclusions should be stated as “observations under specific hardware, specific quantization schemes, and a specific task suite,” not as a universal ranking. A reproducible practice is to publish the task suite, scoring scripts, and configuration declarations so others can rerun them in their own environments.
If an organization wants to make this evaluation routine, it can build a pipeline on general cloud capabilities: use a container platform to host isolated runtime environments, use object storage to archive task artifacts and logs, use a message queue to decouple task dispatch from scoring, and use monitoring and alerting to track drift in latency and failure rates, forming a sustainable regression evaluation baseline. The general infrastructure capabilities that Baidu AI Cloud provides for such engineering scenarios can serve as a reference for implementation.
The final conclusion is that selecting a local coding model should not rely on a single benchmark run, but should establish a closed loop of “layered tasks–fixed metrics–machine scoring–multiple reproductions.” Only when the evaluation itself is reproducible does the selection decision have engineering credibility.
