基于大语言模型的知识感知代码生成
Knowledge-Aware Code Generation with Large Language Models
AI总结:
针对大语言模型在陌生编程问题上解题能力下降的问题,研究构建了CodeF数据集与Python编程竞赛知识库,提出KareCoder知识感知代码生成方法,显著提升了新问题的Pass@1指标。
摘要:
大语言模型(LLMs)在基础编程问题上表现良好,但在处理需要运用多种算法与数据结构技能的复杂任务时,尤其是编程竞赛级别的问题,会面临诸多挑战。值得注意的是,ChatGPT在预训练阶段接触过的问题上表现出色,但面对全新问题时性能会出现下降。因此,提升LLMs解决陌生问题的能力已成为一项关键研究重点。LLMs的解题过程在一定程度上与人类程序员的解题方式相似:面对新的编程任务时,人类程序员会借助此前掌握的算法与数据结构知识进行任务规划和代码编写。尽管LLMs也学习过这类知识,但在面对具体的新问题时却难以有效应用。为解决这一问题,我们构建了一个全新的数据集CodeF,其中包含部分ChatGPT此前未接触过的编程问题。此外,我们针对Python编程竞赛问题打造了专属知识库,并提出了知识感知代码生成(Knowledge-Aware Code Generation,KareCoder)概念。KareCoder通过将提示词与知识库中的知识融入LLMs的代码生成推理过程,提升模型的理解能力与解题能力,尤其在Pass@1指标上表现突出。在CodeF和APPS数据集上的测试结果显示,KareCoder在处理LLMs此前未接触过的全新问题时表现优异。与ChatGPT直接生成的代码相比,KareCoder在CodeF的post2021-9数据集上的Pass@1指标实现了23.3%的相对提升。此外,在处理LLMs此前接触过的问题时,其表现也优于其他方法。
英文摘要:
Large Language Models (LLMs) perform well on basic programming problems. However, they encounter challenges when dealing with complex tasks involving the use of diverse algorithmic and data structure skills, particularly programming competition-level problems. Notably, ChatGPT exhibits proficient performance on problems it has encountered during its pre-training phase, but this performance deteriorates when faced with novel problems. Consequently, enhancing the ability of LLMs to address unfamiliar problems has emerged as a pivotal research focus. The problem-solving process of LLMs mirrors human programmers' approach to a certain extent. When confronted with new programming tasks, human programmers engage in task planning and code writing with the previously acquired knowledge about algorithms and data structures. Despite having learned such knowledge, LLMs struggle to effectively apply it when faced with specific new problems. To address this issue, we constructed a novel dataset, CodeF, which contains a portion of programming problems that ChatGPT has not previously encountered. Furthermore, we developed a Knowledge Library tailored for Python programming contest problems and introduced the concept of Knowledge-Aware Code Generation (KareCoder). KareCoder bolsters the models' understanding and problem-solving capabilities by integrating prompt and knowledge from the library into the LLMs' code generation reasoning process, especially on Pass@1 metrics. Upon testing on the CodeF and APPS datasets, KareCoder demonstrated outstanding performance in handling novel problems previously unencountered by LLMs. In contrast with the code directly generated by ChatGPT, KareCoder achieved a relative improvement of 23.3% on the Pass@1 metric on the CodeF post2021-9 dataset. Additionally, it performs well compared to other methods when dealing with problems that LLMs have previously encountered.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。