Evaluating Code LLMs: A Reusable Model Selection Method
Selecting a code LLM requires testing it on your own repository tasks, not relying only on public leaderboards. This article presents a reusable evaluation method covering long-context instruction following, long-horizon stability, and token efficiency; test cases for multimodal and financial-modeling tasks; a weighted scoring rubric and record table; unit task cost calculation; how to use public leaderboards; and practical selection recommendations.
Why Code Models Need Dedicated Evaluation
Many teams choose models by looking only at public leaderboards. Leaderboard scores show how a model performs on certain types of problems, but they do not directly show whether it can work reliably in your own code repository. Real programming tasks usually require reading dozens of files, remembering project constraints, and making changes across multiple rounds. These conditions rarely appear in leaderboard problems. Therefore, before selecting a model, you should test it on your own tasks.
1. Three Core Metrics
1.1 Long-Context Instruction Following
In real development, the context is often filled with requirement documents, existing code, and style guidelines. For testing, you can put three to five explicit constraints at the beginning of the prompt, such as “do not modify external interfaces” or “follow the project’s existing error-handling approach.” Then add a large amount of unrelated code in the middle, and finally issue the specific task. Check whether the model still follows the constraints at the beginning. The longer the context, the more likely a model is to forget earlier conditions or contradict itself. This is exactly the situation the test should focus on.
1.2 Long-Horizon Task Stability
A programming task usually includes requirement understanding, solution design, code writing, self-testing, fixing, and iteration. During evaluation, observe three things:
- Whether the model deviates from the technical solution established at the beginning;
- Whether features that passed earlier regress after multiple rounds of modification;
- When an error occurs, whether the model first identifies the cause or repeatedly tries unrelated changes.
1.3 Token Efficiency
Some reasoning models produce long reasoning processes even on simple problems, increasing output token volume. In token-billed scenarios, this directly affects cost. During testing, record the number of input tokens and output tokens for each task, and calculate the proportion of reasoning in the output to determine whether redundant reasoning is concentrated in specific cases.
2. Test Case Design
2.1 Multimodal Cases: Confirm Model Capabilities First
A common type of case is to ask the model to watch a reference video and then implement a physics-based smoke or fluid simulation page with interactions such as audio upload and microphone input. This type of case can examine multimodal understanding, solution design, and iteration capability. However, it has a prerequisite: the selected model must support image or video input. Models vary widely in supported image and video formats, file size limits, and frame-count caps. Therefore, before starting the test, verify the input specifications in the official documentation item by item.
If a candidate model accepts only text, switch to a text requirement. For example, provide a text specification and parameter table for particle motion, and ask the model to implement a simulation based on them. The scoring dimensions for the same type of task should remain consistent so that results can be compared across models.
During evaluation, focus on three points: whether the motion effect matches the described physical intuition, whether the mapping between audio and visual parameters is clear, and whether the code structure is easy to modify later. Pixel-perfect reproduction should not be a primary scoring criterion.
2.2 Engineering Cases: Linked Financial Statements
Financial modeling cases have little visual output, but they are closer to everyday enterprise development work. You can ask the model to build a linked model of the balance sheet, income statement, and cash flow statement, and provide a set of historical data and several assumption parameters. During validation, check the following items one by one:
- Whether the balance sheet balances, that is, total assets equal total liabilities plus owners’ equity, with zero error;
- Whether net income from the income statement correctly flows into the retained earnings item under owners’ equity;
- Whether ending cash in the cash flow statement matches cash and cash equivalents on the balance sheet;
- Whether abnormal inputs are handled, for example, whether the model raises an error or gives a warning when a divisor is zero, accounts receivable is negative, or a growth rate is outside a reasonable range.
3. Scoring Rubric and Record Table
Score each dimension from 0 to 5, then multiply by its weight to get a weighted score. The maximum composite score is 5. The pass rule is: the composite score must be at least 3.5, and every dimension must meet its own pass line.
| Dimension | Weight | Scoring Focus | Pass Line |
|---|---|---|---|
| Instruction following | 25% | Proportion of constraints preserved in long context | 4 |
| Completeness | 25% | Requirement coverage and number of edge cases handled | 3 |
| Code quality | 20% | Readability, modularization, comment completeness | 3 |
| Token efficiency | 15% | Input and output token volume at equivalent completeness | 3 |
| Iteration stability | 15% | Regression of previously passed features after multiple rounds | 3 |
Each test should leave one record containing the following fields: task ID, model name and version, reasoning mode (on or off), input token count, output token count, iteration count, failure reason (if any), and scores for each dimension.
An example record is as follows. The task ID is FIN-01, the candidate model is Model A v1, reasoning mode is on, input is 12,000 tokens, output is 8,500 tokens, and there are 4 iterations. The failure reason is that after the third-round modification, ending cash in the cash flow statement did not match the balance sheet. The five dimension scores are 4, 3, 4, 3, and 2. The weighted score is 4×0.25 + 3×0.25 + 4×0.2 + 3×0.15 + 2×0.15 = 3.3, which is below 3.5, so the model fails.
Calculating Unit Task Cost
Token cost can be calculated as follows:
Unit task cost = input tokens × input unit price + output tokens × output unit price + retry cost
Retry cost refers to the token fees actually consumed by failed rounds. Using the example above, assume the input price is CNY 2 per million tokens and the output price is CNY 8 per million tokens. The input portion is CNY 0.024, the output portion is CNY 0.068, and the two total CNY 0.092. If the retry cost is CNY 0.03, the unit task cost is CNY 0.122. The prices here are for demonstration only; actual calculations should use the vendor’s current quote.
4. Relationship with Public Leaderboards
Public leaderboards provide directional reference, but before citing them directly, record the leaderboard name, version, release date, and task type. The team’s primary scenarios determine the weight of leaderboards. If the primary scenario is automated Agent pipelines, increase the weight of Agentic tasks. If the primary scenario is single code completion, increase the weight of single-generation metrics.
Vendor efficiency claims should also be reproduced. For example, if a vendor claims that a version reduces token consumption on long-horizon tasks, the team can select its own task set, run the old and new versions with the same prompts, and compare the mean and distribution of input and output tokens to determine whether the reduction holds.
5. Selection Recommendations
First, define the scenario. Code completion, Agent pipelines, solution design, and legacy code refactoring impose different requirements on models, so models should be selected separately by scenario.
Second, test differences in reasoning modes. Some models perform close to the previous generation when deep-thinking mode is off. Before integration, test both modes separately to find the balance between quality and cost.
Third, calculate cost clearly. If a vendor offers an accelerated version, calculate unit task cost based on actual pricing and measured latency. Interactive coding assistants may care more about response speed, while offline batch jobs care more about unit price.
Fourth, evaluate private deployment options. Open-source weights can be deployed on your own compute, and sensitive code does not need to leave the organization’s infrastructure. However, private deployment requires additional evaluation of operational overhead and inference performance; do not look only at model scores.
Conclusion
Competition among code models is shifting from benchmark scores to real engineering performance. By putting instruction following, long-horizon stability, and token efficiency into one scoring system and testing with your own tasks, teams can keep making judgments as models update rapidly. This method also has limitations: weights need to be adjusted for the team’s business, public leaderboards and vendor data are only references, and final conclusions should be based on your own test results.
