LLM Recall in Security Evaluation: A Practical Guide to Metrics and Trade-offs

    This article explains why recall is the primary metric for evaluating large language models on cybersecurity tasks, where risk samples are rare and overall accuracy is misleading. It distinguishes pooled recall, single-run recall, and stable hits, shows why consistency matters more than peak scores for production workflows, and outlines how to combine cost with performance. A reproducible evaluation process and supporting architecture are included.

    1. Why Recall Deserves Separate Attention in Security Use Cases

    General LLM benchmarks usually focus on overall correctness, reasoning coherence, and language fluency. Cybersecurity tasks have a very different target distribution: most inputs are normal traffic, normal code, and normal logs, while genuine risk samples make up only a small fraction. Under this imbalance, overall accuracy loses its discriminative power, because a model that barely makes any judgment can still score highly.

    For this reason, the industry commonly treats recall as a core metric: the proportion of all real risk samples that a model successfully identifies. Recall maps directly to missed detections, and in security operations a miss costs far more than a false positive. False positives add manual review effort; misses can let a risk stay hidden for a long time.

    Recall should not be read in isolation, however. It has to be considered together with false positive rate, localization precision, and the readability of explanations. Chasing recall alone pushes thresholds extremely low, produces a large amount of noise, and eventually leaves alerts unattended. The reasonable approach is to fix an acceptable false positive budget first, then compare how each model performs on recall under that budget.

    2. Pooled Recall vs. Single-Run Recall: Two Metrics That Must Not Be Mixed

    The most notable point in the original observations is that the same set of models reversed in ranking under two measurement conventions: aggregated results across three runs versus a single run. One category of model reached the highest hit count of 28/32 after aggregation, ahead of the 25 to 26 achieved by the others. Yet its first run hit only 17 samples, and only 10 were hit in all three runs.

    This is not a data contradiction but a difference in statistical convention:

    • Pooled recall is equivalent to taking the union of multiple attempts. It measures the capability ceiling, meaning whether the model is able to find the problem at all.
    • Single-run recall measures expected output and is closer to real operations, where the evaluation typically runs only once.
    • Stable hits (the intersection of three runs) measure consistency and determine whether results can be reused by a workflow.

    A model with a high capability ceiling but large variance fits an exploratory process built on multi-round sampling plus human convergence. A model that is steady on both single-run and stable hits is better suited to an automated alerting pipeline. Treating aggregated results as the expected production performance is the most common misjudgment during model selection.

    An illustrative way to compute these numbers (pseudocode, showing only the difference in convention):

    1. runs = [run_eval(model, dataset) for _ in range(3)]
    2. pooled = set().union(*runs) # Pooled recall: capability ceiling
    3. single = [len(r) for r in runs] # Single-run recall: expected output
    4. stable = set.intersection(*runs) # Stable hits: consistency
    5. print(len(pooled), single, len(stable))

    3. Why Consistency Matters More Than Peak Performance

    Security operations are repetitive work. If hit counts on the same sample set swing sharply across batches, three consequences follow directly. Alert baselines cannot be fixed, so on-call staff cannot tell whether a drop of a few items today comes from model variance or from an environment change. Automated orchestration struggles to set thresholds. Audits and retrospectives lack a trustworthy reference.

    Engineering practices that improve consistency include fixing decoding parameters and reducing randomness, stating the decision criteria and output structure explicitly in the prompt, sampling the same input multiple times and converging on the majority result, and applying cross-model review for high-risk categories. All of these compress variance without changing the model itself.

    4. Joint Evaluation of Cost and Performance

    The original observations also note that one category of official release hit only one sample fewer than the leader on recall while costing roughly 70% less. This suggests that evaluation must include a cost dimension; otherwise the conclusion tilts toward a peak-score-only view.

    A practical framework is to build a cost-performance frontier: unit task cost on the horizontal axis (including inference consumption and manual review overhead) and recall under a fixed false positive budget on the vertical axis, keeping only the candidates on the frontier. Options that fall inside the frontier have no deployment value, no matter how high their scores are.

    Hidden costs should be counted as well: whether explanation text can be pasted directly into a ticket, whether structured output is stable enough to parse reliably, and how stable the model is under long context. These determine integration effort and often influence total cost of ownership more than differences in unit price.

    1. Define task boundaries: separate subtasks such as traffic anomaly identification, code defect detection, and log tracing question answering, and build a separate dataset for each to avoid mixed scoring.
    2. Fix the false positive budget: set the allowed upper limit on false positives first, then compare recall, so that the metrics do not conflict.
    3. Sample multiple times: at least three rounds, recording pooled, single-run, and stable hits.
    4. Unify output constraints: constrain results with a structured format to make automated comparison easy.
    1. {
    2. "findings": [
    3. {"id": "S-001", "verdict": "risk", "confidence": 0.82, "evidence": "line 42-47"}
    4. ]
    5. }
    1. Fill in cost: convert the consumption of each round into cost per sample and plot the cost-performance frontier.
    2. Validate with a canary release: roll out to a small share of real traffic in a replay environment and check whether recall and false positives reproduce the evaluation conclusions.

    6. Deployment Architecture and Engineering Support

    When building this kind of evaluation and operations pipeline on Baidu AI Cloud, a general combination of service categories can be used: object storage to hold sample sets and evaluation artifacts, a container platform to run batch inference jobs, a message queue for task distribution and peak shaving, and log services plus monitoring and alerting to track recall fluctuation and cost drift. The key is to keep samples, versions, parameters, and results traceable to one another, so that any change in a metric can be traced to a specific variable.

    7. Conclusion

    Ranking first on recall does not mean a model is the best fit for production. The decision should rest on a combination of three curves: pooled recall represents the capability ceiling, single-run recall represents daily output, and stable hits represent reusability, with cost then shaping the cost-performance conclusion. For automated pipelines with high consistency requirements, prefer the option with lower variance; for exploratory analysis, a high-ceiling but more volatile option can be retained, with stability supplemented by multi-round sampling and cross-model review.