자기 회귀적이지만 수정 가능한: 안전한 코드 생성을 위한 수정 과정 모델링
Autoregressive, Yet Revisable: In Decoding Revision for Secure Code Generation
대규모 언어 모델(LLM) 기반 코드 생성은 주로 엄격하게 단조적인 과정으로 구성되며, 변경 불가능한 접두부에 토큰을 선형적으로 추가하는 방식으로 이루어집니다. 이러한 방식은 프로그래밍의 인지 과정과 대조되는데, 프로그래밍은 본질적으로 순방향 생성과 실시간 수정이 결합된 과정입니다. 기존 연구에서는 수정 기능을 추가하기 위해 사후 에이전트나 외부 정적 도구를 사용하려는 시도가 있었지만, 이러한 방법은 높은 지연 시간을 초래하거나 모델의 고유한 의미론적 추론 능력을 활용하지 못하는 경우가 많습니다. 본 논문에서는 모델의 고유한 기능을 활용하여 코드 생성을 단조적인 스트림에서 동적이고 자기 수정 가능한 경로로 전환하는 새로운 패러다임인 '수정 스트림(Stream of Revision)'을 제안합니다. 우리는 모델이 단일 순방향 과정 내에서 자체적으로 이전 내용을 되돌아가 수정할 수 있도록 하는 특정 액션 토큰을 도입했습니다. '수정 스트림' 프레임워크는 수정 과정을 내부화함으로써, 모델이 외부 의존성 없이 필요한 시점에 잠재된 능력을 활성화할 수 있도록 합니다. 안전한 코드 생성에 대한 실험 결과는 '수정 스트림'이 최소한의 추론 오버헤드로 상당한 수준의 취약점을 감소시키는 것을 보여줍니다.
Large Language Model (LLM) based code generation is predominantly formulated as a strictly monotonic process, appending tokens linearly to an immutable prefix. This formulation contrasts to the cognitive process of programming, which is inherently interleaved with forward generation and on-the-fly revision. While prior works attempt to introduce revision via post-hoc agents or external static tools, they either suffer from high latency or fail to leverage the model's intrinsic semantic reasoning. In this paper, we propose Stream of Revision, a paradigm shift that elevates code generation from a monotonic stream to a dynamic, self-correcting trajectory by leveraging model's intrinsic capabilities. We introduce specific action tokens that enable the model to seamlessly backtrack and edit its own history within a single forward pass. By internalizing the revision loop, our framework Stream of Revision allows the model to activate its latent capabilities just-in-time without external dependencies. Empirical results on secure code generation show that Stream of Revision significantly reduces vulnerabilities with minimal inference overhead.
No Analysis Report Yet
This paper hasn't been analyzed by Gemini yet.