arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2506.11006cs.SE
收藏

爱立信中使用程序分析增强的微调大语言模型生成测试代码

Test code generation at Ericsson using Program Analysis Augmented Fine Tuned LLMs

Sai Krishna, Balvinder Singh, Sujoy Roychowdhury, Giriprasad Sridhara, Sourav Mazumdar, Magnus Sandelin, Dimitris Rentas, Maciej Nalepa, Karol Sawicki, Jakub Gajda

AI总结:

针对直接用大语言模型生成测试代码时臆测不存在函数的问题,爱立信结合RAG、静态程序分析提示工程与定制模板微调8x7b MoE模型,F1值较基础模型提升8%,效果媲美更大的8x22b MoE模型。

摘要:

我们介绍了爱立信公司利用大语言模型(LLM)生成测试代码的研究。模型输入为自然语言(英文)描述的测试步骤,输出为完成该测试步骤的Java代码。我们指出,直接使用简单提示词的方法并不足够,会导致LLM臆测代码仓库中不存在的函数与签名。随后我们展示了如何通过结合检索增强生成(RAG)与提示工程来缓解这一问题:该提示工程方法借助静态程序分析,为简单提示词补充了额外的上下文信息。我们进一步介绍了通过微调底层LLM获得的性能提升,微调基于定制设计的提示模板开展,模板中包含前置依赖类、它们的公共方法,以及两个从RAG获取的示例输出。我们的实验结果证实,基于生成代码中所用方法计算的传统F1值指标衡量,微调后的模型提升了与开发者原始编写测试代码的一致性或契合度。对8x7b混合专家(MoE)模型进行微调后,其性能较基础模型平均提升8%,且得分与规模大得多的8x22b MoE模型相当。

英文摘要:

We describe test code generation using Large Language Models (LLMs) in Ericsson. Our input is a test step in natural language (English) and our output is code (Java) which accomplishes the test step. We describe how straight forward prompting does not suffice and results in LLM assuming functions and signatures which are not present in the code repository. We then show how we alleviate the problem by a combination of Retrieval Augmented Generation (RAG) along with prompt engineering that expanded the simple prompt with additional contextual information using static program analysis. We then describe further improvements that we obtained by fine-tuning the underlying LLM. The fine tuning is done based on a custom designed prompt template which has pre-dependent classes, their public methods as well two exemplar outputs obtained from RAG. Our results establish that our fine tuned models help improve the correspondence or conformity with the original developer written test code as measured by the traditional metrics of F1-score based on the methods used in the generated code. Fine tuning of a 8x7b Mixture of Experts (MoE) model leads to an average improvement of 8\% over the base model and is comparable to the scores on a much larger 8x22b MoE model.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