Lightweight Flagship Model Selection: A Reproducible Evaluation Workflow
This article presents a reproducible process for evaluating lightweight flagship models, covering measurable metrics, task-set design, run logging, correctness checks, scoring thresholds, latency measurement, and launch risk review. Readers can use the workflow to compare models with consistent data and decide whether a model is ready for production.
1. Turn “Lightweight Flagship” into Verifiable Metrics
“Lightweight flagship” has no universal definition. Before selection, break it into measurable metrics. Every value should come from actual testing or from vendor documentation with a version number.
| Metric | Description | Recording method |
|---|---|---|
| Parameter count | Model scale; affects memory usage and inference cost | Use official documentation and include the version number |
| Quantization precision | FP16, INT8, INT4, etc.; affects memory usage and output precision | Record the precision actually used at deployment |
| Memory usage | Usage after loading and at inference peak | Sample with nvidia-smi every second during inference and take the peak |
| Context length | Maximum input tokens per request | Test with samples near the limit to see whether truncation occurs |
| First-token latency | Time from request sent to first token returned | Time on the client; record cold and warm starts separately; repeat each sample 5 times and report the median |
| Throughput | Tokens output per unit time at fixed concurrency | Fix concurrency; discard the first 60 seconds of warm-up data; average over the next 10 minutes |
Cold start means the first request after the service has just started. Warm start means continuous requests after the model has been loaded. The gap between them can be large, so report both separately.
Lightweight models are usually better suited to code completion, structured documents, internal Q&A, and batch classification. For tasks involving high-precision numerical computation, strict auditing, or external actions, model output should be treated as a draft to be verified, not used directly.
2. Task Set and Environment Record
The task set should cover the work the model will actually perform. The table below lists five categories. Prepare fixed prompts for each category and do not modify them during testing.
| ID | Category | Sample focus | Acceptance criteria |
|---|---|---|---|
| T1 | Geometry drawing code | Draw shapes according to specified steps; do not directly write result coordinates | Pass the rules in Section 3 |
| T2 | API and unit tests | Write an API with parameter validation and add unit tests | All tests pass; invalid input returns the agreed error code |
| T3 | Structured output | Output analysis results according to a given JSON Schema | Parseable, complete fields, correct types |
| T4 | Data calculation | Given a data set, write a script to compute statistics | Error versus independent calculation no greater than 1e-6 |
| T5 | Multi-constraint document | Write a document according to section structure, word count, and glossary | All sections present, consistent terminology, word count within the allowed range |
Prepare 5 to 10 samples per category. Run each sample at least 5 times and record the pass rate. A single pass does not prove that the model is stable.
Use two initial screening lines: a pass rate of 80% or higher can enter the candidate list, while a rate below 60% is not recommended for that task category. These two numbers are starting points and should be adjusted for business risk.
The statistical basis for the pass rate should also be stated. Suppose a task category has 25 runs and 20 pass. A Wilson 95% interval gives approximately 61% to 91%. The lower bound is below 80%, so this data cannot prove that the model reaches the 80% line. Before launch, each task category should have at least 100 runs, and the lower bound of the Wilson 95% interval should be reported.
Every evaluation should keep an environment record. The following is a suggested template:
model_name: # Model namemodel_version: # Version number; must not be blankvendor_doc_url: # Vendor documentation URLparam_count: # Parameter count; state the sourcequantization: # Actual deployment precision, e.g. FP16 / INT8 / INT4inference_framework: # Inference framework name and versiongpu: # GPU model, driver version, memory sizetemperature: # Sampling temperaturetop_p: # Sampling top-pmax_tokens: # Maximum output lengthconcurrency: # Concurrency for the throughput testrepeat_per_sample: 5 # Repetitions per sampleprompt_version: # Hash of the fixed promptsrun_date_utc: # Run time (UTC)raw_log_path: # Location where raw logs are stored
Raw logs should preserve full outputs, not only pass or fail conclusions. This allows the judgment rules to be rechecked if a dispute arises.
3. Geometry Drawing Example: How to Separate a Correct Result from a Correct Process
The T1 prompt is as follows:
Given segment AB, with A at (0, 0) and B at (6, 0), the length of AB is 6. Draw a circle centered at A with radius AB, and a circle centered at B with radius AB. The two circles intersect at an upper point and a lower point; take the upper intersection as C. Draw the two circles, segment AC, and segment BC in order, and display the coordinates of C on the page. Do not directly write the coordinate constant for C; C must be computed from the intersection of the two circles.
First calculate the theoretical value. Both radii equal 6, and the distance between the centers is also 6. The x-coordinate of the intersection is 3, and the y-coordinate is ±√(36 − 9) = ±3√3 ≈ ±5.196152. The upper intersection is C = (3, 5.196152).
When B is replaced with (b, 0), the theoretical value becomes C = (b/2, b·√3/2). This formula can be used to design perturbation tests.
The judgment rules are as follows:
- Correct result: The program output for C differs from the theoretical value by no more than
1e-4. - Correct process: The source code must not contain a numeric literal close to 5.196152 (error less than
1e-3). The y-coordinate is checked here because 3 is too common in code and checking it would produce many false positives. - Perturbation test: Change B to (8, 0), so the theoretical value becomes C = (4, 6.928203). The program output must change accordingly. Code with a hardcoded answer will definitely fail under perturbation.
- Output format: The program must print one line to standard output as
C = (x, y)so it can be read automatically.
Static checks can only catch obvious hardcoding. Writing 3√3 as 3 * math.sqrt(3) will not trigger the static check, but the perturbation test will catch it. Therefore, the perturbation test is the primary judgment method.
The judgment script below requires Python 3.10 or later and runs the candidate code in an isolated environment. It should have no network access and should set a timeout.
import mathimport reimport subprocessimport sysimport tempfilefrom pathlib import PathTOL = 1e-4COORD_RE = re.compile(r"C\s*=\s*\(\s*([-\d.eE+]+)\s*,\s*([-\d.eE+]+)\s*\)")B_LINE_RE = re.compile(r"^(\s*B\s*=\s*)\(.*?\)", re.MULTILINE)def theory_C(bx):# A=(0,0), B=(bx,0); both radii are bx; upper intersection is (bx/2, bx*sqrt(3)/2)return bx / 2, bx * math.sqrt(3) / 2def hardcoded_y(source):y_true = math.sqrt(27) / 3 * 3 # i.e., 3*sqrt(3) ≈ 5.196152for lit in re.findall(r"\d+\.\d+", source):if abs(float(lit) - y_true) < 1e-3:return Truereturn Falsedef run_case(script, bx):src = B_LINE_RE.sub(lambda m: f"{m.group(1)}({bx}, 0)", script, count=1)with tempfile.TemporaryDirectory() as d:path = Path(d) / "case.py"path.write_text(src, encoding="utf-8")try:proc = subprocess.run([sys.executable, str(path)],capture_output=True, text=True, timeout=30, cwd=d,)except subprocess.TimeoutExpired:return Nonem = COORD_RE.search(proc.stdout)if not m:return Nonereturn float(m.group(1)), float(m.group(2))def grade(script):report = {"hardcoded": hardcoded_y(script), "cases": []}passed = not report["hardcoded"]for bx in (6, 8): # 6 is the original case; 8 is the perturbation casegot = run_case(script, bx)want = theory_C(bx)ok = got is not None and all(abs(g - w) <= TOL for g, w in zip(got, want))report["cases"].append({"bx": bx, "got": got, "want": want, "pass": ok})passed = passed and okreport["pass"] = passedreturn reportif __name__ == "__main__":print(grade(Path(sys.argv[1]).read_text(encoding="utf-8")))
Run it as follows:
python grade_t1.py candidate_output.py
The script outputs a dictionary containing the static check result, the actual and theoretical values for both cases, and the overall judgment. A sample is recorded as passed only when the hardcoding check passes and both cases pass.
The following is a reference implementation that meets the requirements, for evaluators to verify the judgment logic:
import mathimport matplotlibmatplotlib.use("Agg")import matplotlib.pyplot as pltA = (0, 0)B = (6, 0)r = math.dist(A, B) # both circle radii equal the length of ABdef circle_intersections(c1, c2, radius):# Equal radii: intersections lie on the perpendicular bisector of the line connecting the centers(x1, y1), (x2, y2) = c1, c2d = math.dist(c1, c2)mx, my = (x1 + x2) / 2, (y1 + y2) / 2h = math.sqrt(radius ** 2 - (d / 2) ** 2)ux, uy = (x2 - x1) / d, (y2 - y1) / d # unit vector along the line connecting the centerspx, py = -uy, ux # normal vector rotated 90 degrees counterclockwisereturn (mx + h * px, my + h * py), (mx - h * px, my - h * py)upper, lower = circle_intersections(A, B, r)C = upper if upper[1] > lower[1] else lowerfig, ax = plt.subplots()ax.add_patch(plt.Circle(A, r, fill=False))ax.add_patch(plt.Circle(B, r, fill=False))ax.plot([A[0], C[0]], [A[1], C[1]])ax.plot([B[0], C[0]], [B[1], C[1]])ax.set_aspect("equal")ax.set_title(f"C = ({C[0]:.6f}, {C[1]:.6f})")fig.savefig("geometry.png")print(f"C = ({C[0]:.6f}, {C[1]:.6f})")
In this code, C is computed from the circle-intersection formula and no constant is written into the code. After changing B to (8, 0), the output becomes C = (4.000000, 6.928203), matching the theoretical value for the perturbation test.
4. Five-Dimensional Scoring and Thresholds
A single metric only shows local performance. During model selection, combine the dimensions into a total score to make horizontal comparisons easier.
| Dimension | Weight | Scoring basis | 5-point condition |
|---|---|---|---|
| Process and result correctness | 30% | Proportion of T1 and T4 samples passed, plus perturbation test results | All samples pass and no perturbation test fails |
| Format and constraint compliance | 20% | T3 parsing success rate and T5 section and word-count checks | All parsing and constraint checks pass |
| Stability | 20% | Pass rates across task categories and the Wilson 95% lower bound | Pass rate no lower than 90%, lower bound no lower than 80% |
| Latency and throughput | 15% | Median first-token latency and throughput at fixed concurrency | Meets the business latency limit and throughput reaches the capacity-planning value |
| Operational cost | 15% | Memory usage, cost per call, and deployment complexity | Deployable on a single GPU and cost within budget |
Map each dimension’s measured value to a score from 1 to 5, then apply the weights. The weights and score mappings here are starting points. Business teams should adjust them according to actual risk and record the rationale in the evaluation report.
Use two rules for the launch decision. First, the weighted total score must be no lower than 3.5. Second, there must be no hard veto. Any of the following is a veto:
- The perturbation test fails, suggesting that the result may be hardcoded or dependent on accidental output.
- The pass rate for a key task is below 60%.
- Model output triggers an external action without a validation step.
5. Latency Measurement and Risk Checklist
Latency must be measured with a consistent methodology; otherwise, numbers from different models cannot be compared.
- Record the request send time and the first-token arrival time on the client, not server-reported numbers.
- Collect cold-start and warm-start results separately. Cold start records the first request after service startup; warm start records requests after the model has been loaded.
- Repeat each sample 5 times and report the median. When the sample size is small, do not report P95 or P99, because these percentiles have little statistical meaning with 5 runs.
- For the throughput test, discard the first 60 seconds of warm-up data and average over the following 10 minutes.
Check the following risks item by item before launch:
- Do the prompts contain personal information or trade secrets, and does the vendor allow receiving such data?
- Can the vendor update model weights without changing the version number, and can the version be locked?
- Before model output triggers an external action (send, delete, or deploy), is there programmatic validation or human review?
- Is there a fallback plan when the model fails or times out?
- Are rate limits and concurrency caps included in capacity planning?
- Does the license allow the intended use, including commercial use?
- Are logs redacted before storage?
6. Common Mistakes
- Concluding from a single pass. One success does not prove stability; evaluate by pass rate.
- Environment drift. After the driver, framework, or quantization settings change, old evaluation results no longer apply and must be rerun.
- Looking only at the result, not the process. Correct output for a geometry problem does not mean the code actually performed the drawing; the perturbation test distinguishes the two.
- Task leakage. If evaluation samples appear in the model’s training or fine-tuning data, the pass rate will be inflated. Evaluation samples should be kept separately, and their source should be recorded.
By following this workflow, teams can turn the vague description of “lightweight flagship” into a set of reproducible numbers and judgment results, and use pass rates to decide whether a model should enter production.
