View a PDF of the paper titled Style2Code: A Style-Controllable Code Generation Framework with Dual-Modal Contrastive Representation Learning, by Dutao Zhang and 2 other authors
View PDF
HTML (experimental)
Abstract:Controllable code generation, the ability to synthesize code that follows a specified style while maintaining functionality, remains a challenging task. We propose a two-stage training framework combining contrastive learning and conditional decoding to enable flexible style control. The first stage aligns code style representations with semantic and structural features. In the second stage, we fine-tune a language model (e.g., Flan-T5) conditioned on the learned style vector to guide generation. Our method supports style interpolation and user personalization via lightweight mixing. Compared to prior work, our unified framework offers improved stylistic control without sacrificing code correctness. This is among the first approaches to combine contrastive alignment with conditional decoding for style-guided code generation.
Submission history
From: Dutao Zhang [view email]
[v1]
Mon, 26 May 2025 03:00:20 UTC (1,529 KB)
[v2]
Sun, 22 Jun 2025 15:54:59 UTC (286 KB)