测试大模型预测代码运行时异常的能力,发现表现普遍较低。
ThrowBench: Benchmarking LLMs by Predicting Runtime Exceptions
- 构建包含2400个带错代码的跨语言基准,要求模型判断是否抛出异常。
- 六款主流代码大模型在异常预测上F1得分仅19%至38%。
- 基于实际执行结果标注,避免训练数据泄露问题,适合评估模型鲁棒性。
现代大型语言模型在代码理解与生成方面表现出色,但现有评测基准(如HumanEval)主要聚焦自然语言到代码的合成任务,忽视了对代码运行时行为的理解能力。此外,存在训练数据泄露的风险。本文提出ThrowBench,一个包含超过2,400个由用户编写、涉及四种编程语言的短程序的基准,多数程序因缺陷会在运行时抛出异常。要求大模型预测程序是否会抛出异常及具体类型。在六种先进代码大模型上评估显示,其F1分数仅为19%至38%,表现有限。由于答案通过实际程序执行确定,可有效避免数据泄露问题。本研究有助于更全面评估代码大模型能力,并识别当前模型在异常理解方面的薄弱环节。相关数据集和结果已公开发布。
原文摘要 · Abstract (English)
Modern Large Language Models (LLMs) have shown astounding capabilities of code understanding and synthesis. In order to assess such capabilities, several benchmarks have been devised (e.g., HumanEval). However, most benchmarks focus on code synthesis from natural language instructions. Hence, such benchmarks do not test for other forms of code understanding. Moreover, there have been concerns about contamination and leakage. That is, benchmark problems (or closely related problems) may appear in training set, strongly biasing benchmark results. In this work we investigate whether large language models can correctly predict runtime program behavior. To this end, we introduce ThrowBench, a benchmark consisting of over 2,400 short user-written programs written in four different programming languages. The majority of these programs throw an exception during runtime (due to a bug). LLMs are asked to predict whether a presented program throws an exception and, if so, which one. Evaluating our benchmark on six state-of-the-art code LLMs we see modest performance ranging from 19 to 38% (F1 score). Benchmarking a wider set of code capabilities could improve the assessment of code LLMs and help identify weak points in current models. Moreover, as ground-truth answers have been determined through program execution, leakage is not a concern. We release ThrowBench as well as all of our results together with this work.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。