Skip to Content
  • Article
  • Open Access

25 August 2026

21 Pages

From Evaluation to Optimisation: Hierarchy-Aware Training Signals for CWE Prediction in Python

,
and
Open Source Institute, Faculty of Science and Technology, University of Canberra, Bruce, ACT 2606, Australia
*
Author to whom correspondence should be addressed.

Abstract

The original ALPHA benchmark introduced a taxonomy-aware penalty for evaluating CWE-level vulnerability prediction in Python and proposed that the penalty could theoretically also serve as a training signal. This paper tests that proposal empirically, comparing three delivery mechanisms–supervised fine-tuning, a dual-head classification loss, and reinforcement learning with a dense reward derived from the normalised penalty. We find that supervised approaches consistently regress below the zero-shot baseline under distribution shift, while GRPO succeeds and generalises across independent training seeds. Using a default, non-test-informed configuration, GRPO reduces the mean cumulative ALPHA penalty of Qwen2.5-Coder-7B-Instruct on Security Hardening and Adversarial Testing (SVEN) by 13.5%. A further test-selected configuration reduces the mean penalty by 22.9% (27.9% in the best-observed run), reaching statistical parity with its 4.5× larger zero-shot teacher. Our experiments show that reinforcement learning outperforms the alternative delivery mechanisms we test. We conclude that delivery mechanism, rather than the specific hierarchical structure of the reward, is the primary variable—though whether taxonomy-aware structure contributes further remains an open question.

1. Introduction

Large language models (LLM) are now widely used to generate code [1,2,3], and a growing body of evidence indicates that the code they produce frequently contains exploitable vulnerabilities [4,5]. The prior ALPHA work [6] argued that binary vulnerability detection—labelling a function as vulnerable or not—provides insufficient specificity for the iterative repair pipelines increasingly used to improve generated code [1,3], since effective repair requires specific feedback [7]. ALPHA [6] therefore evaluates predictions at the level of the common weakness enumeration (CWE) and introduces a taxonomy-aware penalty under which a prediction that falls near the true CWE in the MITRE hierarchy is penalised less than one that falls in an unrelated region of the taxonomy. Because this penalty is continuous and direction-aware, it is a natural candidate for a training objective rather than only an evaluation metric. Furthermore, the penalty’s direction-aware asymmetry explicitly encodes downstream utility by penalising the loss of diagnostic information (over-generalisation) more heavily than unwarranted specificity (over-specification).
While the original ALPHA paper theorised this penalty could function as a loss function, the empirical viability of this approach was unexplored. Crucially, an effective evaluation metric does not automatically translate into an effective loss function. Even if a signal accurately measures a target, the optimisation mechanism can distort or discard that information before it reaches the model parameters. Therefore, realising the theoretical promise of this penalty depends substantially on how it is architecturally delivered during training. We explore three delivery mechanisms, which differ in whether the penalty enters the training loss and in whether the output vocabulary is restricted to classes observed during training,
  • Supervised fine-tuning (SFT): The penalty does not enter the loss; the model imitates the reasoning and CWE labels produced by a stronger teacher model, and the penalty is used only to score the result.
  • A dual-head supervised loss: This is the architecture proposed in the original ALPHA paper. A classification head is trained with a differentiable expected-penalty term, L ALPHA , added to cross-entropy (CE). The penalty enters the loss, but the head is restricted to the CWE vocabulary observed in training.
  • Reinforcement learning (RL): The L ALPHA penalty defines the reward, which is one minus the normalised penalty; and the output vocabulary is unrestricted.
To evaluate these delivery mechanisms, we train on the SecurityEval [8] and CVEfixes [9] datasets, and evaluate on the Security Hardening and Adversarial Testing (SVEN) [10] dataset (Section 4). On a matched in-distribution split (SecurityEval 70/30% train–test split), the classification head is highly effective when trained with CE and mean pooling. However, under the distribution shift to SVEN, both supervised mechanisms degrade significantly, regressing below the base model’s (Qwen2.5-Coder-7B-Instruct) zero-shot performance. In contrast, group relative policy optimisation (GRPO) is the only mechanism that demonstrates robustness under shift. Across every base-backbone configuration, GRPO successfully reduces the cumulative ALPHA penalty relative to the baseline. Notably, the default GRPO configuration, without test-informed tuning, achieves a mean 13.5% reduction in the penalty across three independent training seeds, while a further, test-selected configuration achieves a mean 22.9% reduction (27.9% in the best-observed run under greedy decoding, 25.5% under matched sampled decoding; p = 0.005, Welch’s t-test) and reaches statistical parity with a model 4.5× its size. We make two contributions:
  • Evidence that RL can deliver the ALPHA penalty as an effective training signal under distribution shift, and that the delivery mechanism, not merely the penalty’s availability, determines whether its benefit is realised. Supplying the same penalty through supervised mechanisms does not improve, and often harms, CWE prediction under shift. Whether specifically the penalty’s hierarchical structure, as opposed to reinforcement learning with an unrestricted output vocabulary, is responsible for this advantage remains open (Section 7).
  • RL configurations that improve CWE prediction under distribution shift—a base-backbone GRPO policy with a dense, penalty-derived reward that reduces the SVEN ALPHA penalty of Qwen2.5-Coder-7B-Instruct by a mean of 13.5% across 3 different seeds using only default, pre-specified hyperparameters; and by a mean 22.9% (up to 27.9% best-observed) under a further test-selected configuration that reaches parity with its 4.5× larger zero-shot teacher, together with the data, hyperparameter, and seed-stability analysis that characterise it.

2. Background

LLMs now assist a substantial share of everyday software development, yet a recurring body of evidence shows that the code they produce is frequently insecure [4,5,7]. This has prompted two broad responses: steering models towards secure code and detecting vulnerabilities after generation so they can be repaired. SVEN [10] and SafeCoder [11] exemplify the former using SFT, which raises the proportion of secure completions from 59.1% to 92.3% without degrading functional correctness. For detection, comparative studies report that LLMs and static application security testing (SAST) tools occupy complementary regimes: SAST tools achieve low detection rates but relatively few false positives, whereas LLMs detect far more vulnerabilities at the cost of higher false-positive rates [6,12]. Prompting-augmented frameworks such as DLAP [13] attempt to combine these strengths in a feedback loop setting.
Most SAST-versus-LLM comparisons reduce the task to binary classification [12,14], which is too coarse to drive targeted repair [7]. Our prior work, ALPHA [6], addressed this limitation by introducing the first function-level Python benchmark that scores predictions at CWE-level granularity for both LLMs and SAST tools. Rather than treating every misprediction as equally wrong, ALPHA exploits the hierarchical structure of the MITRE CWE taxonomy [15]. This taxonomy-aware perspective aligns with a broader line of hierarchy-aware learning, in which penalising errors by their semantic distance within a class hierarchy yields “better mistakes” than a flat loss [16].
RL has become the standard mechanism for aligning LLMs with objectives that are not directly differentiable. Building on preference-based RL [17] and the RL-from-human-feedback pipeline popularised by InstructGPT [18], most implementations optimise a reward using proximal policy optimisation [19]. GRPO [20] simplifies this recipe by discarding the learned value network and instead estimating the baseline from the relative scores of a group of sampled outputs, thereby reducing the computational overhead.
Applying RL to code generation is now well established—CodeRL [21], PPOCoder [22], RLTF [23], and StepCoder [24] all treat execution, unit-test, or compiler feedback as a reward to improve functional correctness. Reward-driven approaches aimed specifically at security, however, remain scarce. The closest examples train models to repair vulnerabilities using PPO with syntactic and semantic similarity rewards [25,26], arguing that ordinary cross-entropy underweights the few security-critical lines relative to the bulk of functional code. Concurrent work has begun to pair online RL with a vulnerability reward model [27]. To our knowledge, none of these approaches use a hierarchy-aware CWE penalty as an RL reward. This is the gap the present work addresses: we take the original ALPHA penalty and optimise it directly as a GRPO reward, testing whether this yields a principled, taxonomy-aware training signal for CWE-specific vulnerability detection.

