Post-Incorporating Code Structural Knowledge into Pretrained Models via ICL for Code Translation
Code translation migrates codebases across programming languages. Recently, large language models (LLMs) have achieved significant advancements in software mining. However, handling the syntactic structure of source code remains a challenge. Classic syntax-aware methods depend on intricate model architectures and loss functions, rendering their integration into LLM training resource-intensive. This paper employs in-context learning (ICL), which directly integrates task exemplars into the input context, to post-incorporate code structural knowledge into pre-trained LLMs. We revisit exemplar selection in ICL from an information-theoretic perspective, proposing that list-wise selection based on information coverage is more precise and general objective than traditional methods based on combine similarity and diversity. To address the challenges of quantifying information coverage, we introduce a surrogate measure, Coverage of Abstract Syntax Tree~(CAST), measuring maximum subtree coverage between ASTs of test source code and exemplars. Furthermore, we formulate the NP-hard CAST maximization for exemplar selection and prove that it is a standard submodular maximization problem. Therefore, we propose a greedy algorithm for CAST submodular maximization, which theoretically guarantees a $(1-1/e)$-approximate solution in polynomial time complexity. Our method is the first training-free and model-agnostic approach to post-incorporate code structural knowledge into existing LLMs at test time. Experimental results show that our method significantly improves LLMs performance in code translation and reveals two meaningful insights: 1) Code structural knowledge can be effectively post-incorporated into pre-trained LLMs during inference, despite being overlooked during training; 2) Scaling up model size or training data does not lead to the emergence of code structural knowledge, underscoring the necessity of explicitly considering code syntactic structure.
Thu 9 JulDisplayed time zone: Eastern Time (US & Canada) change
14:00 - 15:30 | Code translation and transformation 2Tool Demonstrations / Journal-First Paper / Research Papers at MB 3.270 Chair(s): Wesley K.G. Assunção North Carolina State University | ||
14:00 20mTalk | Post-Incorporating Code Structural Knowledge into Pretrained Models via ICL for Code Translation Journal-First Paper | ||
14:20 20mTalk | TransLibEval: Demystify Large Language Models’ Capability in Third-party Library-targeted Code Translation Research Papers Pengyu Xue Shandong University, Kunwu Zheng Shandong University, Zhen Yang Shandong University, Yifei Pei Shandong University, Linhao Wu Shandong University, Jiahui Dong Shandong University, Xiapu Luo Hong Kong Polytechnic University, Yan Xiao Sun Yat-sen University, Fei Liu Shandong University, Yuxuan Zhang Shandong University, Xiran Lyu Shandong University, Xianhang Li Shandong University, Xuanyu Zhu Shandong University, Chengyi Wang Shandong University Pre-print | ||
14:40 20mTalk | TransAgent: Enhancing LLM-Based Code Translation via Fine-Grained Execution Alignment Research Papers Zhiqiang Yuan Fudan University, Weitong Chen Fudan University, Hanlin Wang Fudan University, Xin Peng Fudan University, Zhenpeng Chen Tsinghua University, Yiling Lou University of Illinois at Urbana-Champaign | ||
15:00 10mTalk | CoRenameAgent: A Human-In-The-Loop, Multi-Agent Tool for Coordinated Rename Refactoring Tool Demonstrations Abhiram Bellur University of Colorado Boulder, Mohammed Raihan Ullah University of Colorado Boulder, Fraol Batole Tulane University, Mohit Kansara The University of Texas at Dallas, Masaharu Morimoto NEC Corporation, Kai Ishikawa NEC Corporation, Haifeng Chen NEC Laboratories America, Helena Klause JetBrains, Yaroslav Zharov JetBrains Research, Germany, Timofey Bryksin JetBrains Research, Tien N. Nguyen University of Texas at Dallas, Hridesh Rajan Tulane University, Nikolaos Tsantalis Concordia University, Danny Dig University of Colorado Boulder, JetBrains Research | ||
15:10 20mTalk | C2SaferRust: Transforming C Projects Into Safer Rust With NeuroSymbolic Techniques Journal-First Paper Vikram Nitin Columbia University, Rahul Krishna IBM Research, Luiz Lemos do Valle Columbia University, Baishakhi Ray Columbia University | ||