arXiv:2611.02957cs.CRNov 2026

Manuscript Offprint

arXiv:2611.02957

Cyber-JEV: Matched Contrastive Fine-Tuning of Language Models for Fast Source-Code Vulnerability Triage

Zhuyi Zhao, Shengjie Yuan, Shengyu Wang, Kang Wei, Wang Yang, Wenchao Xu, Fushuo Huo

Zhuyi Zhao*, Shengjie Yuan*, Shengyu Wang, Kang Wei, Wang Yang, Wenchao Xu, Fushuo Huo

Abstract—Single-pass scoring models such as Jev give each code function a vulnerability probability, so that security teams can rank many functions for review without generating written explanations. Training an open-weight model for this task is limited by data. Benchmarks with both vulnerable and non-vulnerable labels keep few vulnerable functions once examples related to the test data are removed, while larger public vulnerability records mostly contain vulnerable functions only. Mixing the two lets the data source predict the label, and training on the labeled data alone leaves a model that often scores a fixed function above its vulnerable original. We present Cyber-JEV, a fine-tuning method that uses fix commits to turn these records into comparison groups. Each group holds a vulnerable function, its patched version and up to two unchanged functions from the same file, so the model sees the change that removed a recorded defect. One shared model learns two tasks: classifying functions from the labeled reference data, and ranking the vulnerable function above the other members of its group. At test time the input is one function and the output is a vulnerability score. On a test benchmark of 7,270 functions, an ensemble of five fine-tuned Qwen3.5-4B models reaches an area under the receiver operating characteristic curve of 0.814, compared with 0.743 for Jev 1.13. With the 4,031 alerts of Jev as the review budget, it misses 16 of 322 vulnerable functions instead of 39. Compared with training on the reference data alone, it ranks the vulnerable version above the patched version 14.8 to 29.2 percentage points more often on three sets of real fixes. Such scores can order the changed functions of a pull request or a release for review under a fixed budget.

Index Terms—source-code vulnerability triage, probabilistic decision models, contrastive fine-tuning, shortcut learning, patch sensitivity, language models

I. INTRODUCTION

Modern continuous integration and pre-release security auditing workflows must screen thousands of modified functions under tight latency and analyst review budgets. Rather than relying on slow multi-turn chain-of-thought generation, fast probabilistic decision language models—exemplified by TypeSafe AI's Jev [1], [2]—provide a streamlined single-pass interface: given a candidate function, the model outputs a calibrated vulnerability probability in a single forward pass, allowing automated pipelines to prioritize high-risk functions or trigger human review.

Extending this fast decision paradigm to source-code vulnerability triage, however, faces two competing training bottlenecks [3]–[5]. The first bottleneck is source shortcut learning when aggregating public security data. After standard cross-project and near-duplicate deduplication hygiene is enforced between training and evaluation splits [6]–[9], clean benchmark pools retain very few vulnerable positives (only 197 functions in our setup). Augmenting training with public security patch archives such as MoreFixes [10] and MegaVul [11] contributes thousands of real vulnerabilities, yet the records we admit from these archives contain only vulnerable functions and no benign negatives. Naive joint training allows repository provenance to give away the label: a classifier can minimize training loss simply by recognizing project formatting and identifier conventions, causing test area under the receiver operating characteristic curve (AUROC) to drop to 0.602—worse than ranking functions purely by byte length.

The second bottleneck is an inherent anti-patch bias. If external patch archives are simply discarded in favor of standard binary cross-entropy fine-tuning on the clean reference pool, the model attains strong macroscopic ranking (0.804 AUROC) but systematically fails on minimal security fixes: in 67.2% of vulnerability-versus-patch pairs, it assigns a higher vulnerability score to the patched code than to the original vulnerable code (mirroring the 60.5% inversion rate of the unadapted base model). A likely reason is that security patches typically insert bounds checks, null-pointer guards, or error-return branches, so standard cross-entropy may teach the model to flag high-risk code modules broadly while mistaking newly added defensive checks for risk indicators.

Existing distributionally robust optimization [12], invariant risk minimization [13], and prior-shift logit adjustment [14] all require both positive and negative examples within every source, and thus can neither construct missing within-source negatives nor teach fine-grained patch discrimination. Our approach draws inspiration from classical matched statistical designs and modern contrastive learning: matched sampling in statistics (such as classical case-control studies [15]) eliminates shared group bias via conditional likelihood [16], [17] while relying on a representative reference sample to anchor baseline probabilities [18], [19]; meanwhile, counterfactual minimal edits [20] and hard-negative contrastive ranking [21]—

∗^{*}Zhuyi Zhao and Shengjie Yuan contributed equally to this work and are co-first authors.

Figure

Fig. 1. Cyber-JEV workflow. Reference data train the classification term; groups built from fix commits train only the ranking term. Both terms update one model, which scores a single function at test time.

[23] directly train neural encoders to detect subtle semantic changes.

Guided by these insights, we introduce Cyber-JEV, adapting the open-weight Qwen3.5-4B model [24] for fast, calibrated, and patch-sensitive source-code vulnerability triage (Fig. 1). At the data level, we develop Provenance-Matched Completion (PMC), a five-stage curation and sanitization pipeline that extracts dual-hash and abstract syntax tree (AST) verified patched versions and unchanged same-file context functions from security commits. At the training level, we propose Anchored-Contrastive Hybrid Loss (HYB), which orthogonally decouples global scale calibration from within-group defect ranking, supported by a two-pass memory-bounded gradient accumulator for long functions.

Our contribution is Cyber-JEV, a fine-tuning method in which PMC converts 17 positive-only patch archives into hash-verified groups of vulnerable, patched, and unchanged same-file functions and HYB trains these groups only through within-group ranking while keeping cross-entropy on the reference pool, yielding a five-model ensemble that outperforms Jev 1.13 on all four ranking metrics across 7,270 functions and ranks vulnerable code above its patched version more often than reference-pool fine-tuning on three patch suites, including two from TitanVul.

References (47)