3. Methodology

3.1. The Training-Corpus Problem and Label Withholding

Function-level, human-annotated Python-CWE datasets are small—SecurityEval [8] contains 121 samples across 69 CWE classes, and the Python subset of SVEN [10] contains 342 samples across four base classes. Larger CWE-labelled corpora exist [9] but trade reliability for scale [28]. Their labels are typically derived from static-analysis tools, whose coverage and precision are known to be poor [6,28,29], making them unsuitable as a source of trustworthy supervision. This scarcity of reliable data creates two distinct problems for training. First, training on a classification objective alone, with no LM signal at all, risks eroding the pretrained backbone’s generative competence and collapsing it into a narrow classifier. Second, independently of data quantity, raw Python code itself provides a weak LM signal since short Python functions contain very little that a code-pretrained backbone has not already seen.
The natural remedy is to supplement the LM and classification head with reasoning and explanations generated by a teacher model that has access to the true label. This, however, introduces label leakage into the classification head—if the explanation names the CWE, the language head can read the answer directly from its input. Our protocol resolves this through label withholding. The teacher (Qwen2.5-Coder-32B-Instruct) receives the code and the true CWE label and generates a mechanistic explanation under an explicit constraint to omit any CWE identifier. This yields two corpora: an SFT corpus, in which the teacher’s output retains the CWE identifier; and a classifier corpus, in which the identifier is withheld so that the classification head predicts under genuine uncertainty. Both corpora share the same schema; the gold label is used only in loss computation.

3.2. Dual-Head Architecture and Supervised Objective

We adopt Qwen2.5-Coder-7B-Instruct as a shared backbone—a decoder-only, open-weight model with a native causal LM head and a published zero-shot ALPHA baseline, enabling direct comparison. We adapt the backbone with LoRA [30] adapters (Appendix C), keeping the base transformer weights frozen throughout. Two heads read from this backbone: a causal LM head that generates a mechanistic vulnerability explanation, and a classification head that predicts a CWE from pooled hidden states. The heads are trained in two sequential stages, each optimising a single objective. We employ two-stage training: In Stage 1, we train the LM head with next-token CE only on the teacher-explanation tokens, yielding the SFT backbone; its role is to regularise the shared representation. In Stage 2, we load the SFT adapter, apply a second LoRA adapter, and attach the classification head to the pooled last-layer hidden states. Only Stage 2’s LoRA adapter and the head are updated under the classification loss. The head is a multi-layer perceptron (MLP) mapping the pooled representation to the n = 69 CWE classes observed in the training corpus, with three hidden layers of width 2056, 1024, and 512 before the output projection. The LoRA-adapted backbone supplies the features; this deeper head captures non-linear structure in the pooled embeddings. We evaluate both mean and last-token pooling [31] to form the pooled representation. The Stage 2 objective combines a standard CE loss with the hierarchy-aware L ALPHA term,
L total = L CE + λ · L ALPHA , L ALPHA ( θ ) = ∑ v ∈ V obs p θ ( v ∣ x ) P ^ ( v , c t r u e ) .
P ^ ( v , c t r u e ) = P ( v , c t r u e ) / P max is the ALPHA graph penalty [6] normalised to [ 0 , 1 ] . Both terms are differentiable and read the same class distribution. L ALPHA is an expected penalty weighting each candidate misclassification by its probability and its taxonomic severity. For n = 69 , L CE ∈ [ 0 , ln n ] ≈ [ 0 , 4.23 ] while normalised L ALPHA ∈ [ 0 , 1 ] . Therefore, CE would dominate by 3– 4 × at λ = 1 , so we set λ = 3 to place the terms on a commensurate scale.
A property left unanalysed in the original ALPHA proposal is that L ALPHA is insufficient to train the classifier on its own in the supervised regime. The two logit gradients (derived in Appendix A) expose why
∂ L A L P H A ∂ z k = p θ ( k ) [ P ^ ( k ) − L ALPHA ] , ∂ L CE ∂ z k = p θ ( k ) − 1 [ k = c t r u e ] .
CE is corrective through the indicator 1 [ k = c t r u e ] . It applies an upward push of magnitude 1 − p θ ( c t r u e ) on the true class, strongest exactly when the model is most wrong and unconditional on the training phase. L ALPHA , on the other hand, is confirmatory. Since P ^ ( c t r u e ) = 0 , its push on the true class is p θ ( c t r u e ) · L A L P H A , which vanishes if p θ ( c t r u e ) → 0 . It goes silent precisely when correction is most needed and favours the true class only while that class already leads (Appendix B). It can extend a lead but not create one.
This pathology is specific to the supervised expected-penalty setting. Under GRPO, the L ALPHA penalty enters through sampled rollouts and normalised advantages, rather than a belief-weighted expected-penalty gradient, so it retains a corrective signal even when the model is confidently wrong; this is why the ALPHA penalty can drive learning on its own under RL but must be paired with CE under SFT. The classification head assigns probability only to the classes represented in the training corpus; consequently, L ALPHA can only redistribute probability mass within this fixed simplex. When the deployment distribution is dominated by a class seen only a handful of times in training, hierarchical shaping cannot compensate for a dimension the model has barely learned.
This analysis makes three predictions for SFT:
  • First, when the shared representation is weak and the model’s distribution is already committed, L ALPHA can only rescale existing mass. So, toggling it on or off should leave the score unchanged.
  • Second, when the representation is strong, its effect should be small and refining rather than decisive.
  • Third, whichever class leads at initialisation should be reinforced, so a biased starting point should collapse toward that class rather than away from it.

3.3. Reinforcement Learning with an ALPHA Reward

SFT encourages adaptation to the training distribution at the expense of the base model’s broader capabilities [32], and sufficient adaptation can lead to overspecialisation [33] and catastrophic forgetting [34]. RL removes these constraints. The model generates a free-form analysis, the predicted CWE is extracted from the text, and the reward is computed from the penalty. We view this as a contextual bandit setting [35], in which the entire response is treated as a single action with a terminal reward, thereby avoiding token-level credit assignment. The state s is the prompt, the action a is the complete response, and the policy π θ ( a | s ) is the language model factorised autoregressively. The objective is
J ( θ ) = E x ∼ D , a ∼ π θ ( · | x ) [ R ( a , c t r u e ) ]
For a response a whose extracted CWE is c ^ ,
R ( a , c t r u e ) = 1 − P ( c ^ , c t r u e ) P m a x ∈ [ 0 , 1 ]
We optimise J ( θ ) with GRPO [20], chosen for three reasons: it is suited to a single-GPU budget; it requires no separate value network, estimating the advantage baseline from a group of completions for the same prompt; and a Kullback–Leibler (KL) divergence [36] ( D KL ) anchor to a frozen reference policy to keep training stable. For each prompt, we sample G completions, score each, and form group-relative advantages A while skipping any group whose reward standard deviation falls below 10 − 6 ,
A i , t = R i − mean ( R 1 , … , R G ) std ( R 1 , … , R G ) .
Although the optimisation problem is formulated as maximising J ( θ ) in Equation (3), the implementation minimises its negation (Equation (6)), consistent with gradient-descent optimisers such as AdamW [37],
L i = − ( A i · log π θ ¯ ( y i | x ) − β · D KL ( π θ | | π ref ) ) .
The contrast with the supervised penalty is structural. The dual-head gradient scales with p θ ( k ) , attenuating updates to low-probability classes, whereas the GRPO policy gradient scales with ∇ θ log π θ ( y i | x ) , introducing the inverse dependence. This distinction concerns gradient scaling rather than providing a guarantee that reinforcement learning is unconditionally superior at escaping local optima. Additionally, the KL anchor independently constrains policy movement (Section 6.1), and improvement still requires the sampled group to contain a better action. Beyond constraining policy movement and stabilising training, the KL penalty prevents degenerate solutions, such as the model defaulting to the most frequent class regardless of input (e.g., CWE-89, which alone accounts for 54% of SVEN samples).

