arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2312.01639cs.SE
收藏

论大语言模型在特定领域代码生成中的有效性

On the Effectiveness of Large Language Models in Domain-Specific Code Generation

Xiaodong Gu, Meng Chen, Yalan Lin, Yuhan Hu, Hongyu Zhang, Chengcheng Wan, Zhao Wei, Yong Xu, Juhong Wang

AI总结:

本文研究大语言模型在特定领域代码生成中的表现,发现其因领域库使用能力有限而性能欠佳,提出融入API知识的DomCoder方法(含三种策略),实验证明该方法可提升特定领域代码生成有效性。

摘要:

ChatGPT等大语言模型(LLMs)在代码生成方面展现出卓越能力。尽管取得显著成果,它们仍依赖海量训练数据获取广泛的开放域知识。此外,其评估围绕HumanEval等开放域基准展开,这些基准主要由编程竞赛题目构成。因此,难以全面刻画特定领域(如网络、游戏和数学)相关的复杂性与挑战。本文对LLMs在特定领域代码生成中的表现进行深入研究。结果表明,由于LLMs在利用特定领域库方面能力有限,其生成特定领域代码的性能欠佳。我们进一步观察到,将API知识作为提示词融入可增强LLMs生成更专业代码的能力。基于这些发现,我们进一步研究如何有效将API知识融入代码生成过程。我们实验了三种融入领域知识的策略,即外部知识查询器、思维链提示和思维链微调,并将这些策略称为名为DomCoder的新代码生成方法。实验结果显示,在特定设置下,DomCoder的所有策略均能提升特定领域代码生成的有效性。

英文摘要:

Large language models (LLMs) such as ChatGPT have shown remarkable capabilities in code generation. Despite significant achievements, they rely on enormous training data to acquire a broad spectrum of open-domain knowledge. Besides, their evaluation revolves around open-domain benchmarks like HumanEval, which primarily consist of programming contests. Therefore, it is hard to fully characterize the intricacies and challenges associated with particular domains (e.g., web, game, and math). In this paper, we conduct an in-depth study of the LLMs in domain-specific code generation. Our results demonstrate that LLMs exhibit sub-optimal performance in generating domain-specific code, due to their limited proficiency in utilizing domain-specific libraries. We further observe that incorporating API knowledge as prompts can empower LLMs to generate more professional code. Based on these findings, we further investigate how to effectively incorporate API knowledge into the code generation process. We experiment with three strategies for incorporating domain knowledge, namely, external knowledge inquirer, chain-of-thought prompting, and chain-of-thought fine-tuning. We refer to these strategies as a new code generation approach called DomCoder. Experimental results show that all strategies of DomCoder lead to improvement in the effectiveness of domain-specific code generation under certain settings.

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

↑