TypyBench:评估大语言模型对无类型Python仓库的类型推断能力
TypyBench: Evaluating LLM Type Inference for Untyped Python Repositories
AI总结:
本研究推出评估大语言模型Python仓库类型推断能力的基准TypyBench,含TypeSim、TypeCheck两项新指标,实验发现LLM类型相似度尚可但嵌套类型处理与仓库级一致性不足,为相关研究指明新方向。
摘要:
Python等动态语言的类型推断一直是软件工程领域的长期难题。尽管大语言模型(LLM)在代码理解方面展现出潜力,但其类型推断能力仍未得到充分研究。我们推出了TypyBench——一个用于评估LLM在整个Python仓库中类型推断能力的基准测试。TypyBench包含两项全新指标:TypeSim(类型相似度),用于捕捉预测类型与真实类型之间细微的语义关系;TypeCheck(类型一致性检验),用于评估代码库中的类型一致性。我们在精心筛选的包含50个高质量Python仓库的数据集上对多种LLM进行了评估,结果显示,尽管LLM取得了不错的TypeSim分数,但它们在处理复杂嵌套类型时存在困难,且会出现明显的类型一致性错误。这些发现表明,未来研究应将重点从提升类型相似度转向解决仓库级一致性问题。TypyBench为这一新研究方向奠定了基础,为了解模型在不同类型复杂度和使用场景下的表现提供了洞见。我们的代码和数据可在https://github.com/typybench/typybench获取。
英文摘要:
Type inference for dynamic languages like Python is a persistent challenge in software engineering. While large language models (LLMs) have shown promise in code understanding, their type inference capabilities remain underexplored. We introduce TypyBench, a benchmark designed to evaluate LLMs' type inference across entire Python repositories. TypyBench features two novel metrics: TypeSim, which captures nuanced semantic relationships between predicted and ground truth types, and TypeCheck, which assesses type consistency across codebases. Our evaluation of various LLMs on a curated dataset of 50 high-quality Python repositories reveals that, although LLMs achieve decent TypeSim scores, they struggle with complex nested types and exhibit significant type consistency errors. These findings suggest that future research should shift focus from improving type similarity to addressing repository-level consistency. TypyBench provides a foundation for this new direction, offering insights into model performance across different type complexities and usage contexts. Our code and data are available at https://github.com/typybench/typybench.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。