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:

    1. model_name: # Model name
    2. model_version: # Version number; must not be blank
    3. vendor_doc_url: # Vendor documentation URL
    4. param_count: # Parameter count; state the source
    5. quantization: # Actual deployment precision, e.g. FP16 / INT8 / INT4
    6. inference_framework: # Inference framework name and version
    7. gpu: # GPU model, driver version, memory size
    8. temperature: # Sampling temperature
    9. top_p: # Sampling top-p
    10. max_tokens: # Maximum output length
    11. concurrency: # Concurrency for the throughput test
    12. repeat_per_sample: 5 # Repetitions per sample
    13. prompt_version: # Hash of the fixed prompts
    14. run_date_utc: # Run time (UTC)
    15. 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:

    1. Correct result: The program output for C differs from the theoretical value by no more than 1e-4.
    2. 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.
    3. 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.
    4. 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.

    1. import math
    2. import re
    3. import subprocess
    4. import sys
    5. import tempfile
    6. from pathlib import Path
    7. TOL = 1e-4
    8. COORD_RE = re.compile(r"C\s*=\s*\(\s*([-\d.eE+]+)\s*,\s*([-\d.eE+]+)\s*\)")
    9. B_LINE_RE = re.compile(r"^(\s*B\s*=\s*)\(.*?\)", re.MULTILINE)
    10. def theory_C(bx):
    11. # A=(0,0), B=(bx,0); both radii are bx; upper intersection is (bx/2, bx*sqrt(3)/2)
    12. return bx / 2, bx * math.sqrt(3) / 2
    13. def hardcoded_y(source):
    14. y_true = math.sqrt(27) / 3 * 3 # i.e., 3*sqrt(3) ≈ 5.196152
    15. for lit in re.findall(r"\d+\.\d+", source):
    16. if abs(float(lit) - y_true) < 1e-3:
    17. return True
    18. return False
    19. def run_case(script, bx):
    20. src = B_LINE_RE.sub(lambda m: f"{m.group(1)}({bx}, 0)", script, count=1)
    21. with tempfile.TemporaryDirectory() as d:
    22. path = Path(d) / "case.py"
    23. path.write_text(src, encoding="utf-8")
    24. try:
    25. proc = subprocess.run(
    26. [sys.executable, str(path)],
    27. capture_output=True, text=True, timeout=30, cwd=d,
    28. )
    29. except subprocess.TimeoutExpired:
    30. return None
    31. m = COORD_RE.search(proc.stdout)
    32. if not m:
    33. return None
    34. return float(m.group(1)), float(m.group(2))
    35. def grade(script):
    36. report = {"hardcoded": hardcoded_y(script), "cases": []}
    37. passed = not report["hardcoded"]
    38. for bx in (6, 8): # 6 is the original case; 8 is the perturbation case
    39. got = run_case(script, bx)
    40. want = theory_C(bx)
    41. ok = got is not None and all(abs(g - w) <= TOL for g, w in zip(got, want))
    42. report["cases"].append({"bx": bx, "got": got, "want": want, "pass": ok})
    43. passed = passed and ok
    44. report["pass"] = passed
    45. return report
    46. if __name__ == "__main__":
    47. print(grade(Path(sys.argv[1]).read_text(encoding="utf-8")))

    Run it as follows:

    1. 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:

    1. import math
    2. import matplotlib
    3. matplotlib.use("Agg")
    4. import matplotlib.pyplot as plt
    5. A = (0, 0)
    6. B = (6, 0)
    7. r = math.dist(A, B) # both circle radii equal the length of AB
    8. def circle_intersections(c1, c2, radius):
    9. # Equal radii: intersections lie on the perpendicular bisector of the line connecting the centers
    10. (x1, y1), (x2, y2) = c1, c2
    11. d = math.dist(c1, c2)
    12. mx, my = (x1 + x2) / 2, (y1 + y2) / 2
    13. h = math.sqrt(radius ** 2 - (d / 2) ** 2)
    14. ux, uy = (x2 - x1) / d, (y2 - y1) / d # unit vector along the line connecting the centers
    15. px, py = -uy, ux # normal vector rotated 90 degrees counterclockwise
    16. return (mx + h * px, my + h * py), (mx - h * px, my - h * py)
    17. upper, lower = circle_intersections(A, B, r)
    18. C = upper if upper[1] > lower[1] else lower
    19. fig, ax = plt.subplots()
    20. ax.add_patch(plt.Circle(A, r, fill=False))
    21. ax.add_patch(plt.Circle(B, r, fill=False))
    22. ax.plot([A[0], C[0]], [A[1], C[1]])
    23. ax.plot([B[0], C[0]], [B[1], C[1]])
    24. ax.set_aspect("equal")
    25. ax.set_title(f"C = ({C[0]:.6f}, {C[1]:.6f})")
    26. fig.savefig("geometry.png")
    27. 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.