Evaluating LLM Vulnerability Discovery: Why Pooled Recall Isn't Everything

    When a cybersecurity LLM benchmark consumes 11.7 billion tokens, the headline ranking is rarely the whole story. This article breaks down a large-scale vulnerability discovery evaluation and shows why pooled recall, single-run hit rate, and stable recall can diverge dramatically. You will learn how to calculate cost efficiency, why consistency matters more than peak scores, and how to build a reproducible evaluation pipeline using a stratified dataset, multiple sampling runs, and structured prompts. It includes a scoring script, a prompt template, and practical engineering recommendations that security R&D and platform teams can apply directly.

    When a cybersecurity LLM evaluation consumes 11.7 billion tokens, what should we actually pay attention to? This article looks past the “ranked first in recall” headline. You will understand the huge gap between pooled recall and single-run hits, why consistency metrics matter more than peak scores, how to calculate cost efficiency, and how to build a reproducible vulnerability discovery evaluation pipeline with a stratified dataset, multiple sampling, and structured prompts. The article includes a scoring script, prompt templates, and engineering recommendations that security R&D and platform teams can implement directly.

    1. Background: A Security Capability Test That Burned Through Billions of Tokens

    A cloud vendor’s security platform team recently published a large-scale LLM security capability evaluation. They selected 32 cases from recently disclosed real-world vulnerabilities, covering real code repositories. Ten mainstream LLMs were each run three times, for a total of 96 runs and roughly 11.7 billion tokens consumed. The conclusion: a domestic model ranked first by pooled recall.

    This evaluation attracted attention for three reasons:

    1. The test targets are “hard”: not artificially constructed toy samples, but vulnerabilities already patched in real projects, so models cannot score by memorizing answers.
    2. The scale is large: consuming billions of tokens makes the evaluation itself an engineering project involving cost control, concurrent scheduling, result deduplication, and manual review.
    3. The conclusion is counterintuitive: the model with the best peak score was not the most stable one, directly challenging the assumption that “leaderboard score equals production readiness.”

    Below, we abstract this evaluation into a reusable methodology and break it down layer by layer.

    2. Evaluation Design: Why You Must Use Recent Real CVEs

    2.1 Data contamination is the biggest enemy

    The biggest risk in LLM evaluation is training data contamination. If you use old, widely circulated classic vulnerability samples, the model has likely “seen the answer” during pre-training, inflating scores and failing to reflect real reasoning ability.

    The common industry practice is therefore: select real vulnerabilities disclosed after the model’s training cutoff window, and require the model to analyze them in a sandbox with no internet access and no external retrieval. This separates “memory” from “reasoning.”

    2.2 Case count and stratification

    32 cases is a compromise between statistical significance and cost. A more rigorous approach is to stratify the cases:

    • By vulnerability type: injection, deserialization, missing authorization checks, hardcoded secrets, dependency chain poisoning, and so on;
    • By localization difficulty: visible in a single file, cross-file tracing, cross-service tracing;
    • By code scale: small repositories, medium projects, large multi-module repositories.

    Only after stratification can you answer “which problem categories is the model strong or weak at,” instead of producing a single aggregate score.

    3. Metric Traps: Ranked First in Recall Does Not Mean Most Reliable

    The most important warning for developers is the huge gap between pooled recall, single-run hit rate, and stable hit rate.

    3.1 Definitions of the three metrics

    • Single-run hit rate: the number of vulnerabilities a model located in one run.
    • Pooled recall: the union of vulnerabilities hit at least once across three runs.
    • Stable hit rate: the number of vulnerabilities hit in all three runs.

    The evaluation showed a typical divergence: one model ranked first with a pooled recall of 28/32, but found only 17 in the first run and hit only 10 in all three runs. Its “first place” came largely from the union of three attempts, not from stable capability.

    3.2 Expressing the scoring logic in code

    1. from collections import defaultdict
    2. def score_model(runs):
    3. # runs: List[Set[str]], the set of CVEs hit in each run
    4. n = len(runs)
    5. pooled = set().union(*runs)
    6. stable = set.intersection(*runs)
    7. first = runs[0]
    8. return {
    9. "pooled_recall": len(pooled),
    10. "first_run_recall": len(first),
    11. "stable_recall": len(stable),
    12. "consistency": round(len(stable) / max(len(pooled), 1), 3),
    13. }
    14. # Example: results of three runs
    15. runs = [{"CVE-1", "CVE-2"}, {"CVE-2", "CVE-3"}, {"CVE-2", "CVE-4"}]
    16. print(score_model(runs))
    17. # pooled=4, first=2, stable=1, consistency=0.25

    The closer consistency is to 1, the more reproducible the model’s output; the closer to 0, the more the result depends on random sampling and the harder it is to rely on in production.

    3.3 Engineering recommendations

    • For production selection, prioritize stable recall and consistency, not leaderboard peaks;
    • If you must use a high-variance model, trade recall through multi-round sampling plus result merging, but evaluate the token cost;
    • Reports must disclose all three metrics to avoid selective reporting.

    4. The Cost Dimension: What a 69.8% Reduction Means

    Another key conclusion: a production model’s recall was only one vulnerability behind the top model, while cost dropped by about 69.8%. This shows that evaluation must consider not only capability but also cost per unit of effective output.

    A simplified metric:

    1. Cost efficiency = stable hits / (total tokens consumed × unit price)

    In real business, security scanning is a high-frequency, continuous, batch task, so cost differences are amplified into order-of-magnitude gaps. A cheap and stable model is often more suitable for embedding in a CI/CD pipeline than an expensive model that occasionally performs exceptionally.

    5. Designing a Reproducible Evaluation Pipeline

    To reproduce a similar evaluation in your own team, build it with the following architecture:

    1. Dataset layer: maintain a “time-controlled” vulnerability case library recording disclosure time, fix commits, and involved files;
    2. Sandbox layer: containerized isolation, external network disabled, read-only code repository mounted;
    3. Scheduling layer: task queue plus concurrency control, timeouts, and retries;
    4. Sampling layer: run each case multiple times, recording parameters such as temperature and random seed;
    5. Scoring layer: automatically compare the model’s output file/line numbers against the real fix locations and generate the three recall metrics;
    6. Review layer: manually or rule-based secondary confirmation of “suspected vulnerabilities” reported by the model to reduce false positives.

    Illustrative prompt template:

    1. You are a code security audit assistant. Internet access is forbidden.
    2. Locate real defects related to "{vulnerability_type}" in the given repository.
    3. Output strict JSON:
    4. {"file": "...", "line": 0, "reason": "...", "confidence": 0.0}
    5. Output JSON only, no explanation.

    Structured output significantly reduces parsing cost and makes automated scoring possible.

    6. Common Pitfalls and Best Practices

    • Pitfall 1: Choosing the highest score. Ignoring consistency and cost leads to inconsistent behavior in production.
    • Pitfall 2: More cases are always better. An unstratified set of a hundred cases is less instructive than a stratified set of thirty.
    • Pitfall 3: Ignoring false positives. Counting only recall and not precision will drown the security team in noise.
    • Best practice: pin the evaluation set version, fix sampling parameters, publish all three recall metrics, report cost alongside, and periodically roll in newly disclosed vulnerabilities to update the question bank.

    7. Conclusion

    The real value of this billion-token evaluation is not “who took first place,” but that it used an engineering approach to expose the multidimensional nature of evaluation metrics: recall, stability, and cost must be viewed together. For developers, migrating this methodology into your own model selection and security pipeline is more meaningful than memorizing any leaderboard position.