Enhancing the ability of LLMs for spaceborne equipment code generation via retrieval-augmented generation and contrastive learning

IF 3.1 2区 计算机科学 Q3 COMPUTER SCIENCE, SOFTWARE ENGINEERING
Rui He, Liang Zhang, Liangqing Lyu, Changbin Xue
{"title":"Enhancing the ability of LLMs for spaceborne equipment code generation via retrieval-augmented generation and contrastive learning","authors":"Rui He,&nbsp;Liang Zhang,&nbsp;Liangqing Lyu,&nbsp;Changbin Xue","doi":"10.1007/s10515-025-00545-1","DOIUrl":null,"url":null,"abstract":"<div><p>In the code generation field, Large Language Models (LLMs) pre-trained on numerous open-source code fragments show powerful reasoning abilities and remarkable downstream performance. They assist code generation by combining retrieval techniques like retrieving relevant code fragments as templates or using retrieval results to supplement natural language descriptions and get code examples. However, in domains like aerospace equipment, existing code generation technologies perform suboptimally. Different aerospace equipment has different functions and significant data processing and loading differences. There is a lack of effective retrieval methods to provide semantically similar code contexts for LLMs, hindering code generation from meeting complex task requirements. To address this, we propose CodeCLARE, a retrieval-augmented code generation framework. It first fine-tunes UniXcoder via contrastive learning and uses it as a semantic encoder for code fragment retrieval. Then, the NL2Code search strategy is adopted with program requirements as queries. In the final stage of the code generation process, through a “Few-Shots Selection” mechanism, the prompt templates effectively integrate both the retrieved code examples and the specific requirement information, enabling the successful generation of highly accurate C++ code through the advanced capabilities of LLMs. Experimental results show that our approach significantly improves code quality compared to traditional ones and provides an effective solution for spacecraft control code generation.</p></div>","PeriodicalId":55414,"journal":{"name":"Automated Software Engineering","volume":"33 1","pages":""},"PeriodicalIF":3.1000,"publicationDate":"2025-08-29","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Automated Software Engineering","FirstCategoryId":"94","ListUrlMain":"https://link.springer.com/article/10.1007/s10515-025-00545-1","RegionNum":2,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0

Abstract

In the code generation field, Large Language Models (LLMs) pre-trained on numerous open-source code fragments show powerful reasoning abilities and remarkable downstream performance. They assist code generation by combining retrieval techniques like retrieving relevant code fragments as templates or using retrieval results to supplement natural language descriptions and get code examples. However, in domains like aerospace equipment, existing code generation technologies perform suboptimally. Different aerospace equipment has different functions and significant data processing and loading differences. There is a lack of effective retrieval methods to provide semantically similar code contexts for LLMs, hindering code generation from meeting complex task requirements. To address this, we propose CodeCLARE, a retrieval-augmented code generation framework. It first fine-tunes UniXcoder via contrastive learning and uses it as a semantic encoder for code fragment retrieval. Then, the NL2Code search strategy is adopted with program requirements as queries. In the final stage of the code generation process, through a “Few-Shots Selection” mechanism, the prompt templates effectively integrate both the retrieved code examples and the specific requirement information, enabling the successful generation of highly accurate C++ code through the advanced capabilities of LLMs. Experimental results show that our approach significantly improves code quality compared to traditional ones and provides an effective solution for spacecraft control code generation.

通过检索增强生成和对比学习,增强了llm对星载设备代码生成的能力
在代码生成领域,对大量开源代码片段进行预训练的大型语言模型(Large Language Models, llm)显示出强大的推理能力和显著的下游性能。它们通过结合检索技术来辅助代码生成,比如检索相关的代码片段作为模板,或者使用检索结果来补充自然语言描述并获得代码示例。然而,在像航空航天设备这样的领域,现有的代码生成技术的性能不是最优的。不同的航天设备具有不同的功能和显著的数据处理和加载差异。缺乏有效的检索方法来为llm提供语义相似的代码上下文,阻碍了代码生成满足复杂任务需求。为了解决这个问题,我们提出了CodeCLARE,一个检索增强的代码生成框架。它首先通过对比学习对UniXcoder进行微调,并将其用作代码片段检索的语义编码器。然后,采用NL2Code搜索策略,将程序需求作为查询。在代码生成过程的最后阶段,通过“Few-Shots Selection”机制,提示模板有效地整合了检索到的代码示例和特定的需求信息,使llm的高级功能能够成功生成高精度的c++代码。实验结果表明,该方法显著提高了编码质量,为航天器控制码生成提供了有效的解决方案。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
Automated Software Engineering
Automated Software Engineering 工程技术-计算机:软件工程
CiteScore
4.80
自引率
11.80%
发文量
51
审稿时长
>12 weeks
期刊介绍: This journal details research, tutorial papers, survey and accounts of significant industrial experience in the foundations, techniques, tools and applications of automated software engineering technology. This includes the study of techniques for constructing, understanding, adapting, and modeling software artifacts and processes. Coverage in Automated Software Engineering examines both automatic systems and collaborative systems as well as computational models of human software engineering activities. In addition, it presents knowledge representations and artificial intelligence techniques applicable to automated software engineering, and formal techniques that support or provide theoretical foundations. The journal also includes reviews of books, software, conferences and workshops.
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信