Evaluating Local LLMs for Coding: A Reproducible Methodology and Selection Framework

    This article presents an engineering approach to evaluating local large language models for coding tasks. Instead of relying on subjective scoring or a single benchmark, it fixes the hardware, task set, and scoring script so that only the model and quantization scheme vary. A three-layer task set covers tool calling, defect repair, and end-to-end application builds, while machine scoring and four objective metrics—wall-clock time, interaction turns, output tokens, and prompt cache hit rate—make results reproducible. Comparing 4-bit integer, 4-bit float, and 8-bit float quantization reveals distinct working patterns and cost structures, leading to a scenario-based selection matrix and a dual-track workflow, plus common pitfalls and engineering recommendations.

    1. Why Local Coding Evaluation Needs a New Paradigm

    When teams introduce large language models into the development workflow, the most common question is not “Can the model write code?” but “Under my hardware budget, which combination of quantization and model can deliver reliably at an acceptable cost?” Traditional approaches rely on subjective scoring or a single benchmark task, and the results are often affected by prompts, reviewer preferences, and random factors, making them hard to reproduce. A more reliable approach is to treat evaluation as an engineering experiment: fix the hardware, fix the task set, and fix the scoring script, so that only the variables under test—the model and quantization scheme—change.

    One representative experiment used a local inference environment with dual accelerator cards and compared three lightweight models positioned as “Flash” models, each corresponding to a common quantization route in the industry: 4-bit integer quantization, 4-bit float quantization, and 8-bit float quantization. It is worth emphasizing that this article does not evaluate any specific product. Instead, it abstracts the experiment into a methodology that helps readers reproduce it in their own environments and reach conclusions that fit their own teams.

    2. Evaluation Design: Making Scores Reproducible

    1. Three-Layer Task Set

    • Tool-calling layer: the model is required to call 21 native tools as an agent, covering basic capabilities such as file read/write, command execution, retrieval, and test execution, to check whether its “hand-eye coordination” is reliable.
    • Defect-repair layer: defect-repair tasks from 17 real projects, examining localization, minimal changes, and regression awareness.
    • End-to-end build layer: building a complete web application from scratch with 19 check items, examining planning, layering, and self-verification capabilities.

    The point of the three-layer structure is that a single-layer benchmark tends to reward models that “can talk,” while combined tasks expose models that “can do.”

    2. Scoring and Cost Control

    Scoring is fully automated by machines, with no LLM judge introduced, avoiding reviewer bias and extra overhead. At the same time, four objective metrics are recorded: wall-clock time, number of interaction turns, total output tokens, and prompt cache hit rate. The first two reflect experience, while the latter two directly determine the compute bill.

    The metric-collection logic can be simplified as follows:

    1. metrics = {
    2. "wall_clock_min": elapsed(), # end-to-end elapsed time
    3. "turns": len(trace), # number of interaction turns
    4. "output_tokens": sum(t.out for t in trace),
    5. "cache_hit_rate": cached_prompt / total_prompt,
    6. }
    7. score = checks_passed / checks_total # machine scoring, no human involvement

    3. Behavioral Differences Across the Three Quantization Routes

    All three models passed every test, but their working modes were completely different, which shows that “can it do it” and “how it does it” are equally important.

    • 4-bit integer quantization version: extremely concise output, only about 20,000 tokens in total, and the shortest end-to-end build time (just over 18 minutes). Even though the underlying inference engine’s throughput was not the best, the low output volume still won it the best overall speed. Suitable for prototype validation and quick drafts.
    • 8-bit float quantization version: the fewest interaction turns (about 77), tending to produce a plan first and then execute step by step, with the best process readability; the prompt cache hit rate was above 90%, repeated context was almost free, and the compute cost per task was the lowest, making it suitable for long-running unattended background autonomous execution.
    • 4-bit float quantization version: a large amount of internal reasoning in every turn, the longest time (over 27 minutes), but the most standardized code and the most test cases (18), with the best engineering quality, making it suitable as a “hardening” step before delivery.

    A counterintuitive but important conclusion is that time and quality are not linearly related. Output volume, turns, and cache hits together determine the real cost, while the depth of internal reasoning mainly affects defect rate and maintainability.

    4. Selection Framework: Mapping Metrics to Scenarios

    Scenario requirement Priority metrics Recommended route
    Daily iteration, balance of cost and efficiency Cache hit rate, turns 8-bit float quantization
    High standardization, high test coverage Number of test cases, defect rate 4-bit float quantization
    Fastest route to a runnable prototype Output tokens, wall-clock time 4-bit integer quantization

    In practice, a “dual-track” approach is recommended: use a low-output, low-cost route for exploration and drafts, and a deep-reasoning route for review and hardening, with the two aligned through a unified automated scoring script. If a team uses relevant capabilities from Baidu AI Cloud, the evaluation scripts, logs, and metrics can be placed in general categories such as container platforms, log services, and monitoring and alerting, enabling task orchestration, traceability, and dashboards without binding to any proprietary interface.

    5. Common Pitfalls and Engineering Recommendations

    1. Looking only at total time: ignoring output volume and cache hits leads to mistaking “fewer words” for a “faster engine.”
    2. Ignoring regression cost: defect-repair tasks must come with regression tests, otherwise minimal changes may introduce new problems.
    3. Unstable prompts: fix the system prompt and tool descriptions, otherwise cross-model comparison loses meaning.
    4. Coupling of hardware and quantization: the quantization scheme changes memory usage and throughput, so reported conclusions should be tied to a specific hardware configuration.
    5. Missing reproducible scripts: version the scorer, task set, and random seeds together so that conclusions can be verified by others.

    Overall, local lightweight models are already usable in coding agent scenarios, and the real differences lie in working modes and cost structures. With a fixed task set plus machine scoring as the backbone, and a selection matrix built around the four metrics of time, turns, output volume, and cache hits, teams can make explainable and reproducible trade-offs among efficiency, cost, and engineering quality.