3.4. Use of AI Tools in Manuscript Preparation

Generative AI tools (Claude Sonnet 4.5 and Claude Sonnet 5, Anthropic, San Francisco, CA, USA) were used during manuscript preparation for two purposes: First, to assist in drafting and refining explanatory text, including identifying inconsistencies between reported claims and their supporting data. Second, to assist with debugging during implementation. The authors reviewed and verified all AI-assisted output and take full responsibility for the accuracy and integrity of the analysis and content.

4. Experimental Setup

4.1. Datasets

SecurityEval [8] (121 Python functions, 69 CWEs) is the primary training source; a 70/30 train–test split was carved out before any corpus generation for SFT training, so the teacher never saw the held-out samples, which are reserved for in-distribution evaluation. CVEfixes [9] (1548 samples, 71 classes) supplies mined patched functions that augment the RL pool. SVEN [10] (342 samples; CWE-022, CWE-078, CWE-079, CWE-089) is the out-of-distribution (OOD) benchmark: its four classes are common enough to be well represented in the base model’s pretraining corpora but are thinly covered by the training corpora used here. Table 1 summarises sizes, class counts, and overlap.
Table 1. “Shared” counts distinct CWEs also present in SecurityEval. CVEfixes⋆ denotes CVEfixes restricted to the 23 CWEs shared with SecurityEval; D comb additionally applies deduplication and length filtering to CVEfixes⋆ before union with SecurityEval (7).
CWE labels are normalised across all three corpora: identifiers are mapped to the integer node form used by the ALPHA taxonomy graph [6]. Labels retain their original abstraction level (Base, Class, or Variant) rather than being collapsed to a common level, since the ALPHA penalty is direction-aware and this distinction separates over-generalisation from over-specification. These three corpora differ in label provenance: SecurityEval and SVEN each carry one hand-annotated CWE per sample; CVEfixes labels are inherited from the National Vulnerability Database (NVD) record of the associated common vulnerabilities and exposures (CVE) via the CVEfixes relational schema and are consequently noisier. A further source of label noise affects the CVEfixes-derived data specifically: NVD sometimes assigns more than one CWE to a single CVE. This affects 53 of the 463 CVEfixes samples (11.45%) that remain after the preprocessing described below. For these samples, we kept the first CWE label returned by the database.
Preprocessing: CVEfixes⋆ (710 samples, 23 CWEs—Table 1) passes through exact deduplication followed by a 20–400 word length bound. The lower bound removes stubs, bare imports and trivial accessors that carry no vulnerability semantics and contribute negligible gradient signal while the upper bound guarantees every retained snippet fits entirely within the 512-token encoder window alongside its instruction wrapper, so no sample is scored on truncated code. Both are standard for CVEfixes-derived subsets, where audits report substantial duplication and length noise in the raw mining output [9,38,39]. Preprocessing leaves 463 usable Python samples over the 23 shared CWEs, which combine with SecurityEval to form D comb , consisting of 584 samples over 69 CWEs.
D comb = D SecurityEval ∪ preprocess D CVE ⋆ .
This augmentation deepens classes the classifier already targets rather than adding new ones. The filter is load-bearing: CVEfixes is dominated by CWE-918 (125), CWE-352 (120) and CWE-444 (85), none of which appear in SecurityEval or SVEN, and training GRPO on unfiltered CVEfixes yields the worst SVEN score of any RL configuration (see Section 6.2).
Within the 23 shared classes, the preprocessed CVEfixes’ contribution is uneven—the largest class supplies 74 samples while half supply 6 or fewer—so a few classes would otherwise dominate the RL gradient signal. To test whether this matters, we also build a variant with a per-class ceiling of 31 samples (mean per-class count ≈ 30.87 of the CVEfixes⋆ pool), which binds on 7 of the 23 classes and reduces the three largest classes’ share of the shared-class mass from 42% to 29%. This gives two variants of D comb : capped and uncapped. The uncapped variant is used throughout the main experiments, with the capped variant reported in the ablation in Section 6.2.

4.2. Policy and Training

The policy and backbone is Qwen2.5-Coder-7B-Instruct [40]; the teacher that generates the explanation corpora is Qwen2.5-Coder-32B-Instruct [40]. All fine-tuning is parameter-efficient (PEFT) [41] via LoRA [30]. Unless stated otherwise, all reported scores represent cumulative ALPHA values. In selected instances, we report mean per-sample scores and label them accordingly. We report two complementary settings:
  • Out-of-distribution: Training on SecurityEval or D comb and evaluation on SVEN—the deployment-realistic regime.
  • In-distribution: A 70 / 30 SecurityEval split, with both teacher corpora generated only from the training portion so that the held-out samples are unseen.
The in-distribution setting is diagnostic, not a target in its own right—it isolates whether the dual-head loss behaves as the gradient analysis in Section 3.2 predicts. Deployment is where a trained model meets inputs unlike its training distribution, so distribution shift is this work’s actual concern. We evaluate SFT and the dual-head loss in both regimes because their in-distribution behaviour explains why they fail under shift (Section 5). GRPO is evaluated only under shift: we adopted it because SFT showed no distribution-shift gains despite adequate in-distribution performance, so we did not run an in-distribution GRPO evaluation.
GRPO: GRPO sweeps group size G ∈ { 8 , 16 } , KL regularisation coefficient β ∈ { 0.02 , 0.04 } , and 2–6 epochs. Completions are sampled at temperature 0.8 (Ollama default) during training. Unless otherwise stated, GRPO checkpoints are evaluated under greedy decoding, matching typical deployment practice; Section 5.2 additionally reports a sampled-decoding evaluation of the best configuration for direct statistical comparison with the sampled-decoding baseline. Continued training runs reduce the learning rate from 5 × 10 − 6 to 2 × 10 − 6 and retain the original base model as the frozen KL reference so that the KL bound accumulates over epochs rather than relative to the most recent checkpoint. All experiments used a single NVIDIA A100 (80 GB) GPU.

5. Results

5.1. Supervised Results: In-Distribution and Under Shift

On the matched 70 / 30 SecurityEval split, mean pooling substantially outperforms last-token pooling, and the dual-head marginally outperforms the SFT generative baseline. Table 2 reports the held-out SecurityEval evaluation.
Table 2. In-distribution evaluation on the held-out SecurityEval split (36, 30%). Lower is better.
Three observations follow: first, pooling is the dominant factor—mean pooling reduces the penalty by roughly 40% relative to last-token pooling. Second, CE fine-tuning alone adds value over parsing the model’s own free-form output when the distribution matches. The mean-pooled classification head trained with only L CE reaches 145.2, improving on the zero-shot baseline of 230.7. Third, adding L ALPHA to the CE objective improves the mean-pooled score only marginally ( 145.2 → 141.6 ), a difference of 0.1 per sample over 36 samples, which we do not claim as significant and on which we rest no conclusion. This marginal improvement is the second prediction realised in Section 3.2—once CE has fixed the ranking, the L ALPHA term that only redistributes residual mass has limited scope to alter it. Under last-token pooling, switching the penalty term L ALPHA on or off changes nothing (233.6 in both cases), consistent with the gradient analysis. This is the first prediction of Section 3.2 realised—because the L ALPHA gradient scales with p θ ( k ) , it can only amplify the distribution that the representation already produces; under a weak (last-token) representation, that distribution is fixed, and the penalty term has no distribution to reshape, and the score is identical.
Re-running the supervised mechanisms with evaluation on SVEN reverses the picture (Table 3). Both SFT and the dual-head classifier exceed the 7B zero-shot baseline’s cumulative penalty of 753.2.
Table 3. Out-of-distribution evaluation (SecurityEval → SVEN). Cumulative ALPHA, lower is better.
Two points are notable: first, the ordering of the pooling strategies inverts relative to Table 2—mean pooling, the strongest in-distribution, is the weakest under shift, because a representation tuned to the training distribution does not transfer when the test distribution is concentrated elsewhere. Second, under mean pooling, the effect of L ALPHA is also larger under shift than in-distribution—an 8.6% reduction (3063.1 → 2799.2)—though this does not reverse the classifier’s overall degradation, and the effect is not consistent across pooling strategies ( L ALPHA increases the penalty by 8.9% under last-token pooling).
The classifier conditions are the weakest overall—it can predict only one of its 69 training classes, and SVEN’s dominant class appeared twice in training. Table A3 reports per-class recall for each pooling-loss combination on SVEN’s four evaluation classes, together with each condition’s most frequently predicted class overall. Last-token pooling never recovers the correct class on any of the four SVEN CWEs regardless of loss, collapsing almost entirely onto CWE-020; mean pooling performs unevenly across classes and, like last-token pooling, defaults most often to a class absent from SVEN’s evaluation taxonomy. This pattern is sharpest on SVEN’s dominant class CWE-89—CE with mean pooling predicts it correctly in only 2 cases, most often predicting CWE-522 instead; CE with last-token pooling never predicts CWE-89 correctly on this subset. This is the third prediction in Section 3.2 realised—with only two training instances of the dominant class, p θ ( CWE - 89 ) begins negligible, so the penalty gradient towards it is negligible and shrinks further as the model commits elsewhere. The loss cannot lift a class the representation has not surfaced.

