AIMay 26, 2025

Style2Code: A Style-Controllable Code Generation Framework with Dual-Modal Contrastive Representation Learning

arXiv:2505.19442v31 citations
Originality Incremental advance
AI Analysis

This work addresses the challenge of generating code with specific styles for developers, but it is incremental as it builds on existing methods like Flan-T5.

The paper tackles the problem of controllable code generation by synthesizing code that follows a specified style while maintaining functionality, proposing a two-stage training framework that combines contrastive learning and conditional decoding to enable flexible style control, with results showing improved stylistic control without sacrificing code correctness.

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.

Code Implementations1 repo
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes