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

通过小型语言模型作为评判者改进代码生成

Improving Code Generation via Small Language Model-as-a-judge

Università della Svizzera italiana(瑞士意大利语大学)

Giuseppe Crupi, Rosalia Tufano, Gabriele Bavota

AI总结:

通过训练小型语言模型作为代码正确性评判者,改进代码生成性能,展现其在无需执行信息时优于现有方法,并以更低成本接近大规模模型表现。

摘要:

大型语言模型(LLMs)在自动化代码生成中展现了显著的能力。尽管在主流语言中表现良好,但它们在较少使用或领域特定语言上可能表现不佳,促使公司开发内部代码生成器。虽然开源模型可以用于此目的,但只有具有数十亿参数的LLM才能匹配商业工具的性能,这需要昂贵的训练和部署成本。最近的研究提出通过小型模型(SLMs)生成多个候选解决方案,并使用另一个SLM来选择最可能正确的解决方案。该领域最近的工作是Sun等人[29]提出的RankEF,这是一个经过训练以通过执行和非执行信息对代码解决方案进行排名的T5模型。然而,Sun等人并未评估T5排名器的分类准确性,即它多经常将正确的实现误判为错误或反之,这留下了关于LLM作为代码正确性评判者在其他任务(如自动化代码审查)中可靠性的问题。此外,他们的实验涉及相对旧的模型,使人们不清楚这种方法论在廉价训练具有与大规模LLM相当性能的代码生成器方面有多大帮助。我们提出了一项研究,以解决这些限制。我们训练了几种最先进的SLMs作为代码正确性评判者,并评估它们区分正确和错误实现的能力。我们显示,现代SLMs在不利用执行信息的情况下优于RankEF。当用作代码排名器时,它们比RankEF获得更高的性能提升,并且与比LLM大5-25倍的模型竞争性,但成本仅为一小部分。

英文摘要:

Large language models (LLMs) have shown remarkable capabilities in automated code generation. While effective for mainstream languages, they may underperform on less common or domain-specific languages, prompting companies to develop in-house code generators. While open-source models can be trained for this, only LLMs with tens of billions of parameters match the performance of commercial tools, demanding costly training and deployment. Recent work proposed supporting code generation with smaller models (SLMs) by generating multiple candidate solutions and using another SLM to select the most likely correct one. The most recent work in this area is the one by Sun et al. [29] presenting RankEF, a T5 model trained to rank code solutions using both execution-based and non-execution-based information. However, Sun et al. do not assess the T5 ranker's classification accuracy, that is, how often it misjudges correct implementations as incorrect or vice versa, leaving open questions about the reliability of LMs as code correctness judges for other tasks (e.g., automated code review). Moreover, their experiments involve relatively old models, making it unclear the extent to which such a methodology would still help companies in cheaply training their own code generators with performance comparable to those of massive LLMs. We present a study addressing these limitations. We train several state-of-the-art SLMs as code correctness judges and assess their ability to discriminate between correct and wrong implementations. We show that modern SLMs outperform RankEF, even without exploiting execution-based information. When used as code rankers, they achieve higher performance gains than RankEF and perform competitively with LLMs 5-25x larger, at a fraction of the cost.

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

↑