← Back to all development cases
This case was judged by an anonymized AI reviewer and has not been independently reviewed by people; inspect the draft, cards, and both outputs to assess it.
AutocompleteWith cards better280 / 280 · beu-cb8593ab297330d9

On Fixing Insecure AI-Generated Code through Model Fine-Tuning and Prompting Strategies

Computer science · 2605.05867v1

FLOWING EVIDENCE BENCHMARK

How do we compare writing with and without cards?

At the same writing position, the same model produces one first result with cards and one without. All 280 pairs enter the overall anonymized review, which assesses whether a decision not to continue fits the draft.

Overall: 138 with-card wins, 26 ties, 107 no-card wins, 5 pairs where neither was usable, and 4 inconclusive judgments. Both sides wrote text in 218 pairs; 48 had a deliberate stop and 14 included an invalid output.

SAME DRAFT · WITH OR WITHOUT CARDS

01 · FIXED WRITING POSITION

MANUSCRIPT

Same writing position ▌

Matched autocomplete at the same draft position

02 · TWO MATCHED VERSIONS

SHARED BY BOTH

Draft, writing task, and generation model

A · With cards

Relevant literature cards supplied

B · Without cards

No literature cards supplied

Generation model

Same model and version

A → first output

B → first output

Anonymized AI judge

First outputs are anonymized as X and Y

Continuation review: accuracy, fit to the writing task and usability
Returns: X preferred / tie / Y preferred / both unusable

Review again with the answer order swapped

HOW DOES BLIND JUDGING WORK?

① Anonymize both outputs
The AI judge sees the same draft and both first outputs without knowing which received cards.

② Compare and swap order
The judge applies task-specific criteria in X/Y and then Y/X order.

③ Review disagreements
A third pass resolves disagreements. Incomplete reviews remain in the denominator.

How are positions and cards selected?

We selected 40 writing positions in each of seven fields, for 280 comparisons. The position and relevant literature cards were set before each comparison, so both versions began from the same draft.

The main result retains every frozen position, including places where cards might not add a useful next move. This avoids selecting cases based on their outputs, but 49% describes the whole cohort, not a win rate where evidence clearly had an opportunity to help. This cohort did not record that opportunity label for each position before generation, so those two groups cannot yet be separated reliably.

CARD USE · 140/280

Reported card use in continuations with text

The model reports whether a card affected its continuation. In 140 of 280 tests it produced continuation text and reported card use. The previous count of 150 included 10 cases without continuation text and has been corrected.

COMPARISON · 70 / 7 / 30

Which written version was better?

Of the 107 reported-use cases where both versions produced text, the blinded AI judge preferred the with-card version 70 times, found 7 about the same, and preferred the without-card version 30 times.

How are the two table percentages calculated?

ADOPTION COVERAGE

140reported use with text
÷
280all positions
=
50%

WITH-CARD VERSION PREFERRED

70with cards better
÷
107comparable tests
=
65%

The percentages use different groups: 50% counts continuations with text reporting card use among all 280 tests; 65% covers the 107 such cases with text on both sides. The generating model reports card use, while an anonymized AI judge compares writing quality.

Card use is self-reported by the generator. The anonymized AI judge sees the draft and source snippets, so source-aware preference remains possible; there was no independent human review. The overall result describes these 280 frozen positions, not a win probability for any writing task.

Manuscript writing position

Text excerpt · not a PDF page

Research manuscript · excerpt

On Fixing Insecure AI-Generated Code through Model Fine-Tuning and Prompting Strategies

body

One of the earlier efforts is LLMSecEval (developed in 2023), which provides 150 natural-language prompts tied to MITRE’s Top-25 CWEs and includes secure reference implementations, allowing model outputs to be checked against known vulnerabilities [56]. Another benchmark, CodeLMSec, was introduced in 2024. Using a dataset of 280 non-secure prompts in Python and C, models were tested with CodeQL to quantify the number of outputs that contain high-risk CWEs [24]. In our study, static code analysis is utilised. The CodeQL tool was chosen for security analysis to identify security weaknesses in code samples. 2.4 Techniques to Mitigate Vulnerabilities in AI-Generated Code As the security of AI-generated code has become a growing concern, recent research has focused on developing various mitigation strategies to remove as many security weaknesses as possible from AI-generated code. One prominent method is to train models on security-aligned code datasets. For example, a paper by Xu et al. [62] describes ProSec; a fine-tuning approach where a dataset of synthetic code snippets is

