Skip to content

Linear Correction Mixture (MoC) makes large language models generate safer codeA Mixture of Linear Corrections Generates Secure Code

arXiv· arXiv:2507.09508· Weichen Yu, Ravi Mangal, Terry Zhuo, Matt Fredrikson, Corina S. Pasareanu·Indexed by this site · 27 days ago· Originally publishedDefenses
AI summary

The researchers propose an inference-time steering method, MoC (Mixture of Corrections), which guides large language models to generate code with fewer vulnerabilities without harming functionality by adjusting the model's token generation probabilities. Representation engineering analysis shows that current large language models internally encode representations that distinguish vulnerable code from secure code, with discrimination accuracy higher than standard prompting methods. On Qwen2.5-Coder-7B, MoC improves the security rate by 8.9% and simultaneously improves HumanEval pass@1 by 2.1%.

Read originalarxiv.org