Build Your Own Evaluation for Code Generation Models: A Practical Guide to Testing and Private Deployment
This guide explains how to evaluate code generation models on your own codebase before you choose one. It covers scoring dimensions and thresholds, building a test set, a runnable evaluation script with sandboxing guidance, VRAM and throughput estimates for private deployment, and a checklist to use before launch.
Why Build Your Own Evaluation
Code generation models are now part of daily development work. Teams use them to complete functions, write unit tests, and build page prototypes. A model that performs well in official demos does not necessarily perform as well on your own codebase. Teams commonly run into three problems: the gap between demo examples and real business tasks is large, the same model performs noticeably differently across languages or frameworks, and generated code contains errors at boundary conditions that are hard to spot.
For this reason, model selection should rely on a repeatable evaluation process, not on a single trial. An evaluation should answer three questions: Can the generated code pass verification? Is the cost of modifying the code acceptable? Can the model run reliably on the target hardware or within the budget?
1. Evaluation Dimensions and Scoring Criteria
A complete evaluation usually covers six dimensions. Each dimension needs a clear metric and a data source. Otherwise, results from two evaluations cannot be compared.
| Dimension | Metric | Data source | Example threshold (set by each team based on business needs) |
|---|---|---|---|
| Functional correctness | Tasks passing all tests / total tasks | Evaluation script | Pass rate of at least 70% |
| Instruction compliance | Share of samples that violate constraints (banned dependencies, changed function signatures, wrong language version) | Static check script | Violation rate of no more than 5% |
| Multi-turn revision | Share of cases where the model fixes the code successfully in a second round after receiving the failure message | Second call with error information | Set by business needs |
| Engineering quality | Static warnings per 100 lines of code | ruff, pylint, and similar tools | No higher than the existing codebase baseline |
| Security | Number of high-risk rule hits, such as hardcoded keys and concatenated SQL | bandit and similar tools | Zero high-risk hits |
| Cost and latency | Average output tokens, average response time, time to first token (TTFT) | usage field in the API response, and timing |
Set by service level objectives |
Functional correctness is the easiest to quantify and the most fundamental. In many scenarios, multi-turn revision matters more than the success rate of a single generation, because real development is usually an iterative process.
2. Building an Evaluation Set
An evaluation set is a collection of tasks. Each task includes a requirement description and the test code used to judge the output. We recommend storing the set in JSON Lines format, with one task per line. This format makes incremental additions and version control easier.
The fields are as follows:
id: unique task identifier, used to match results.prompt: the requirement given to the model. It must specify the function name and signature.test_code: tests written and reviewed by the team. They