↓ Next paragraph was generated here

The highlighted text is near the writing position. This is a layout of the evaluation input, not a PDF screenshot.

A matched comparison at the same writing positionOverall AI review: With cards better

Both arms use the same model, task and manuscript context. Only the retrieved passages differ. The first recorded output from each arm is shown below.

Read overall AI review rationale

A = with cards · B = without cards

Both outputs complete the sentence about ProSec appropriately, but Output A is significantly more useful. The draft has established a pattern of substantive, source-grounded descriptions (LLMSecEval with '150 natural-language prompts tied to MITRE's Top-25 CWEs,' CodeLMSec with '280 non-secure prompts in Python and C'). Output A matches this scope by specifying that the synthetic code snippets are 'generated from Common Weakness Enumerations (CWEs)' and that alignment occurs 'through preference learning'—both details directly supported by the ProSec source snippet, which mentions 'synthesizing error-inducing coding scenarios from Common Weakness Enumerations (CWEs)' and 'advanced preference learning objectives.' Output B is factually correct but overly generic ('used to fine-tune a model so that it generates more secure code'); it adds no specific information beyond what 'ProSec; a fine-tuning approach' already conveys. Output A fits the draft's informational density and argumentative style, continuing the pattern of concrete technical detail that makes the survey useful.

Evidence

Same model and position · retrieved passages supplied · first output

Preferred by blind review

generated from Common Weakness Enumerations (CWEs) and used to align the model with secure coding practices through preference learning.

Passages supplied to the Evidence version

Card 1 · ProSec: Fortifying Code LLMs with Proactive Security Alignment

In this paper, we propose PROSEC, a novel proactive security align- ment approach designed to align code LLMs with secure coding practices. PROSEC systematically exposes the vulnerabilities in a code LLM by syn- thesizing error-inducing coding scenarios from Common Weakness Enumerations (CWEs), and…

Read full passage excerpt

In this paper, we propose PROSEC, a novel proactive security align- ment approach designed to align code LLMs with secure coding practices. PROSEC systematically exposes the vulnerabilities in a code LLM by syn- thesizing error-inducing coding scenarios from Common Weakness Enumerations (CWEs), and generates fixes to vulnerable code snippets, allow- ing the model to learn secure practices through advanced preference learning objectives

Card 2 · Emergent Abilities in Large Language Models: A Survey

Large Language Models (LLMs) are leading a new technological revolution as one of the most promising research streams toward artificial general intelligence. The scaling of these models, accomplished by increasing the number of parameters and the magnitude of the training datasets, has been linked t…

Read full passage excerpt

Large Language Models (LLMs) are leading a new technological revolution as one of the most promising research streams toward artificial general intelligence. The scaling of these models, accomplished by increasing the number of parameters and the magnitude of the training datasets, has been linked to various so-called emergent abilities that were previously unobserved. These emergent abilities, ranging from advanced reasoning and in-context learning to coding and problem-solving, have sparked an intense scientific debate: Are they truly emergent, or do they simply depend on external factors, such as training dynamics, the type of problems, or the chosen metric? What underlying mechanism causes them? Despite their transformative potential, emergent abilities remain poorly understood, leading to misconceptions about their definition, nature, predictability, and implications. In this work, we shed light on emergent abilities by conducting a comprehensive review of the phenomenon, addressi …

Card 3 · MoE-LLaVA: Mixture of Experts for Large Vision-Language Models

Recent advances demonstrate that scaling Large Vision-Language Models (LVLMs) effectively improves downstream task performances. However, existing scaling methods enable all model parameters to be active for each token in the calculation, which brings massive training and inferring costs. In this wo…

Read full passage excerpt

Recent advances demonstrate that scaling Large Vision-Language Models (LVLMs) effectively improves downstream task performances. However, existing scaling methods enable all model parameters to be active for each token in the calculation, which brings massive training and inferring costs. In this work, we propose a simple yet effective training strategy MoE-Tuning for LVLMs. This strategy innovatively addresses the common issue of performance degradation in multi-modal sparsity learning, consequently constructing a sparse model with an outrageous number of parameters but a constant computational cost. Furthermore, we present the MoE-LLaVA, a MoE-based sparse LVLM architecture, which uniquely activates only the top-k experts through routers during deployment, keeping the remaining experts inactive. Extensive experiments show the significant performance of MoE-LLaVA in a variety of visual understanding and object hallucination benchmarks. Remarkably, with only approximately 3B sparsely a …

Card 4 · Towards Efficient Mixture of Experts: A Holistic Study of Compression Techniques

Scaling large language models has driven remarkable advancements across various domains, yet the continual increase in model size presents significant challenges for real-world deployment. The Mixture of Experts (MoE) architecture offers a promising solution by dynamically selecting and activating o…

Read full passage excerpt

Scaling large language models has driven remarkable advancements across various domains, yet the continual increase in model size presents significant challenges for real-world deployment. The Mixture of Experts (MoE) architecture offers a promising solution by dynamically selecting and activating only a subset of experts during inference, thus substantially reducing computational costs while preserving high performance. Despite these benefits, MoE introduces new inefficiencies, such as excessive parameters and communication overhead. In this work, we present a holistic study of compression techniques for Mixture of Experts to enhance both efficiency and scalability. While recent efforts have focused on Expert Trimming, which reduces the number of experts, these approaches still suffer from considerable communication and computational costs. To address this, we propose more aggressive strategies, such as Layer Drop, which removes entire MoE layers, and Block Drop, which eliminates tran …

Card 5 · Improving Multi-Step Reasoning Abilities of Large Language Models with Direct Advantage Policy Optimization

The role of reinforcement learning (RL) in enhancing the reasoning of large language models (LLMs) is becoming increasingly significant. Despite the success of RL in many scenarios, there are still many challenges in improving the reasoning of LLMs. One challenge is the sparse reward, which makes op…

Read full passage excerpt

The role of reinforcement learning (RL) in enhancing the reasoning of large language models (LLMs) is becoming increasingly significant. Despite the success of RL in many scenarios, there are still many challenges in improving the reasoning of LLMs. One challenge is the sparse reward, which makes optimization difficult for RL and necessitates a large amount of data samples. Another challenge stems from the inherent instability of RL, particularly when using Actor-Critic (AC) methods to derive optimal policies, which often leads to unstable training processes. To address these issues, we introduce Direct Advantage Policy Optimization (DAPO), an novel step-level offline RL algorithm. Unlike standard alignment that rely solely outcome rewards to optimize policies (such as DPO), DAPO employs a critic function to predict the reasoning accuracy at each step, thereby generating dense signals to refine the generation strategy. Additionally, the Actor and Critic components in DAPO are trained i …

Model-reported card use

Card 1 · fact

Affected output: generated from Common Weakness Enumerations (CWEs) and used to align the model with secure coding practices through preference learning.

Model explanation: The row supplies the concrete facts that ProSec's synthetic snippets are derived from CWEs and that alignment is achieved via preference learning, which completes the unfinished clause about Xu et al.'s ProSec.

No Evidence

Same model and position · no retrieved passages · first output

Not preferred in this comparison

used to fine-tune a model so that it generates more secure code.

Earlier card-use comparison

The earlier diagnostic compared only cases with reported card use and text on both sides; its scope differs from the overall AI review above.

The blinded model review preferred the Evidence version. Its original rationale appears below.

Read the original model judgment

Both outputs complete the sentence conservatively and are source-grounded. Output A is preferable because it directly incorporates specific, accurate details from the ProSec source: (1) the dataset is 'generated from Common Weakness Enumerations (CWEs)' — matching 'synthesizing error-inducing coding scenarios from Common Weakness Enumerations (CWEs)', and (2) it uses 'preference learning' — matching 'advanced preference learning objectives'. Output A also captures the 'align the model with secure coding practices' purpose stated in the source. Output B is more generic ('fine-tune a model so that it generates more secure code') and loses the specific mechanisms (CWEs, preference learning) that distinguish ProSec's approach. Output A requires less editing to be publication-ready while preserving the draft's scope and meaning.

The passages are input material; their presence does not mean an output used them or that they support every claim. Draft and source passages are excerpted; no simulated scores or PDF appear here.