Proceedings

Improving Code Translation with Syntax-Guided and Semantic-aware Preference Optimization

Download BibTeX Cite

Proceedings of the Thirty-Fifth International Joint Conference on Artificial Intelligence. Main Track. Pages 5973-5981.

https://doi.org/10.24963/ijcai.2026/665

Abstract

LLMs have shown immense potential for code translation, yet they often struggle to ensure both syntactic correctness and semantic consistency. While preference-based learning offers a promising alignment strategy, it is hindered by unreliable semantic rewards derived from sparse test cases or restrictive reference translations. We argue that a robust semantic reward for code translation must be derived directly from the source code. In this paper, we propose CTO to improve code translation with syntax-guided and semantic-aware preference optimization.

Through contrastive learning, we train a cross-lingual semantic model to directly assess functional equivalence between source and translated code. By formulating code translation as a multi-objective optimization problem, this robust semantic signal is seamlessly unified with compiler-based syntactic feedback within the direct preference optimization framework. Extensive experiments on C++, Java, and Python translations demonstrate that CTO significantly outperforms existing baselines and alternative preference optimization strategies.

  1. [Azar et al., 2024] Mohammad Gheshlaghi Azar, Zhao- han Daniel Guo, Bilal Piot, Remi Munos, Mark Rowland, Michal Valko, and Daniele Calandriello. A general theo- retical paradigm to understand learning from human pref- erences. In PMLR, volume 238, pages 4447-4455, Palau de Congresos, VLC, Spain, 2024. PMLR.
  2. [Chen et al., 2021] Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. CoRR, 2107.03374:1-35, 2021.
  3. [Du et al., 2024] Yali Du, Hui Sun, and Ming Li. A joint learning model with variational interaction for multilin- gual program translation. In ASE, pages 1907-1918, Sacramento, CA, USA, 2024. ACM.
  4. [Feng et al., 2020] Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, et al. CodeBERT: A pre- trained model for programming and natural languages. In EMNLP, pages 1536-1547, Virtual, 2020. ACL.
  5. [Feng et al., 2024] Duanyu Feng, Bowen Qin, Chen Huang, Zheng Zhang, and Wenqiang Lei. Towards analyzing and understanding the limitations of DPO: A theoretical per- spective. CoRR, 2404.04626:1-8, 2024.
  6. [Gee et al., 2025] Leonidas Gee, Milan Gritta, Gerasimos Lampouras, and Ignacio Iacobacci. Code-Optimise: Self- generated preference data for correctness and efficiency. In Findings of NAACL, pages 79-94, Albuquerque, NM, USA, 2025. ACL.
  7. [Guo et al., 2021] Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, Shujie Liu, Long Zhou, Nan Duan, Alexey Svyatkovskiy, Shengyu Fu, et al. GraphCode- BERT: Pre-training code representations with data flow. In ICLR, pages 1-18, Virtual, 2021. OpenReview.net.
  8. [Hu et al., 2022] Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. In ICLR, pages 1-26, Virtual, 2022. OpenReview.net.
  9. [Huang et al., 2023] Yufan Huang, Mengnan Qi, Yongqiang Yao, Maoquan Wang, Bin Gu, Colin Clement, and Neel Sundaresan. Program translation via code distillation. In EMNLP, pages 10903-10914, Singapore, 2023. ACL.
  10. [Hui et al., 2024] Binyuan Hui, Jian Yang, Zeyu Cui, Jiaxi Yang, Dayiheng Liu, Lei Zhang, Tianyu Liu, Jiajun Zhang, Bowen Yu, Keming Lu, et al. Qwen2.5-coder technical report. CoRR, 2409.1218:1-32, 2024.
  11. [Ibrahimzada et al., 2024] Ali Reza Ibrahimzada, Kaiyao Ke, Mrigank Pawagi, Muhammad Salman Abid, Rangeet Pan, Saurabh Sinha, and Reyhaneh Jabbar- vand. Repository-level compositional code translation and validation. CoRR, 2410.24117:1-22, 2024.
  12. [Khan et al., 2024] Mohammad Abdullah Matin Khan, M. Saiful Bari, Xuan Do Long, Weishi Wang, Md. Rizwan Parvez, and Shafiq Joty. XCodeEval: An execution-based large scale multilingual multitask benchmark for code understanding, generation, translation and retrieval. In ACL, pages 6766-6805, Bangkok, Thailand, 2024. ACL.
  13. [Le et al., 2022] Hung Le, Yue Wang, Akhilesh Deepak Gotmare, Silvio Savarese, and Steven Chu Hong Hoi. CodeRL: Mastering code generation through pretrained models and deep reinforcement learning. In NeurIPS, pages 21314-21328, New Orleans, LA, USA, 2022. Cur- ran Associates Inc.
  14. [Liu et al., 2023] Fang Liu, Jia Li, and Li Zhang. Syntax and domain aware model for unsupervised program trans- lation. In ICSE, pages 755-767, Melbourne, VIC, Aus- tralia, 2023. IEEE.
  15. [Lu et al., 2021] Shuai Lu, Daya Guo, Shuo Ren, Junjie Huang, Alexey Svyatkovskiy, Ambrosio Blanco, Colin B. Clement, Dawn Drain, Daxin Jiang, Duyu Tang, et al. CodeXGLUE: A machine learning benchmark dataset for code understanding and generation. In NeurIPS, pages 1- 16, Virtual, 2021.
  16. [Curran Associates, Inc. Ma et al., 2025] Zeyao Ma, Xiaokang Zhang, Jing Zhang, Jifan Yu, Sijia Luo, and Jie Tang. Dynamic scaling of unit tests for code reward modeling. In ACL, Vienna, Austria, 2025. ACL.
  17. [Meng et al., 2024] Yu Meng, Mengzhou Xia, and Danqi Chen. SimPO: Simple preference optimization with a reference-free reward. In NeurIPS, pages 1-38, Vancou- ver, BC, Canada,, 2024.
  18. [Curran Associates Inc. Nguyen et al., 2014] Anh Tuan Nguyen, Tung Thanh Nguyen, and Tien N. Nguyen. Migrating code with sta- tistical machine translation. In ICSE Companion, pages 544-547, Hyderabad, India, 2014. ACM.
  19. [Ouyang et al., 2022] Long Ouyang, Jeff Wu, Xu Jiang, Diogo Almeida, Carroll L. Wainwright, Pamela Mishkin, Chong Zhang, Sandhini Agarwal, Katarina Slama, Alex Ray, et al. Training language models to follow instructions with human feedback. In NeurIPS, pages 27730-27744, New Orleans, LA, USA, 2022.
  20. Curran Associates Inc. [Pan et al., 2024] Rangeet Pan, Ali Reza Ibrahimzada, Rahul Krishna, Divya Sankar, Lambert Pouguem Wassi, Michele Merler, Boris Sobolev, Raju Pavuluri, Saurabh Sinha, and Reyhaneh Jabbarvand. Lost in translation: A study of bugs introduced by large language models while translat- ing code. In ICSE, pages 1-13, Lisbon, Portugal, 2024.
  21. Curran Associates Inc. [Park et al., 2024]
  22. Ryan Park, Rafael Rafailov, Stefano Er- mon, and Chelsea Finn. Disentangling length from quality in direct preference optimization. In ACL, pages 4998- 5017, Bangkok, Thailand, 2024. ACL.
  23. [Rafailov et al., 2023] Rafael Rafailov, Archit Sharma, Eric Mitchell, Christopher D. Manning, Stefano Ermon, and Chelsea Finn. Direct preference optimization: Your lan- guage model is secretly a reward model. In NeurIPS, volume 36, pages 53728-53741, New Orleans, LA, USA, 2023.
  24. [Curran Associates, Inc. Ren et al., 2020] Shuo Ren, Daya Guo, Shuai Lu, Long Zhou, Shujie Liu, Duyu Tang, Neel Sundaresan, Ming Zhou, Ambrosio Blanco, and Shuai Ma. CodeBLEU: a method for automatic evaluation of code synthesis. CoRR, 2009.10297:1-8, 2020.
  25. [Roziere et al., 2020] Baptiste Roziere, Marie-Anne Lachaux, Lowik Chanussot, and Guillaume Lample. Unsupervised translation of programming languages. In NeurIPS, pages 20601-20611, Vancouver, BC, Canada, 2020.
  26. Curran Associates Inc. [Roziere et al., 2022]
  27. Baptiste Roziere, Jie Zhang, Francois Charton, Mark Harman, Gabriel Synnaeve, and Guillaume Lample. Leveraging automated unit tests for unsupervised code translation. In ICLR, pages 1-20, Virtual, 2022. OpenReview.net.
  28. [Rozière et al., 2023] Baptiste Rozière, Jonas Gehring, Fabian Gloeckle, Sten Sootla, Itai Gat, Xiaoqing Ellen Tan, Yossi Adi, Jingyu Liu, Tal Remez, Jérémy Rapin, et al. Code Llama: Open foundation models for code. CoRR, 2308.12950:1-48, 2023.
  29. [Schulman et al., 2017] John Schulman, Filip Wolski, Pra- fulla Dhariwal, Alec Radford, and Oleg Klimov. Proximal policy optimization algorithms. CoRR, 1707.06347:1-12, 2017.
  30. [Shao et al., 2024] Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchuan Zhang, YK Li, Y Wu, et al. DeepSeekMath: Pushing the limits of mathematical reasoning in open lan- guage models. CoRR, 2402.03300:1-30, 2024.
  31. [Shojaee et al., 2023] Parshin Shojaee, Aneesh Jain, Sindhu Tipirneni, and Chandan K. Reddy. Execution-based code generation using deep reinforcement learning. Trans. Mach. Learn. Res., 2023:1-26, 2023.
  32. [Szafraniec et al., 2023] Marc Szafraniec, Baptiste Roziere, Hugh Leather Francois Charton, Patrick Labatut, and Gabriel Synnaeve. Code translation with compiler repre- sentations. In ICLR, pages 1-20, Kigali, Rwanda, 2023. OpenReview.net.
  33. [van den Oord et al., 2018] Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with con- trastive predictive coding. CoRR, 1807.03748:1-13, 2018.
  34. [Wang et al., 2021] Yue Wang, Weishi Wang, Shafiq Joty, and Steven C.H. Hoi. CodeT5: Identifier-aware unified pre-trained encoder-decoder models for code understand- ing and generation. In EMNLP, pages 8696-8708, Punta Cana, Dominican Republic, 2021. ACL.
  35. [Wang et al., 2024] Yanli Wang, Yanlin Wang, Suiquan Wang, Daya Guo, Jiachi Chen, John Grundy, Xilin Liu, Yuchi Ma, Mingzhi Mao, Hongyu Zhang, et al. Repo- TransBench: A real-world benchmark for repository-level code translation. CoRR, 2412.17744:1-23, 2024.
  36. [Yan et al., 2023] Weixiang Yan, Yuchen Tian, Yunzhe Li, Qian Chen, and Wen Wang. CodeTransOcean: A compre- hensive multilingual benchmark for code translation. In EMNLP, pages 5067-5089, Singapore, 2023. ACL.
  37. [Yan et al., 2024] Weixiang Yan, Haitian Liu, Yunkun Wang, Yunzhe Li, Qian Chen, Wen Wang, Tingyu Lin, Weishan Zhao, Li Zhu, Hari Sundaram, et al. CodeScope: An execution-based multilingual multitask multidimensional benchmark for evaluating LLMs on code understanding and generation. In ACL, pages 5511-5558, Bangkok, Thailand, 2024. ACL.
  38. [Yang et al., 2024] Zhen Yang, Fang Liu, Zhongxing Yu, Jacky Wai Keung, Jia Li, Shuo Liu, Yifan Hong, Xiaoxue Ma, Zhi Jin, and Ge Li. Exploring and unleashing the power of large language models in automated code trans- lation. Proc. ACM Softw. Eng., 1:1585-1608, 2024.
  39. [Zhang et al., 2025] Kechi Zhang, Ge Li, Yihong Dong, Jingjing Xu, Jun Zhang, Jing Su, Yongfei Liu, and Zhi Jin. CodeDPO: Aligning code models with self generated and verified source code. In ACL, Vienna, Austria, 2025. ACL.
  40. [Zheng et al., 2023] Qinkai Zheng, Xiao Xia, Xu Zou, Yux- iao Dong, Shan Wang, Yufei Xue, Lei Shen, Zihan Wang, Andi Wang, Yang Li, et al. CodeGeeX: A pre-trained model for code generation with multilingual benchmark- ing on HumanEval-X. In KDD, pages 5673-5684, Long Beach, CA, USA, 2023. ACM.
  41. [Zhou et al., 2023] Shuyan Zhou, Uri Alon, Sumit Agarwal, and Graham Neubig. CodeBERTScore: Evaluating code generation with pretrained models of code. In EMNLP, pages 13921-13937, Singapore, 2023. ACL.
  42. [Zhu et al., 2022a] Ming Zhu, Aneesh Jain, Karthik Suresh, Roshan Ravindran, Sindhu Tipirneni, and Chandan K. Reddy. XLCoST: A benchmark dataset for cross-lingual code intelligence. CoRR, 2206.08474:1-20, 2022.
  43. [Zhu et al., 2022b] Ming Zhu, Karthik Suresh, and Chan- dan K. Reddy. Multilingual code snippets training for program translation. In AAAI, volume 36, pages 11783- 11790, Virtual, 2022. AAAI.

References were extracted automatically from the PDF and may contain errors.

Welcome Future Conferences AI Journal Division IJCAI Proceedings About IJCAI IJCAI Awards