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

自解释关键词增强大语言模型的代码生成能力

Self-Explained Keywords Empower Large Language Models for Code Generation

Zhejiang University(浙江大学)

Lishui Fan, Mouxiang Chen, Zhongxin Liu

AI总结:

本文提出自解释关键词技术SEK,通过让LLM提取并解释问题描述中的关键术语并按频率排序,显著提升了多个LLMs在HumanEval、MBPP和APPS等基准上的代码生成准确率。

摘要:

大语言模型(LLMs)在代码生成方面取得了令人瞩目的性能。然而,由于LLMs训练数据的长尾分布,低频术语在训练过程中通常代表性不足。因此,LLMs在代码生成过程中经常误解或忽略与问题相关的低频关键词,从而影响生成代码的准确性。为解决这一问题,我们提出了一种名为SEK(Self-Explained Keywords,自解释关键词)的新技术,该技术通过利用LLM自身提取并解释问题描述中的关键术语,并根据频率对其进行排序,从而增强LLM的代码生成能力。在三个基准(即HumanEval(+)、MBPP(+)和APPS)上使用五个代表性LLMs进行的综合实验表明,SEK能够显著提升LLMs的代码生成性能,带来可观且一致的增益。例如,SEK将DeepSeek-Coder-V2-Instruct在HumanEval基准上的Pass@1从85.4%提升至93.3%。进一步分析证实,SEK使LLMs能够将注意力从低频关键词转移到其对应的高频同义词上。

英文摘要:

Large language models (LLMs) have achieved impressive performance in code generation. However, due to the long-tail distribution of LLMs' training data, low-frequency terms are typically underrepresented in the training process. Consequently, LLMs often misunderstand or overlook problem-specific, low-frequency keywords during code generation, compromising the accuracy of the generated code. To address this, we propose a novel technique named SEK(\textbf{S}elf-\textbf{E}xplained \textbf{K}eywords), which empowers an LLM for better code generation by extracting and explaining the key terms in the problem description with the LLM itself and ranking them based on frequency. Comprehensive experiments across three benchmarks, i.e., HumanEval(+), MBPP(+), and APPS, with five representative LLMs, show that SEK can significantly improve LLMs in code generation, yielding substantial and consistent gains. For instance, SEK improves the Pass@1 of DeepSeek-Coder-V2-Instruct from 85.4\% to 93.3\% on the Humaneval benchmark. Further analysis confirms that SEK enables the LLMs to shift their attention from low-frequency keywords to their corresponding high-frequency counterparts.

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

↑