Function-to-Style Guidance of LLMs for Code Translation

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Zhang, Longhui, Wang, Bin, Wang, Jiahao, Zhao, Xiaofeng, Zhang, Min, Yang, Hao, Zhang, Meishan, Li, Yu, Li, Jing, Yu, Jun
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866915390720835584
author Zhang, Longhui
Wang, Bin
Wang, Jiahao
Zhao, Xiaofeng
Zhang, Min
Yang, Hao
Zhang, Meishan
Li, Yu
Li, Jing
Yu, Jun
Zhang, Min
author_facet Zhang, Longhui
Wang, Bin
Wang, Jiahao
Zhao, Xiaofeng
Zhang, Min
Yang, Hao
Zhang, Meishan
Li, Yu
Li, Jing
Yu, Jun
Zhang, Min
contents Large language models (LLMs) have made significant strides in code translation tasks. However, ensuring both the correctness and readability of translated code remains a challenge, limiting their effective adoption in real-world software development. In this work, we propose F2STrans, a function-to-style guiding paradigm designed to progressively improve the performance of LLMs in code translation. Our approach comprises two key stages: (1) Functional learning, which optimizes translation correctness using high-quality source-target code pairs mined from online programming platforms, and (2) Style learning, which improves translation readability by incorporating both positive and negative style examples. Additionally, we introduce a novel code translation benchmark that includes up-to-date source code, extensive test cases, and manually annotated ground-truth translations, enabling comprehensive functional and stylistic evaluations. Experiments on both our new benchmark and existing datasets demonstrate that our approach significantly improves code translation performance. Notably, our approach enables Qwen-1.5B to outperform prompt-enhanced Qwen-32B and GPT-4 on average across 20 diverse code translation scenarios.
format Preprint
id arxiv_https___arxiv_org_abs_2507_11083
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Function-to-Style Guidance of LLMs for Code Translation
Zhang, Longhui
Wang, Bin
Wang, Jiahao
Zhao, Xiaofeng
Zhang, Min
Yang, Hao
Zhang, Meishan
Li, Yu
Li, Jing
Yu, Jun
Zhang, Min
Artificial Intelligence
Software Engineering
Large language models (LLMs) have made significant strides in code translation tasks. However, ensuring both the correctness and readability of translated code remains a challenge, limiting their effective adoption in real-world software development. In this work, we propose F2STrans, a function-to-style guiding paradigm designed to progressively improve the performance of LLMs in code translation. Our approach comprises two key stages: (1) Functional learning, which optimizes translation correctness using high-quality source-target code pairs mined from online programming platforms, and (2) Style learning, which improves translation readability by incorporating both positive and negative style examples. Additionally, we introduce a novel code translation benchmark that includes up-to-date source code, extensive test cases, and manually annotated ground-truth translations, enabling comprehensive functional and stylistic evaluations. Experiments on both our new benchmark and existing datasets demonstrate that our approach significantly improves code translation performance. Notably, our approach enables Qwen-1.5B to outperform prompt-enhanced Qwen-32B and GPT-4 on average across 20 diverse code translation scenarios.
title Function-to-Style Guidance of LLMs for Code Translation
topic Artificial Intelligence
Software Engineering
url https://arxiv.org/abs/2507.11083