5.2. GRPO Under Distribution Shift

Across all GRPO-initialised base backbone configurations in Table 4, every configuration improves on baseline; under a null hypothesis of no directional effect, this outcome has probability ( 0.5 ) 6 = 0.0156 (excluding checkpoints continued from an earlier epoch of the same run). The exceptions, which do not improve, are policies initialised from the SFT checkpoint and policies trained on unfiltered out-of-domain CVEfixes data; both are explained in Section 6.
Table 4. All GRPO configurations on SVEN, reporting cumulative ALPHA. Lower is better. “Cont.” marks continued training from the preceding checkpoint. * signifies the capped training corpus.
To establish a result that does not depend on any test-informed choice, we first report the pre-specified, default configuration (base backbone; G = 8 , β = 0.04 , 2 epochs; SecurityEval training data), repeated across three independent training seeds (42, 43, 44) to quantify variability from initialisation, data order, and policy optimisation, distinct from the decoding-time variance reported below. This configuration reduces SVEN’s ALPHA penalty to 651.8 ± 33.8 across three seeds, a 13.5% reduction relative to baseline (per-seed reductions 8.3%, 16.4%, 15.7%), equivalent to 2.57 baseline standard deviations (SD) below the baseline mean (Table 5). All three seeds individually improve on baseline.
Table 5. Training-seed variability for the default (base backbone; G = 8 , β = 0.04 , 2 epochs; SecurityEval training data) and best-observed GRPO (base backbone; G = 16 , β = 0.02 , 3 epochs; D comb training data) configurations on SVEN, evaluated under greedy decoding. Cumulative ALPHA, lower is better.
Hyperparameter and data-recipe selection, evaluated against SVEN, identify an additional configuration (base backbone; combined data D comb ; G = 16 , β = 0.02 ; epoch 3) that further improves on this result. Repeated across the same three seeds, it reduces the SVEN penalty to 580.4 ± 36.1 , a 22.9% reduction (per-seed reductions 27.9%, 18.3%, 22.6%), equivalent to 4.37 baseline SD below the baseline mean (Table 5). Because the configuration was selected using SVEN performance, the seed-42 result of 543.1 and its associated 27.9% reduction is treated as the best observed value within this configuration’s seed distribution rather than as an unbiased estimate of expected performance. The seed-averaged 22.9% is reported as the more representative estimate.
For the best configuration, since the published baseline was evaluated under sampled decoding, we additionally evaluated matched-sampled decoding (temperature 0.8) from the seed-42 checkpoint across six independent decoding runs (526.0, 541.5, 548.2, 577.8, 586.4, 587.8; mean 561.3 ± 26.1 ) and recorded a 25.5% reduction. A Welch’s two-sample t-test against the baseline’s three published runs (mean 753.2 ± 39.5 ) gives t = −7.62 (df = 2.9), p = 0.005 (two-tailed); even the weakest of the six sampled runs clears the baseline mean by 4.2 baseline standard deviations. Both the seed-averaged best-configuration score (580.4) and sampled-decoding figures (561.3) lie within, or close to, the 4.5× larger 32B model’s reported performance ( 574.7 ± 42.4 ).
Because cumulative ALPHA depends on test-set size and composition, Table A3 and Table A4 report standard prediction measures alongside it. The default GRPO configuration achieves 77.5% exact accuracy and 52.5% macro-averaged recall across SVEN’s four classes, against 0.0–8.8% accuracy and 0.0–18.4% macro-averaged recall for the four classifier conditions (Table A4). Ancestor and descendant errors—predictions that are hierarchically close to the true CWE—are rare across every condition (at most 0.3% of predictions); almost all non-exact predictions for the classifier and GRPO are lateral—landing in a sibling branch of the CWE taxonomy rather than a hierarchically nearby one. GRPO’s advantage therefore comes overwhelmingly from converting near-misses into exact matches. GRPO’s max penalty share (3.5%) is driven primarily by outputs indicating no vulnerability, for which no CWE identifier could be extracted from the model’s free-form response (3.2% of predictions)—a category that does not apply to the classifier heads, which always output one of their 69 trained classes via softmax.
A different comparison, between the two GRPO configurations, isolates a separate mechanism. Comparing default and best-observed GRPO at seed 42 shows both achieve identical exact-match counts (265/342), so the reduction from 690.6 to 543.1 does not come from getting more predictions right. It comes from 11 samples moving out of the max penalty category (12 to 1) and into lateral (65 to 76). The best configuration’s advantage over the default therefore comes primarily from fewer max penalty errors among its incorrect predictions, rather than from resolving substantially more cases correctly.

6. Ablations

The GRPO study comprises many configurations; three factors determine the outcome: the reference policy, the training data, and the optimisation hyperparameters, together with the number of epochs.

6.1. Reference Policy: Base Versus SFT Backbone

The largest single effect is the choice of reference policy. Initialising GRPO from the SFT backbone records 1450.5 ALPHA penalty on SVEN; initialising from the base Qwen2.5-Coder-7B-Instruct records 651.8 ± 33.8 on the same SecurityEval training data—better by more than a factor of two. A likely cause is the KL anchor. If the SFT checkpoint is biased towards any particular class as a result of its teacher-supervised training, the KL term keeps the policy anchored near that biased reference, so RL cannot fully correct the bias even with a correct reward signal—consistent with the pattern in Table 4, where both SFT-initialised configurations (SecurityEval: 1450.5; Combined: 1377.8) score far above every base-initialised configuration.

6.2. Training Data Composition

SecurityEval provides only 121 training samples, so we tested whether enriching the RL training set with CVEfixes improves the policy and whether the composition of that enrichment matters. Training with unfiltered CVEfixes does not help (1763.0, worse than SecurityEval alone at 690.6)—its dominant classes are absent from SVEN, so RL teaches the wrong distribution. Restricting the enrichment to CVEfixes samples whose CWE also appears in SecurityEval (Section 4) improves the score. The D comb uncapped variant performs substantially better than the capped one at matched settings: 614.1 ( 18.47 % ) against 659.7 ( 12.41 % ), a gap that persists under continued training (609.7, 19.05 % at 4 epochs; 624.1, 17.14 % at 6). We therefore use the uncapped corpus throughout the main experiments.

6.3. Group Size and KL Coefficient

