Duetcs: Code Style Transfer through Generation and Retrieval
Binger Chen, Ziawasch Abedjan
Abstract
Coding style has direct impact on code comprehension. Automatically transferring code style to user's preference or consistency can facilitate project cooperation and maintenance, as well as maximize the value of open-source code. Existing work on automating code stylization is either limited to code formatting or requires human supervision in pre-defining style checking and transformation rules. In this paper, we present unsupervised methods to assist automatic code style transfer for arbitrary code styles. The main idea is to leverage Big Code database to learn style and content embedding separately to generate or retrieve a piece of code with the same functionality and the desired target style. We carefully encode style and content features, so that a style embedding can be learned from arbitrary code. We explored the capabilities of novel attention-based style generation models and meta-learning and implemented our ideas in DUETCS. We complement the learning-based approach with a retrieval mode, which uses the same embeddings to directly search for the desired piece of code in Big Code. Our experiments show that DUETCS captures more style aspects than existing baselines.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 7049c37b-b8aa-406f-b6ff-26e74deee7bbCited by top-tier papers1
Ask how each one uses itBuilds on4
- Unsupervised Translation of Programming LanguagesBaptiste Rozière, Marie-Anne Lachaux, Lowik Chanussot, Guillaume LampleNeurIPS 2020 · 606 citations
- Language-Agnostic Representation Learning of Source Code from Structure and ContextDaniel Zügner, Tobias Kirschstein, Michele Catasta, Jure Leskovec et al.ICLR 2021 · 131 citations
- Exploiting Structured Knowledge in Text via Graph-Guided Representation LearningTao Shen, Yi Mao, Pengcheng He, Guodong Long et al.EMNLP 2020 · 60 citations
- Interactive Cross-language Code Retrieval with Auto-EncodersBinger Chen, Ziawasch AbedjanASE 2021 · 7 citations
Related papers
- Transductive Learning for Unsupervised Text Style TransferFei Xiao, Liang Pang, Yanyan Lan, Yan Wang et al.EMNLP 2021 · 20 citations
- Disentangled Learning with Synthetic Parallel Data for Text Style TransferJingxuan Han, Quan Wang, Zikang Guo, Benfeng Xu et al.ACL 2024 · 4 citations
- Collaborative Learning of Bidirectional Decoders for Unsupervised Text Style TransferYun Ma, Yangbin Chen, Xudong Mao, Qing LiEMNLP 2021 · 6 citations
- Reformulating Unsupervised Style Transfer as Paraphrase GenerationKalpesh Krishna, John Wieting, Mohit IyyerEMNLP 2020 · 9 citations
- A Style is Worth One Code: Unlocking Code-to-Style Image Generation with Discrete Style SpaceHuijie Liu, Shuhao Cui, Haoxiang Cao, Shuai Ma et al.CVPR 2026 · 1 citation
