Lune

ICSE2023Top-tier venue

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 Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

1 top-tier paper has cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Interactive Cross-language Code Retrieval with Auto-Encoders cites Unsupervised Translation of Programming Languages
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers1

  1. Beyond Functional Correctness: Investigating Coding Style Inconsistencies in Large Language ModelsYanlin Wang, Tianyue Jiang, Mingwei Liu, Jiachi Chen et al.FSE 2025 · 6 citations

Builds on4

  1. Unsupervised Translation of Programming LanguagesBaptiste Rozière, Marie-Anne Lachaux, Lowik Chanussot, Guillaume LampleNeurIPS 2020 · 606 citations
  2. 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
  3. Exploiting Structured Knowledge in Text via Graph-Guided Representation LearningTao Shen, Yi Mao, Pengcheng He, Guodong Long et al.EMNLP 2020 · 60 citations
  4. Interactive Cross-language Code Retrieval with Auto-EncodersBinger Chen, Ziawasch AbedjanASE 2021 · 7 citations

Related papers

  1. Transductive Learning for Unsupervised Text Style TransferFei Xiao, Liang Pang, Yanyan Lan, Yan Wang et al.EMNLP 2021 · 20 citations
  2. Prefix-Tuning Based Unsupervised Text Style TransferHuiyu Mai, Wenhao Jiang, Zhi-Hong DengEMNLP Findings 2023 · 4 citations
  3. Disentangled Learning with Synthetic Parallel Data for Text Style TransferJingxuan Han, Quan Wang, Zikang Guo, Benfeng Xu et al.ACL 2024 · 4 citations
  4. Collaborative Learning of Bidirectional Decoders for Unsupervised Text Style TransferYun Ma, Yangbin Chen, Xudong Mao, Qing LiEMNLP 2021 · 6 citations
  5. Reformulating Unsupervised Style Transfer as Paraphrase GenerationKalpesh Krishna, John Wieting, Mohit IyyerEMNLP 2020 · 9 citations
Dusk over the sea between two cliffs drawn in fine vertical lines