Increasing the group size G from 8 to 16 sharpens the advantage estimate, yielding more usable gradient updates per epoch. Lowering β from 0.04 to 0.02 increases the reward’s influence relative to the KL anchor. The two effects are approximately additive (Table 6).
Table 6. Hyperparameter ablation (combined data, 2 epochs, base backbone, seed 42). The final column reports the change in cumulative ALPHA relative to the default GRPO configuration; negative values indicate a lower penalty and, hence, better performance.
We did not reserve a validation set for the RL runs: we identified the peak epoch, like the other hyperparameters, by its score on SVEN, the test benchmark. A validation set disjoint from the test data would allow principled early stopping without selecting on the test set; we identify this in Section 9.
The group-size and KL-coefficient effects reported above are drawn from single training runs at each setting. We therefore read the ordering in Table 6 as suggestive of direction rather than as precisely quantified independent contributions, pending a fully reseeded ablation (Section 9).

7. Discussion

The key findings of this study are the contrast between the results in Table 2 and Table 3. The dual-head penalty loss itself is not flawed; rather, the supervised learning mechanisms that support it fail to deliver robust performance. Specifically, SFT learns to imitate a teacher whose labels and vocabulary may embed systematic biases; the dual-head loss delivers the penalty into a classifier whose vocabulary is fixed at training time. Both deliveries are mediated, and each mediator is a point of failure under shift.
GRPO is the only mechanism that improves under shift, and its advantage is consistent with the KL property—anchoring to a base reference allows the policy to reinforce knowledge already present from pretraining.
We have not isolated the contribution of the ALPHA penalty’s hierarchical structure within reinforcement learning; part of the improvement may be attributable to reinforcement learning with a free output vocabulary rather than to the graded penalty specifically. This remains an open question that this study does not resolve (Section 9). We therefore frame the contribution more narrowly: the penalty can serve as an effective training signal when delivered directly, and the delivery mechanism is the primary variable distinguishing success from failure across our experiments.
A related observation from Section 5.2 is suggestive on this point, though it is not a substitute for that baseline. The improvement from the default to the best-observed GRPO configuration (Section 5.2, Appendix D) occurs entirely through samples moving from the max penalty category into lateral, with the exact-match count unchanged. A binary or exact-match reward cannot distinguish between these two outcomes, since neither is an exact match and both would receive identical, zero, reward; only a reward that assigns different values to different degrees of wrongness could provide a gradient favouring this shift. This pattern is consistent with the graded structure of the reward doing genuine work, but it is evaluated only across two configurations of the same graded-reward setup rather than against an actual binary-reward run, and we do not treat it as resolving the question posed above.

8. Threats to Validity

We selected the best-observed GRPO value using the test results; therefore, it is an optimistic estimate. We address this by leading our results with a default configuration selected using no test-informed choices (Section 5). We further address this by repeating training for both configurations across three seeds, confirming the default configuration’s improvement is consistent across all three without any SVEN-informed tuning (Table 5). The best configuration achieves a seed-averaged improvement of 22.9%, while the single best-observed run, obtained with seed 42, achieves a 27.9% reduction; we report both statistics throughout, with the seed-averaged improvement treated as the more representative estimate. The training-seed variability is measured here for two of the six independent configurations in Table 4; the remainder, including the full hyperparameter sweep for Table 6, remain open (Section 6.3).
The in-distribution comparison of L ALPHA and CE rests on 36 samples and a 0.1-per-sample difference; accordingly, we treat the two losses as comparable in-distribution and draw no conclusion about the difference. Furthermore, the classifier cannot predict unobserved classes and no nearest-ancestor fallback is implemented other than applying max penalty.

9. Limitations and Future Work

The most acute limitation is data sparsity: 121 training samples spread across 69 distinct CWEs (a mean of fewer than two samples per class, with a long tail of singletons) and as few as two samples for SVEN’s most common class. This is the binding constraint on all three mechanisms and the principal motivation for future work—larger labelled corpora augmentation to balance CWE coverage or an inference-time nearest-ancestor fallback for classes the classifier has not observed. Such a fallback is relevant only to a deployed system, which is outside the scope of the present study, and its own viability—reliably predicting the correct ancestor class for an unobserved label—is not established here.
Furthermore, the evaluation is function-level Python on two datasets, evaluated against a single base backbone model family. The central finding, that direct delivery via RL survives distribution shift while mediated supervised delivery does not, is a claim about delivery mechanism rather than about Python, CWE taxonomy, or this model family specifically; we would expect the same asymmetry wherever a supervised objective must pass through a fixed-vocabulary classifier or an imitated teacher, but this is untested. Three axes of generalisation remain open and should not be assumed: other programming languages, where CWE prevalence and code idioms differ substantially from Python; repository or commit-level analysis, where the unit of prediction and available context differ from the isolated functions used here; and CWE distributions substantially different from training class, particularly distributions with a long tail of singleton classes, which our own analysis (Section 5.1, Appendix D) identifies as the regime most damaging to the supervised mechanisms specifically.
Three further extensions follow directly from the analysis in Section 6 and Section 7: a binary-reward GRPO baseline to isolate the contribution of the graded penalty; a validation set disjoint from the test benchmark for principled early stopping; and extending our seed-repetition analysis to the remaining configurations, particularly the hyperparameter sweep underlying Table 6 and possibly to more seeds for tighter confidence intervals.
Beyond these results, the longer-term direction is to deploy the trained policy within an iterative repair pipeline and evaluate remediation success directly. Such deployment would require several safeguards. Predictions and free-form explanations should be verified against the CWE taxonomy and, where appropriate, complementary SAST outputs, with invalid or off-graph predictions rejected or flagged rather than surfaced as actionable. A human reviewer should approve any downstream code change, with the model providing ranked, explained suggestions rather than applying fixes autonomously. Predictions should also remain traceable to the model checkpoint, reward configuration, and supporting taxonomic evidence, given the sensitivity of GRPO outcomes to training choices. Finally, deployment would require maintaining the ALPHA graph as the MITRE CWE taxonomy evolves and treating generated explanations as decision support rather than ground truth. This is consistent with approaches in other safety-critical domains that integrate LLM-generated domain knowledge into structured knowledge-management systems while retaining explicit human validation checkpoints [42].
We also did not directly compare the computational cost of the three delivery mechanisms against their predictive gains. All experiments were run on a single NVIDIA A100 (80 GB) GPU (Section 4), but the mechanisms differ substantially in the compute required to reach their reported result: SFT and the dual-head classifier are each a single fixed-cost training run, whereas the best-performing GRPO policy was selected from a sweep of fifteen configurations over group size, KL coefficient, and epoch count (Table 6), several extended through continued training. We did not record wall-clock time or GPU-hours per configuration, and a direct cost-accuracy comparison across delivery mechanisms, analogous to complexity–accuracy trade-offs examined in comparative machine-learning studies in other engineering domains [43], is left for future work.

10. Conclusions

This paper validated the proposal that the ALPHA penalty could serve as a training signal, and the validation succeeded unexpectedly. The proposed supervised mechanism fails: the expected-penalty loss leaves predictions essentially unchanged in-distribution, and the full supervised pipeline regresses below zero-shot under distribution shift for reasons distinct from the penalty itself—a fixed vocabulary that converts class sparsity into worst-case penalties is directly evidenced in our analysis (Section 5.1); mode collapse and label noise introduced by the teacher-supervision pipeline are plausible contributing mechanisms, though we have not isolated their individual contribution. Reinforcement learning with the penalty as a direct, dense reward eliminates all three limitations by construction and delivers a mean 13.5 % improvement under the default configuration across three seeds. A further test-selected configuration delivers a mean 22.9 % improvement, bringing the 7B model to parity with one 4.5 × its size. The ablations localise the gains: reference-policy choice dominates decisively, data curation comes second, group size and KL strength contribute near-additively, and early stopping is mandatory. This study demonstrates the value of direct delivery under a graded, hierarchy-derived reward but does not, by itself, establish that the hierarchical structure of the reward, rather than free-form generation under RL, is responsible for GRPO’s advantage; disentangling these remains open (Section 9). The design principle for hierarchy-aware training that follows is therefore not that the penalty matters little but that a useful penalty is squandered unless it is delivered directly to the model’s parameters; for CWE prediction under realistic distribution shift, reinforcement learning provides that directness.

