Style2Code: A Style-Controllable Code Generation Framework with Dual-Modal Contrastive Representation Learning
Fuente:
arXiv
Enregistré dans:
| Auteurs principaux: | , , , |
|---|---|
| Format: | Preprint |
| Publié: |
2025
|
| Sujets: | |
| Accès en ligne: | |
| Tags: |
Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
|
| _version_ | 1866909999414902784 |
|---|---|
| author | Zhang, Dutao Arias, Nicolas Rafael Arroyo He, YuLong Kovalchuk, Sergey |
| author_facet | Zhang, Dutao Arias, Nicolas Rafael Arroyo He, YuLong Kovalchuk, Sergey |
| contents | 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. |
| format | Preprint |
| id |
arxiv_https___arxiv_org_abs_2505_19442 |
| institution | arXiv |
| publishDate | 2025 |
| record_format | arxiv |
| spellingShingle | Style2Code: A Style-Controllable Code Generation Framework with Dual-Modal Contrastive Representation Learning Zhang, Dutao Arias, Nicolas Rafael Arroyo He, YuLong Kovalchuk, Sergey Artificial Intelligence I.2.6; D.2.3 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. |
| title | Style2Code: A Style-Controllable Code Generation Framework with Dual-Modal Contrastive Representation Learning |
| topic | Artificial Intelligence I.2.6; D.2.3 |
| url | https://arxiv.org/abs/2505.19442 |