Skip to main content
QUICK REVIEW

[论文解读] ICE-Score: Instructing Large Language Models to Evaluate Code

Terry Yue Zhuo|arXiv (Cornell University)|Apr 27, 2023
Topic Modeling被引用 7
一句话总结

ICE-Score 提出了一种无需参考代码、基于大语言模型(LLM)的代码生成评估指标,利用指令微调的大语言模型实现多维度代码评估,在无需测试套件或参考代码的情况下,对四种编程语言的生成代码实现了与人类偏好及功能正确性高度相关的评估。

ABSTRACT

Recent advancements in the field of natural language generation have facilitated the use of large language models to assess the quality of generated text. Although these models have shown promising results in tasks such as machine translation and summarization, their applicability in code intelligence tasks remains limited without human involvement. The complexity of programming concepts required for such tasks makes it difficult to develop evaluation metrics that align with human judgment. Token-matching-based metrics, such as BLEU, have demonstrated weak correlations with human practitioners in code intelligence tasks. Moreover, utilizing human-written test suites to evaluate functional correctness can be challenging in domains with low resources. To overcome these obstacles, we propose exttt{ICE-Score}, a new evaluation metric via instructing large language models (LLMs) for code assessments. Our metric addresses the limitations of existing approaches by achieving superior correlations with functional correctness and human preferences, without the need for test oracles or references. We evaluate the efficacy of our metric on two different aspects ( extit{human preference} and extit{execution success}) and four programming languages. Our results demonstrate that our metric surpasses state-of-the-art metrics for code generation, delivering high levels of accuracy and consistency across various programming languages and tasks. We also make our evaluation metric and datasets available to the public\footnote{\url{https://github.com/terryyz/ice-score}}, encouraging further research in evaluating code intelligence tasks.

研究动机与目标

  • 解决传统基于标记匹配的评估指标(如 BLEU 和 ROUGE)在代码评估中与人类判断相关性较弱的问题。
  • 克服现有评估方法对人工编写的测试套件或参考代码的依赖,这些方法在低资源场景下成本高且不切实际。
  • 开发一种无需参考代码的评估指标,使其在代码智能任务中与人类偏好和功能正确性保持一致。
  • 在无需执行代码或依赖外部预言机的情况下,实现在多种编程语言上的稳定且准确的代码评估。
  • 提供一种可扩展、自动化且与人类判断对齐的代码生成评估框架,充分利用指令微调大语言模型的语义理解能力。

提出的方法

  • 利用指令微调的大语言模型(LLM)基于预定义的多维评估标准对代码片段进行评估。
  • 设计一种基于提示的评估框架,引导 LLM 通过结构化评估步骤,无需指令生成或加权评分函数。
  • 根据人类判断标准定义一组评估维度,如正确性、可读性和语义一致性。
  • 使用在自然语言和代码数据上预训练的 LLM 进行训练和部署,以实现对编程语法和语义的稳健理解。
  • 在示例级别和语料库级别应用该指标,以评估单个代码片段和整体模型输出。
  • 通过完全依赖 LLM 通过自然语言指令和内部知识判断代码质量,确保评估过程完全无参考。
Figure 1: An illustration of ICE-Score . On the left-hand side, we input the task problems and corresponding generated code snippets. On the right-hand side, ICE-Score outputs the corresponding assessments.
Figure 1: An illustration of ICE-Score . On the left-hand side, we input the task problems and corresponding generated code snippets. On the right-hand side, ICE-Score outputs the corresponding assessments.

实验结果

研究问题

  • RQ1基于 LLM 的评估指标是否能在无需参考代码的情况下,与人类偏好实现高度相关?
  • RQ2指令微调的大语言模型在不执行代码或使用测试套件的情况下,能在多大程度上评估生成代码的功能正确性?
  • RQ3与最先进的指标(如 CodeBERTScore 和 G-EVAL)相比,所提出的 ICE-Score 指标在与人类判断和功能正确性的一致性方面表现如何?
  • RQ4ICE-Score 是否能在多种编程语言(包括 Java、Python、C、C++ 和 JavaScript)上实现泛化?
  • RQ5在低资源或复杂代码智能任务中,无参考、基于 LLM 的评估框架能否保持一致性和准确性?

主要发现

  • 与 G-EVAL 和 CodeBERTScore 等现有指标相比,ICE-Score 在无参考设置下与人类偏好的相关性更优。
  • 该指标在四种编程语言中均表现出与功能正确性的强相关性,表明其在不同语法和语义下的强大泛化能力。
  • ICE-Score 显著优于传统指标(如 BLEU 和 ROUGE),后者因依赖标记级匹配而与人类判断对齐性较弱。
  • 该评估框架无需测试套件或参考代码,显著降低了低资源场景下代码评估的成本和复杂性。
  • 该方法在示例级别和语料库级别均保持高度一致性和准确性,证实其在大规模模型评估中的可靠性。
  • 作者已公开发布该指标及相关数据集,以支持自动化代码评估的进一步研究,促进可复现性与社区发展。
Figure 2: Example inputs and outputs with (a) ICE-Score , (b) ICE-Score with Zero-Shot Chain-of-Thought. With the step-by-step evaluation, the output assessment is more aligned with human preference.
Figure 2: Example inputs and outputs with (a) ICE-Score , (b) ICE-Score with Zero-Shot Chain-of-Thought. With the step-by-step evaluation, the output assessment is more aligned with human preference.

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。