Author Contributions

Conceptualisation, M.A. and C.C.N.K.; methodology, M.A. and C.C.N.K.; software, M.A. and M.S.; validation, M.A., M.S. and C.C.N.K.; formal analysis, M.A. and M.S.; investigation, M.A.; writing, M.A., M.S. and C.C.N.K.; supervision, C.C.N.K. All authors have read and agreed to the published version of the manuscript.

Funding

This work is funded under the agreement with the ACT Government, Future Jobs Fund—Open Source Institute (OpenSI)—R01553; and NetApp Technology Alliance Agreement with OpenSI—R01657. The Australian Government supported this research through the Department of Education’s National Industry PhD Program (project 36337). The views expressed herein are those of the authors and are not necessarily those of the Australian Government or the Department of Education.

Data Availability Statement

The datasets used in this study are openly available at https://huggingface.co/datasets/s2e-lab/SecurityEval, https://github.com/eth-sri/sven and https://github.com/secureIT-project/CVEfixes, all accessed on 20 August 2026. The code and dataset presented in the study are not readily available because of storage and technical limitations. Requests to access the dataset should be directed to the corresponding author.

Acknowledgments

During the preparation of this manuscript, the authors used Claude Sonnet 4.5 and 5 for debugging and refining the draft text. The authors have reviewed and edited all AI-assisted output and take full responsibility for the content of this publication.

Conflicts of Interest

The authors declare no conflicts of interest.

Appendix A. Gradient Derivations for the Supervised Objective

This appendix derives the gradient of each loss term in Section 3.2 with respect to the logit z k of class k. These gradients govern how the classification head and the shared backbone are updated during training.

Appendix A.1. Notation

  • z k ∈ R : the raw logit for class k, produced by the linear classification head.
  • S = ∑ j = 1 n e z j : the softmax normalisation constant.
  • p θ ( k ) = e z k S : the model’s predicted probability for class k after softmax.
  • c true : the ground-truth CWE class.
  • P ^ ( v , c true ) ∈ [ 0 , 1 ] : the normalised ALPHA penalty for predicting class v when the true class is c true ; a constant with respect to model parameters.
  • 1 [ · ] : the indicator function, equal to 1 if the condition holds and 0 otherwise.

Appendix A.2. Softmax Derivative

Both derivations rely on the derivative of the softmax output p θ ( v ) with respect to logit z k . We derive this first using the quotient rule.
  • Case 1: v = k .
∂ p θ ( k ) ∂ z k = ∂ ∂ z k e z k S = e z k · S − e z k · e z k S 2 = e z k S − e z k S · e z k S = p θ ( k ) − p θ ( k ) 2
      = p θ ( k ) 1 − p θ ( k ) .
The numerator step uses ∂ ∂ z k e z k = e z k and ∂ S ∂ z k = e z k (since only the k-th term in S depends on z k ).
  • Case 2: v ≠ k .
                                  ∂ p θ ( v ) ∂ z k = ∂ ∂ z k e z v S = 0 · S − e z v · e z k S 2                     ( quotient   rule ; ∂ ∂ z k e z v   =   0 ) = − e z v S · e z k S
      = − p θ ( v ) · p θ ( k ) .

Appendix A.3. Gradient of L CE

L CE = − log p θ ( c true ) = − log e z c true S = − z c true + log S
Derivative of log S with respect to z k .
∂ log S ∂ z k = ∂ log S ∂ S · ∂ S ∂ z k                  
= 1 S · ∂ S ∂ z k = e z k S = p θ ( k ) or s o f t m a x ( k ) .
  • Case 1: k ≠ c true .
The term − z c true does not depend on z k , so,
∂ L CE ∂ z k = ∂ ∂ z k ( − z c true ) + ∂ log S ∂ z k = 0 + p θ ( k ) = p θ ( k ) .
Since p θ ( k ) > 0 , the gradient is positive, and the logit is pushed down.
  • Case 2: k = c true .
Now − z c true does depend on z k , contributing − 1 :
∂ L CE ∂ z k = ∂ ∂ z k ( − z c true ) + ∂ log S ∂ z k = − 1 + p θ ( k ) = p θ ( k ) − 1 .
Since p θ ( k ) ∈ ( 0 , 1 ) , the gradient is negative, and the logit is pushed up.
  • Unified form:
Both cases combine into
∂ L CE ∂ z k = p θ ( k ) − 1 [ k = c true ] .
This gradient is always well-defined and is strongest early in training when p θ ( c true ) is small, providing the largest upward push to the correct logit precisely when the model is most uncertain.

Appendix A.4. Gradient of L ALPHA

L ALPHA ( θ ) = ∑ v ∈ V obs p θ ( v ∣ x ) P ^ ( v , c true ) .
The penalties P ^ ( v , c true ) are constants with respect to θ ; only p θ ( v ) carries dependence on z k .
∂ L ALPHA ∂ z k = ∑ v P ^ ( v , c true ) · ∂ p θ ( v ) ∂ z k .
Split the sum into the v = k term and all v ≠ k terms, then substitute the softmax derivatives from (A1) and (A2):
∂ L ALPHA ∂ z k = P ^ ( k , c true ) · p θ ( k ) 1 − p θ ( k ) + ∑ v ≠ k P ^ ( v , c true ) · − p θ ( v ) p θ ( k ) .
Factor out p θ ( k ) ,
= p θ ( k ) P ^ ( k , c true ) 1 − p θ ( k ) − ∑ v ≠ k P ^ ( v , c true ) p θ ( v ) .
Expand P ^ ( k , c true ) ( 1 − p θ ( k ) ) ,
= p θ ( k ) P ^ ( k , c true ) − { P ^ ( k , c true ) p θ ( k ) + ∑ v ≠ k P ^ ( v , c true ) p θ ( v ) } .
Observe that
P ^ ( k , c true ) p θ ( k ) + ∑ v ≠ k P ^ ( v , c true ) p θ ( v ) = ∑ v P ^ ( v , c true ) p θ ( v ) = L ALPHA
∴ ∂ L ALPHA ∂ z k = p θ ( k ) P ^ ( k , c true ) − L ALPHA .

Appendix B. Gradient Analysis of the Classification Objective

We take the L CE and L ALPHA gradients from (A3) and (A4).  L ALPHA is a state-dependent penalty. z k is pushed up in (A4) if class k’s penalty in [ P ^ ( k , c true ) − L ALPHA ] lies below the current expected penalty L ALPHA . Additionally, the prefactor p θ ( k ) scales this by the model’s current belief in class k. For the true class, P ^ ( c t r u e ) = 0 gives
∂ L A L P H A ∂ z c t r u e = − p θ ( c t r u e ) L A L P H A
an upward push of magnitude p θ ( c t r u e ) L ALPHA that shrinks to zero if p θ ( c t r u e ) → 0 , which depends heavily on the training phase.

When Does ALPHA Favour the True Class?

Let k ⋆ be a close-but-wrong neighbour. The true class receives the stronger upward push when its gradient is more negative than the neighbour’s. So ideally,
− p θ ( c true ) L ALPHA < p θ ( k * ) P ^ ( k * ) − L ALPHA
Multiplying both sides by − 1 to find the magnitude flips the inequality and reverses the subtraction:
p θ ( c true ) L ALPHA > p θ ( k * ) L ALPHA − P ^ ( k * )
Dividing by L ALPHA :
p θ ( c true ) > p θ ( k * ) 1 − P ^ ( k * ) L ALPHA
Since k * is a close neighbour, P ^ ( k * ) will be close to 0 and P ^ ( k * ) L ALPHA ≈ 0 , so:
p θ ( c true ) > p θ ( k * ) 1 − P ^ ( k * ) L ALPHA ≈ p θ ( k * )
The contrast with CE is the entire point. CE’s upward push on the true class is positive for every state due to the 1 [ · ] function; it is unconditional. ALPHA’s push favours the true class only conditionally, when the state-dependent inequality (A5) holds—that is, only while the true class already leads its nearest wrong neighbour. A loss whose corrective effect is contingent on the model already being right cannot, by itself, make an incorrect model right; it can widen an existing margin but cannot open one.

