TransAgent: Enhancing LLM-Based Code Translation via Fine-Grained Execution Alignment

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Yuan, Zhiqiang, Chen, Weitong, Wang, Hanlin, Peng, Xin, Chen, Zhenpeng, Lou, Yiling
Formato: Preprint
Publicado: 2024
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866911572510638080
author Yuan, Zhiqiang
Chen, Weitong
Wang, Hanlin
Peng, Xin
Chen, Zhenpeng
Lou, Yiling
author_facet Yuan, Zhiqiang
Chen, Weitong
Wang, Hanlin
Peng, Xin
Chen, Zhenpeng
Lou, Yiling
contents Code translation transforms code between programming languages while preserving functionality, which is critical in software development and maintenance. While traditional learning-based code translation methods have limited effectiveness due to the lack of sufficient parallel training data, Large Language Models (LLMs) have recently advanced this field with their strong code generation and comprehension capabilities. However, code translated by LLMs still suffers from diverse quality issues, such as syntax and semantic errors. In this work, we propose TransAGENT, a novel multi-agent system that eliminates the errors during LLM-based code translation. The main insight of TransAGENT is to localize error-prone code blocks via fine-grained execution alignment between source and target code. We evaluate TransAGENT on a newly constructed benchmark of recent programming tasks to mitigate data leakage. TransAGENT outperforms the latest UniTrans by up to 33.3% in translation accuracy and achieves an average improvement of 56.7% over Agentless in program repair performance. We also conduct an ablation study and evaluate TransAGENT across different LLMs, demonstrating its effectiveness and strong generalizability.
format Preprint
id arxiv_https___arxiv_org_abs_2409_19894
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle TransAgent: Enhancing LLM-Based Code Translation via Fine-Grained Execution Alignment
Yuan, Zhiqiang
Chen, Weitong
Wang, Hanlin
Peng, Xin
Chen, Zhenpeng
Lou, Yiling
Software Engineering
Artificial Intelligence
Code translation transforms code between programming languages while preserving functionality, which is critical in software development and maintenance. While traditional learning-based code translation methods have limited effectiveness due to the lack of sufficient parallel training data, Large Language Models (LLMs) have recently advanced this field with their strong code generation and comprehension capabilities. However, code translated by LLMs still suffers from diverse quality issues, such as syntax and semantic errors. In this work, we propose TransAGENT, a novel multi-agent system that eliminates the errors during LLM-based code translation. The main insight of TransAGENT is to localize error-prone code blocks via fine-grained execution alignment between source and target code. We evaluate TransAGENT on a newly constructed benchmark of recent programming tasks to mitigate data leakage. TransAGENT outperforms the latest UniTrans by up to 33.3% in translation accuracy and achieves an average improvement of 56.7% over Agentless in program repair performance. We also conduct an ablation study and evaluate TransAGENT across different LLMs, demonstrating its effectiveness and strong generalizability.
title TransAgent: Enhancing LLM-Based Code Translation via Fine-Grained Execution Alignment
topic Software Engineering
Artificial Intelligence
url https://arxiv.org/abs/2409.19894