arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2402.02047cs.SEcs.LG
收藏

代码语言模型的校准与正确性

Calibration and Correctness of Language Models for Code

UC Davis(加利福尼亚大学戴维斯分校);Univ. of Stuttgart(斯图加特大学);Univ. of Houston(休斯顿大学);SRI(SRI国际(斯坦福研究所))

Claudio Spiess, David Gros, Kunal Suresh Pai, Michael Pradel, Md Rafiqul Islam Rabin, Amin Alipour, Susmit Jha, Prem Devanbu, Toufique Ahmed

AI总结:

本文针对代码生成模型的校准问题,提出评估框架并发现模型校准不佳,利用Platt缩放改进校准,以支持开发者理性决策。

摘要:

机器学习模型被广泛使用,但也常常出错。用户将受益于一个可靠的指示,以判断给定模型的给定输出是否应被信任,从而能够做出理性的决策,决定是否使用该输出。例如,输出可以与置信度度量相关联;如果该置信度度量与正确性可能性强相关,则该模型被认为是良好校准的。良好校准的置信度度量可以作为理性、渐进式决策的基础,决定在使用生成的代码时需要多少审查和关注。迄今为止,校准研究主要集中在非生成式(如分类)设置中,尤其是在软件工程领域。然而,生成的代码常常可能出错:面对生成的代码,开发者必须决定是直接使用、在经过不同强度的仔细审查后使用,还是丢弃模型生成的代码。因此,校准在生成式设置中至关重要。我们做出了多项贡献。我们开发了一个评估代码生成模型校准的框架。我们考虑了多种任务、正确性标准、数据集和方法,并发现总体而言,我们测试的生成式代码模型在开箱即用时校准不佳。然后,我们展示了如何使用标准方法(如Platt缩放)来改进校准。由于Platt缩放依赖于正确性数据的先验可用性,我们评估了Platt缩放在软件工程中的适用性和泛化性,讨论了其具有良好实际应用潜力的场景,以及不适合的场景。我们的贡献将导致在当前使用语言模型生成的代码时做出更好的校准决策,并为未来研究提供一个框架,以进一步改进软件工程中生成式模型的校准方法。

英文摘要:

Machine learning models are widely used, but can also often be wrong. Users would benefit from a reliable indication of whether a given output from a given model should be trusted, so a rational decision can be made whether to use the output or not. For example, outputs can be associated with a confidence measure; if this confidence measure is strongly associated with likelihood of correctness, then the model is said to be well-calibrated. A well-calibrated confidence measure can serve as a basis for rational, graduated decision-making on how much review and care is needed when using generated code. Calibration has so far been studied in mostly non-generative (e.g. classification) settings, especially in software engineering. However, generated code can quite often be wrong: Given generated code, developers must decide whether to use directly, use after varying intensity of careful review, or discard model-generated code. Thus, calibration is vital in generative settings. We make several contributions. We develop a framework for evaluating the calibration of code-generating models. We consider several tasks, correctness criteria, datasets, and approaches, and find that, by and large, generative code models we test are not well-calibrated out of the box. We then show how calibration can be improved using standard methods, such as Platt scaling. Since Platt scaling relies on the prior availability of correctness data, we evaluate the applicability and generalizability of Platt scaling in software engineering, discuss settings where it has good potential for practical use, and settings where it does not. Our contributions will lead to better-calibrated decision-making in the current use of code generated by language models, and offers a framework for future research to further improve calibration methods for generative models in software engineering.

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

↑