ICTAI 2026 Accepted
Continuous Retrieval-Grounded Reward Design for Secure Code Generation on Small Language Models (CARGO)
Small code models trained on security-scanner verdicts stall because nearly every early attempt scores the same zero, so this also scores each attempt against a retrieved secure fix to give training something to climb.
- SAST-only GRPO on Qwen2.5-Coder-1.5B updates the policy on fewer than 9% of steps: rollouts that fail to parse all score zero and the group-relative advantage collapses. A copy-guarded cosine reward against a CWE-retrieved secure fix lifts that to 94.8%.
- Over SAST-only GRPO on 1,582 prompts across 19 CWEs in Python, C, and C++: +19.9 pp Compile@1, +16.6 pp Secure@1|Compile, +26.5 pp Functional-Secure@1.
- Not tied to one optimizer: the retrieval reward lifts GRPO, PPO, RLOO, and RAFT by 22.5 to 26.5 pp, and reproduces on Qwen2.5-Coder-3B (+20.9) and StarCoder2-3B (+19.2).
- Python
- PyTorch
- PEFT (LoRA)
- GRPO / PPO / RLOO / RAFT
- CodeQL
- Semgrep
- Bandit
- Cppcheck
- BM25 + bge-base
- Qwen2.5-Coder