paper-with-me

Papers

Learn from Your Mistakes: Tree-like Self-Play for Secure Code LLMs

2026-06-02 · Wenqi Chen, Ziyan Zhang, Bin Wang, Lin Liu, Hengheng Zhang, Zhengsu Chen arxiv

While Large Language Models (LLMs) excel in code generation, they remain prone to replicating subtle yet critical vulnerabilities endemic to their training data. Current alignment techniques, such as Supervised Fine-Tuning (SFT) and Reinforcement Learning (RL), typically apply coarse-grained optimization at the sequence level. This approach often fails to address the localized nature of security flaws, where a single incorrect token choice can compromise an entire program. To bridge this gap, we introduce Tree-like Self-Play (TSP), a framework that reframes secure code generation as a fine-grained sequential decision process. Unlike standard methods that blindly maximize likelihood, TSP constructs a decision tree where the model explores branching trajectories--generating both secure "golden paths" and vulnerable variants. By treating code generation as a self-play game, the model learns to strictly discriminate against its own localized errors. This provides a dense, on-policy learning signal that forces self-correction precisely at the critical decision nodes where vulnerabilities typically emerge. Our experiments demonstrate that TSP fundamentally enhances model reliability. In Python security benchmarks, TSP boosts CodeLlama-7B's pass rate (SPR@1) to 75.8%, significantly outperforming SFT (57.0%) and unstructured self-play baselines. Crucially, TSP induces robust out-of-distribution generalization: the model not only reduces vulnerabilities in unseen categories (CWEs) by 24.5% but also successfully transfers security principles learned from C/C++ to diverse languages, including Python, Go, and JavaScript. This suggests that TSP does not merely memorize patches, but internalizes abstract, language-agnostic security logic.

📄 PDF Abstract BibTeX arXiv:2606.03489

Code (0)

등록된 구현이 없습니다.

Tasks

Reinforcement LearningCode Generation

Similar Papers 제목 키워드 기반

Learn from Your Mistakes: Self-Correcting Masked Diffusion Models

2026-02-12 · Yair Schiff, Omer Belhasin, Roy Uziel, Guanghan Wang 외 arxiv

Masked diffusion models (MDMs) have emerged as a promising alternative to autoregressive models, enabling parallel token generation while achieving competitive performance. Despite these advantages, MDMs face a fundament…

Correct Yourself, Keep My Trust: How Self-Correction and Social Connection Shape Credibility in Social Chatbots

2026-06-17 · Biswadeep Sen, Yi-Chieh Lee arxiv

When social chatbots make mistakes, and they do, how they recover determines whether users trust them again. Social chatbots are increasingly integrated into everyday life, yet they remain prone to generating convincing …

Self-Reflection Outcome is Sensitive to Prompt Construction

2024-06-14 · Fengyuan Liu, Nouar AlDahoul, Gregory Eady, Yasir Zaki 외

Large language models (LLMs) demonstrate impressive zero-shot and few-shot reasoning capabilities. Some propose that such capabilities can be improved through self-reflection, i.e., letting LLMs reflect on their own outp…

Prompt Engineering

Zero-Shot Multi-Hop Question Answering via Monte-Carlo Tree Search with Large Language Models

2024-09-28 · Seongmin Lee, Jaewook Shin, Youngjin Ahn, Seokin Seo 외

Recent advances in large language models (LLMs) have significantly impacted the domain of multi-hop question answering (MHQA), where systems are required to aggregate information and infer answers from disparate pieces o…

Multi-hop Question AnsweringQuestion Answering

Effective Large Language Model Debugging with Best-first Tree Search

2024-07-26 · Jialin Song, Jonathan Raiman, Bryan Catanzaro

Large Language Models (LLMs) show promise in code generation tasks. However, their code-writing abilities are often limited in scope: while they can successfully implement simple functions, they struggle with more comple…

Code GenerationLanguage ModelingLanguage ModellingLarge Language Model