The advent of large language models (LLMs) has significantly advanced the field of code translation, enabling automated translation between programming languages. However, these models often struggle with complex translation tasks due to inadequate contextual understanding. This paper introduces a novel approach that enhances code translation through Few-Shot Learning, augmented with retrieval-based techniques. By leveraging a repository of existing code translations, we dynamically retrieve the most relevant examples to guide the model in translating new code segments. Our method, based on Retrieval-Augmented Generation (RAG), substantially improves translation quality by providing contextual examples from which the model can learn in real-time. We selected RAG over traditional fine-tuning methods due to its ability to utilize existing codebases or a locally stored corpus of code, which allows for dynamic adaptation to diverse translation tasks without extensive retraining. Extensive experiments on diverse datasets with open LLM models such as Starcoder, Llama3-70B Instruct, CodeLlama-34B Instruct, Granite-34B Code Instruct, and Mixtral-8x22B, as well as commercial LLM models like GPT-3.5 Turbo and GPT-4o, demonstrate our approach's superiority over traditional zero-shot methods, especially in translating between Fortran and CPP. We also explored varying numbers of shots i.e. examples provided during inference, specifically 1, 2, and 3 shots and different embedding models for RAG, including Nomic-Embed, Starencoder, and CodeBERT, to assess the robustness and effectiveness of our approach.
LEGO-Compiler: Enhancing Neural Compilation Through Translation Composability
SKLP, Institute of Computing Technology, CAS University of Chinese Academy of Sciences, Beijing, China(SKLP,计算技术研究所,中国科学院大学,北京,中国);University of Leeds, UK(利兹大学,英国);Zhongguancun Laboratory, Beijing, China(中关村实验室,北京,中国)
ViDove: A Translation Agent System with Multimodal Context and Memory-Augmented Reasoning
Pigeon AI;Carnegie Mellon University(卡内基梅隆大学);Fudan University(复旦大学);University of California San Diego(加利福尼亚大学圣地亚哥分校);University of Toronto(多伦多大学);University of California Irvine(加利福尼亚大学尔湾分校);University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);Institute of Science Tokyo(东京科学研究所);Hong Kong University of Science and Technology(香港科技大学)
ExpertAgent: Enhancing Personalized Education through Dynamic Planning and Retrieval-Augmented Long-Chain Reasoning
Department of Computer Science(计算机科学系);San Francisco State University(旧金山州立大学);Department of Mechanical & Industrial Engineering(机械与工业工程系);Louisiana State University(路易斯安那州立大学)
A Query-Aware Multi-Path Knowledge Graph Fusion Approach for Enhancing Retrieval-Augmented Generation in Large Language Models
School of Computer and Communication Engineering, University of Science and Technology Beijing(计算机与通信工程学院,北京科技大学);Blekinge Institute of Technology(布莱金厄学院)
Enhancing Speech-to-Speech Dialogue Modeling with End-to-End Retrieval-Augmented Generation
MoE Key Lab of Artificial Intelligence(人工智能增强实验室);Jiangsu Key Lab of Language Computing(江苏语言计算重点实验室);X-LANCE Lab(X-LANCE实验室);School of Computer Science, Shanghai Jiao Tong University(上海交通大学计算机科学学院);Shanghai Innovation Institute(上海创新研究院);Shanghai Aviation Electric Co., Ltd(上海航空电器有限公司)
RAG-Star: Enhancing Deliberative Reasoning with Retrieval Augmented Verification and Refinement
Gaoling School of Artificial Intelligence, Renmin University of China(中国人民大学高瓴人工智能学院);Wuhan University of Science and Technology(武汉科技大学);National University of Singapore(新加坡国立大学);Northeastern University at Qinhuangdao(东北大学秦皇岛分校);BOSS Zhipin(BOSS直聘)
Enhancing textual textbook question answering with large language models and retrieval augmented generation
Faculty of Computing and Information Technology, King Abdulaziz University(阿卜杜勒阿齐兹国王大学计算与信息技术学院);College of Computer and Information Science, Imam Mohammad Ibn Saud Islamic University (IMSIU)(伊玛目穆罕默德·本·沙特伊斯兰大学计算机与信息科学学院);School of Computing, Macquarie University(麦考瑞大学计算学院)
Locate-and-Focus: Enhancing Terminology Translation in Speech Language Models
Department of Digital Media Technology, Xiamen University(厦门大学数字媒体技术系);Tongyi Lab(通义实验室);Soochow University(苏州大学);Key Laboratory of Digital Protection and Intelligent Processing of Intangible Cultural Heritage of Fujian and Taiwan (Xiamen University), Ministry of Culture and Tourism, China(福建省和台湾非物质文化遗产数字化保护与智能处理重点实验室(厦门大学),中华人民共和国文化和旅游部,中国)
Neural Machine Translation with Contrastive Translation Memories
Peking University(北京大学);Tencent AI Lab(腾讯人工智能实验室);Shandong University(山东大学);Beijing Institute of General Artificial Intelligence(北京通用人工智能研究院);Renmin University of China(中国人民大学)
Enhancing Vulnerability Reports with Automated and Augmented Description Summarization
Department of Computer Science at the University of Central Florida(佛罗里达中央大学计算机科学系);Department of Computer Science at Northeastern Illinois University(北伊利诺伊大学计算机科学系);Department of Computer Science at Qatar University(卡塔尔大学计算机科学系);Ewha Womans University(成均馆大学)