Appendix C. Implementation

Table A1. GRPO Hyperparameters.
All phases train LoRA adapters via peft [41] on a bfloat16 [44] Qwen2.5-Coder-7B-Instruct backbone transformer from the HuggingFace transformer library, with gradient checkpointing and manual device placement. The ALPHA penalty graph is taken from [6]; the teacher corpus is generated offline from Qwen2.5-Coder-32B-Instruct via the Ollama client. SFT and GRPO (Section 3.3) are implemented directly on torch. SFT and GRPO hyperparameters are described in Table A2 and Table A1, respectively.
Table A2. SFT Hyper Parameters.

Appendix D. Classifier Per-Class Prediction Analysis

Table A3 reports per-class recall on SVEN for each of the four classifier conditions in Section 3.2, together with each condition’s most frequently predicted class across the full 342-sample evaluation set, and a fifth row for the default GRPO configuration for direct comparison. Table A4 extends this comparison with exact accuracy, macro-averaged recall, and a hierarchical error-direction breakdown computed using the ALPHA taxonomy graph, for the same conditions plus three independent training seeds of both the default and best-observed GRPO configurations.
Table A3. Classifier recall (%) per SVEN class, by pooling strategy (MP: mean pooling, LTP: last-token pooling) and loss.
Table A4. Hierarchical error-direction breakdown and macro-averaged recall on SVEN. “Max Penalty” covers outputs indicating no vulnerability as well as any out-of-graph or disconnected CWE, all of which receive the maximum penalty.

