Evolving Triple Knowledge-Augmented LLMs for Code Translation in Repository Context

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Ou, Guangsheng, Liu, Mingwei, Chen, Yuxuan, Du, Xueying, Wang, Shengbo, Zhang, Zekai, Peng, Xin, Zheng, Zibin
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866911281701715968
author Ou, Guangsheng
Liu, Mingwei
Chen, Yuxuan
Du, Xueying
Wang, Shengbo
Zhang, Zekai
Peng, Xin
Zheng, Zibin
author_facet Ou, Guangsheng
Liu, Mingwei
Chen, Yuxuan
Du, Xueying
Wang, Shengbo
Zhang, Zekai
Peng, Xin
Zheng, Zibin
contents Large language models (LLMs) have behaved well in function-level code translation without repository-level context. However, the performance of LLMs in repository-level context code translation remains suboptimal due to complex dependencies and context, hindering their adoption in industrial settings. In this work, we propose a novel LLM-based code translation technique K-Trans, which leverages triple knowledge augmentation to enhance LLM's translation quality under repository context in real-world software development. First, K-Trans constructs a evolving translation knowledge base by extracting relevant information from target-language codebases, the repository being translated, and prior translation results. Second, for each function to be translated, K-Trans retrieves relevant triple knowledge, including target-language code samples, dependency usage examples, and successful translation function pairs, serving as references to enhance LLM for translation. Third, K-Trans constructs a knowledge-augmented translation prompt using the retrieved triple knowledge and employs LLMs to generate the translated code while preserving repository context. It further leverages LLMs for self-debugging, enhancing translation correctness. Lastly, K-Trans continuously evolves the translation knowledge base. The experiments show that K-Trans substantially outperforms the baseline adapted from previous work by 19.4%/40.2% relative improvement in pass@1 and 0.138 in CodeBLEU. It is important to note that the results also demonstrate that each knowledge significantly contributes to K-Trans's effectiveness in handling repository-level context code translation, with dependency usage examples making the most notable contribution. Moreover, as the self-evolution process progresses, the knowledge base continuously enhances the LLM's performance across various aspects of the repository-level code translation.
format Preprint
id arxiv_https___arxiv_org_abs_2503_18305
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Evolving Triple Knowledge-Augmented LLMs for Code Translation in Repository Context
Ou, Guangsheng
Liu, Mingwei
Chen, Yuxuan
Du, Xueying
Wang, Shengbo
Zhang, Zekai
Peng, Xin
Zheng, Zibin
Software Engineering
Large language models (LLMs) have behaved well in function-level code translation without repository-level context. However, the performance of LLMs in repository-level context code translation remains suboptimal due to complex dependencies and context, hindering their adoption in industrial settings. In this work, we propose a novel LLM-based code translation technique K-Trans, which leverages triple knowledge augmentation to enhance LLM's translation quality under repository context in real-world software development. First, K-Trans constructs a evolving translation knowledge base by extracting relevant information from target-language codebases, the repository being translated, and prior translation results. Second, for each function to be translated, K-Trans retrieves relevant triple knowledge, including target-language code samples, dependency usage examples, and successful translation function pairs, serving as references to enhance LLM for translation. Third, K-Trans constructs a knowledge-augmented translation prompt using the retrieved triple knowledge and employs LLMs to generate the translated code while preserving repository context. It further leverages LLMs for self-debugging, enhancing translation correctness. Lastly, K-Trans continuously evolves the translation knowledge base. The experiments show that K-Trans substantially outperforms the baseline adapted from previous work by 19.4%/40.2% relative improvement in pass@1 and 0.138 in CodeBLEU. It is important to note that the results also demonstrate that each knowledge significantly contributes to K-Trans's effectiveness in handling repository-level context code translation, with dependency usage examples making the most notable contribution. Moreover, as the self-evolution process progresses, the knowledge base continuously enhances the LLM's performance across various aspects of the repository-level code translation.
title Evolving Triple Knowledge-Augmented LLMs for Code Translation in Repository Context
topic Software Engineering
url https://arxiv.org/abs/2503.18305