References

  1. Islam, M.A.; Ali, M.E.; Parvez, M.R. MapCoder: Multi-Agent Code Generation for Competitive Problem Solving. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Bangkok, Thailand; Ku, L.W., Martins, A., Srikumar, V., Eds.; Association for Computational Linguistics: Stroudsburg, PA, USA, 2024; pp. 4912–4944. [Google Scholar] [CrossRef] [Scilit]
  2. Adnan, M.; Kuhn, C.C. Measuring and mitigating debugging effectiveness decay in code language models. Sci. Rep. 2025, 15, 44120. [Google Scholar] [CrossRef] [Scilit]
  3. Adnan, M.; Xu, Z.; Kuhn, C.C.N. Large Language Model Guided Self-Debugging Code Generation. arXiv 2025, arXiv:2502.02928. [Google Scholar] [CrossRef] [Scilit]
  4. Pearce, H.; Ahmad, B.; Tan, B.; Dolan-Gavitt, B.; Karri, R. Asleep at the Keyboard? Assessing the Security of GitHub Copilot’s Code Contributions. Commun. ACM 2025, 68, 96–105. [Google Scholar] [CrossRef] [Scilit]
  5. Tihanyi, N.; Bisztray, T.; Ferrag, M.A.; Jain, R.; Cordeiro, L.C. How secure is AI-generated code: A large-scale comparison of large language models. Empir. Softw. Eng. 2025, 30, 47. [Google Scholar] [CrossRef] [Scilit]
  6. Adnan, M.; Kuhn, C.C.N. Adaptive Hierarchical Evaluation of LLMs and SAST tools for CWE Prediction in Python. In Proceedings of the 2026 International Conference on Advances in Artificial Intelligence and Machine Learning (AAIML), Tokyo, Japan, 20–22 March 2026; pp. 193–200. [Google Scholar] [CrossRef] [Scilit]
  7. Kamoi, R.; Zhang, Y.; Zhang, N.; Han, J.; Zhang, R. When Can LLMs Actually Correct Their Own Mistakes? A Critical Survey of Self-Correction of LLMs. Trans. Assoc. Comput. Linguist. 2024, 12, 1417–1440. [Google Scholar] [CrossRef] [Scilit]
  8. Siddiq, M.L.; Santos, J.C.S. SecurityEval Dataset: Mining Vulnerability Examples to Evaluate Machine Learning-Based Code Generation Techniques. In Proceedings of the 1st International Workshop on Mining Software Repositories Applications for Privacy and Security, Virtual, 18 November 2022. [Google Scholar] [CrossRef] [Scilit]
  9. Bhandari, G.; Naseer, A.; Moonen, L. CVEfixes: Automated collection of vulnerabilities and their fixes from open-source software. In Proceedings of the 17th International Conference on Predictive Models and Data Analytics in Software Engineering, Virtual, 19–20 August 2021; pp. 30–39. [Google Scholar]
  10. He, J.; Vechev, M. Large language models for code: Security hardening and adversarial testing. In Proceedings of the 2023 ACM SIGSAC Conference on Computer and Communications Security, Copenhagen, Denmark, 26–30 November 2023; pp. 1865–1879. [Google Scholar]
  11. He, J.; Vero, M.; Krasnopolska, G.; Vechev, M. Instruction tuning for secure code generation. In Proceedings of the 41st International Conference on Machine Learning, ICML’24, Vienna, Austria, 21–27 July 2024; JMLR.org: Norfolk, MA, USA, 2024. [Google Scholar]
  12. Zhou, X.; Tran, D.M.; Le-Cong, T.; Zhang, T.; Irsan, I.C.; Sumarlin, J.; Le, B.; Lo, D. Comparison of static application security testing tools and large language models for repo-level vulnerability detection. arXiv 2024, arXiv:2407.16235. [Google Scholar]
  13. Yang, Y.; Zhou, X.; Mao, R.; Xu, J.; Yang, L.; Zhang, Y.; Shen, H.; Zhang, H. DLAP: A Deep Learning Augmented Large Language Model Prompting framework for software vulnerability detection. J. Syst. Softw. 2025, 219, 112234. [Google Scholar] [CrossRef] [Scilit]
  14. Quan, H.; Wang, J.; Li, X.; Zhuo, T.Y.; Chen, X.; Du, X. An Empirical Study of Vulnerabilities in Python Packages and Their Detection. arXiv 2025, arXiv:2509.04260. [Google Scholar]
  15. Martin, R.A.; Barnum, S. Common weakness enumeration (CWE) status update. Ada Lett. 2008, XXVIII, 88–91. [Google Scholar] [CrossRef] [Scilit]
  16. Bertinetto, L.; Mueller, R.; Tertikas, K.; Samangooei, S.; Lord, N.A. Making Better Mistakes: Leveraging Class Hierarchies With Deep Networks. In Proceedings of the 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Seattle, WA, USA, 13–19 June 2020; pp. 12503–12512. [Google Scholar] [CrossRef] [Scilit]
  17. Christiano, P.F.; Leike, J.; Brown, T.B.; Martic, M.; Legg, S.; Amodei, D. Deep reinforcement learning from human preferences. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS’17, Long Beach, CA, USA, 4–9 December 2017; Curran Associates Inc.: Red Hook, NY, USA; pp. 4302–4310. [Google Scholar]
  18. Ouyang, L.; Wu, J.; Jiang, X.; Almeida, D.; Wainwright, C.L.; Mishkin, P.; Zhang, C.; Agarwal, S.; Slama, K.; Ray, A.; et al. Training language models to follow instructions with human feedback. In Proceedings of the 36th International Conference on Neural Information Processing Systems, NIPS ’22, New Orleans, LA, USA, 28 November–9 December 2022; Curran Associates Inc.: Red Hook, NY, USA, 2022. [Google Scholar]
  19. Schulman, J.; Wolski, F.; Dhariwal, P.; Radford, A.; Klimov, O. Proximal Policy Optimization Algorithms. arXiv 2017, arXiv:1707.06347. [Google Scholar] [CrossRef] [Scilit]
  20. Shao, Z.; Wang, P.; Zhu, Q.; Xu, R.; Song, J.; Bi, X.; Zhang, H.; Zhang, M.; Li, Y.; Wu, Y.; et al. Deepseekmath: Pushing the limits of mathematical reasoning in open language models. arXiv 2024, arXiv:2402.03300. [Google Scholar]
  21. Le, H.; Wang, Y.; Gotmare, A.D.; Savarese, S.; Hoi, S.C. CodeRL: Mastering code generation through pretrained models and deep reinforcement learning. In Proceedings of the 36th International Conference on Neural Information Processing Systems, NIPS ’22, New Orleans, LA, USA, 28 November–9 December 2022; Curran Associates Inc.: Red Hook, NY, USA, 2022. [Google Scholar]
  22. Shojaee, P.; Jain, A.; Tipirneni, S.; Reddy, C.K. Execution-based code generation using deep reinforcement learning. arXiv 2023, arXiv:2301.13816. [Google Scholar]
  23. Liu, J.; Zhu, Y.; Xiao, K.; Fu, Q.; Han, X.; Wei, Y.; Ye, D. RLTF: Reinforcement Learning from Unit Test Feedback. Trans. Mach. Learn. Res. 2023. Available online: https://openreview.net/forum?id=hjYmsV6nXZ (accessed on 20 August 2026).
  24. Dou, S.; Liu, Y.; Jia, H.; Zhou, E.; Xiong, L.; Shan, J.; Huang, C.; Wang, X.; Fan, X.; Xi, Z.; et al. Stepcoder: Improving code generation with reinforcement learning from compiler feedback. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Bangkok, Thailand, 11–16 August 2024; pp. 4571–4585. [Google Scholar]
  25. Islam, N.T.; Khoury, J.; Seong, A.; Karkevandi, M.B.; Parra, G.D.L.T.; Bou-Harb, E.; Najafirad, P. Llm-powered code vulnerability repair with reinforcement learning and semantic reward. arXiv 2024, arXiv:2401.03374. [Google Scholar]
  26. Islam, N.T.; Karkevandi, M.B.; Najafirad, P. Code Security Vulnerability Repair Using Reinforcement Learning with Large Language. arXiv 2024, arXiv:2401.07031. [Google Scholar] [CrossRef] [Scilit]
  27. Wu, T.; Du, M.; Liu, Y.; Yang, C.; Zhuo, T.Y.; Zhang, J.; Ng, S.K. Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model. arXiv 2026, arXiv:2602.07422. [Google Scholar] [CrossRef] [Scilit]
  28. Yadav, A.S.; Wilson, J.N. R+ r: Security vulnerability dataset quality is critical. In Proceedings of the 2024 Annual Computer Security Applications Conference (ACSAC); IEEE: New York, NY, USA, 2024; pp. 1047–1061. [Google Scholar]
  29. Pujar, S.; Zheng, Y.; Buratti, L.; Lewis, B.; Chen, Y.; Laredo, J.; Morari, A.; Epstein, E.; Lin, T.; Yang, B.; et al. Analyzing source code vulnerabilities in the D2A dataset with ML ensembles and C-BERT. Empir. Softw. Engg. 2024, 29, 48. [Google Scholar] [CrossRef] [Scilit]
  30. Hu, E.J.; Shen, Y.; Wallis, P.; Allen-Zhu, Z.; Li, Y.; Wang, S.; Wang, L.; Chen, W. Lora: Low-rank adaptation of large language models. ICLR 2022, 1, 3. [Google Scholar]
  31. Ennadir, S.; Zólyomi, L.; Smirnov, O.; Wang, T.; Pertoft, J.; Cornell, F.; Cao, L. Pool Me Wisely: On the Effect of Pooling in Transformer-Based Models. In Proceedings of the Thirty-Ninth Annual Conference on Neural Information Processing Systems, Sydney, Australia, 6–12 December 2026. [Google Scholar]
  32. Adnan, M.; Gamage, B.; Xu, Z.; Herath, D.; Kuhn, C.C. Unleashing Artificial Cognition: Integrating Multiple AI Systems. In Proceedings of the Australasian Conference on Information Systems, Canberra, Australia, 4–6 December 2024. [Google Scholar]
  33. Yan, H.; Vaidya, S.S.; Zhang, X.; Yao, Z. Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generation. arXiv 2025, arXiv:2506.23034. [Google Scholar]
  34. Kirkpatrick, J.; Pascanu, R.; Rabinowitz, N.; Veness, J.; Desjardins, G.; Rusu, A.A.; Milan, K.; Quan, J.; Ramalho, T.; Grabska-Barwinska, A.; et al. Overcoming catastrophic forgetting in neural networks. Proc. Natl. Acad. Sci. USA 2017, 114, 3521–3526. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  35. Sutton, R.S.; Barto, A.G. Reinforcement Learning: An Introduction, 2nd ed.; MIT Press: Cambridge, MA, USA, 2018. [Google Scholar]
  36. Kullback, S.; Leibler, R.A. On Information and Sufficiency. Ann. Math. Stat. 1951, 22, 79–86. [Google Scholar] [CrossRef] [Scilit]
  37. Kingma, D.P.; Ba, J. Adam: A method for stochastic optimization. In Proceedings of the International Conference on Learning Representations, San Diego, CA, USA, 7–9 May 2015. [Google Scholar]
  38. Croft, R.; Babar, M.A.; Kholoosi, M.M. Data Quality for Software Vulnerability Datasets. In Proceedings of the 45th International Conference on Software Engineering, ICSE ’23; IEEE Press: New York, NY, USA, 2023; pp. 121–133. [Google Scholar] [CrossRef] [Scilit]
  39. Kim, S.; Woo, S.; Lee, H.; Oh, H. VUDDY: A Scalable Approach for Vulnerable Code Clone Discovery. In Proceedings of the 2017 IEEE Symposium on Security and Privacy (SP), San Jose, CA, USA, 22–24 May 2017; pp. 595–614. [Google Scholar] [CrossRef] [Scilit]
  40. Hui, B.; Yang, J.; Cui, Z.; Yang, J.; Liu, D.; Zhang, L.; Liu, T.; Zhang, J.; Yu, B.; Lu, K.; et al. Qwen2. 5-coder technical report. arXiv 2024, arXiv:2409.12186. [Google Scholar]
  41. Ding, N.; Qin, Y.; Yang, G.; Wei, F.; Yang, Z.; Su, Y.; Hu, S.; Chen, Y.; Chan, C.M.; Chen, W.; et al. Parameter-efficient fine-tuning of large-scale pre-trained language models. Nat. Mach. Intell. 2023, 5, 220–235. [Google Scholar] [CrossRef] [Scilit]
  42. Abellanosa, A.D.; Pereira, E.; Lefsrud, L.; Mohamed, Y. Integrating knowledge management and large language models to advance construction Job Hazard Analysis: A systematic review and conceptual framework. J. Saf. Sustain. 2025, 2, 156–170. [Google Scholar] [CrossRef] [Scilit]
  43. Kahraman, E.; Hosseini, S.; Taiwo, B.O.; Fissha, Y.; Jebutu, V.A.; Akinlabi, A.A.; Adachi, T. Fostering sustainable mining practices in rock blasting: Assessment of blast toe volume prediction using comparative analysis of hybrid ensemble machine learning techniques. J. Saf. Sustain. 2024, 1, 75–88. [Google Scholar] [CrossRef] [Scilit]
  44. Kalamkar, D.; Mudigere, D.; Mellempudi, N.; Das, D.; Banerjee, K.; Avancha, S.; Vooturi, D.T.; Jammalamadaka, N.; Huang, J.; Yuen, H.; et al. A study of BFLOAT16 for deep learning training. arXiv 2019, arXiv:1905.12322. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.