paperbot · PL 论文追踪

全部论文 待读 收藏

P1 TIGER: A Generating-Then-Ranking Framework for Practical Python Type Inference

TIGER:面向实用 Python 类型推断的“先生成后排序”框架
ICSE 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE)2025匹配度 5/10 · 论文属于机器学习与程序语言交叉中的类型推断任务,与用户关注的“AI→PL”方向有部分重叠,但未涉及 LLM/Agent 改进静态分析、浮点程序分析或贝叶斯程序分析等核心兴趣。方法基于预训练代码模型而非当前强 LLM/Agent,理论形式化较弱。引用 2 inbox
Chong Wang, Jian Zhang, Yiling Lou, Mingwei Liu, Weisong Sun, Yang Liu, Xin Peng
crossref: 2026-09-12

AI 速览

一句话:提出两阶段“先生成后排序”框架,显著提升 Python 中用户定义类型与未见类型的推断准确率。

Python 的动态类型系统灵活但易引发类型相关错误,自动类型推断可用于补全类型提示。现有基于学习的方法虽有较好准确率,却难以全面处理各类类型,尤其是复杂参数化类型和未见过的用户定义类型。本文提出 TIGER,一个“先生成后排序”(GTR)的两阶段框架:借助微调的预训练代码模型,分别以 span masking 目标训练生成模型、以对比学习目标训练相似度模型;生成阶段产出大量类型候选(包括复杂参数化类型),排序阶段则结合用户定义类型对候选精确排序。在 ManyTypes4Py 数据集上的评估表明,TIGER 在多种类型类别上优于现有方法,在 Top-5 Exact Match 中推断用户定义类型和未见类型的准确率分别提升 11.2% 和 20.1%,同时验证了生成与排序两阶段对自动类型推断的重要作用。

问题
Python 动态类型易导致类型相关错误,而现有基于学习的类型推断方法难以全面应对复杂参数化类型以及用户定义或未见类型。
方法
提出 TIGER 两阶段“先生成后排序”框架,基于微调的预训练代码模型,分别用 span masking 训练生成模型、用对比学习训练相似度模型,先生成大量类型候选再对其排序。
评估
在 ManyTypes4Py 数据集上与现有方法对比,Top-5 Exact Match 中用户定义类型与未见类型的推断准确率分别提升 11.2% 和 20.1%,并通过实验分析了生成与排序阶段的作用。
原文摘要(Abstract)

Python's dynamic typing system offers flexibility and expressiveness but can lead to type-related errors, prompting the need for automated type inference to enhance type hinting. While existing learning-based approaches show promising inference accuracy, they struggle with practical challenges in comprehensively handling various types, including complex parameterized types and (unseen) user-defined types. In this paper, we introduce TIGER, a two-stage generating-then-ranking (GTR) framework, designed to effectively handle Python's diverse type categories. TIGER leverages fine-tuned pre-trained code models to train a generative model with a span masking objective and a similarity model with a contrastive training objective. This approach allows TIGER to generate a wide range of type candidates, including complex parameterized types in the generating stage, and accurately rank them with user-defined types in the ranking stage. Our evaluation on the ManyTypes4Py dataset shows TIGER's advantage over existing methods in various type categories, notably improving accuracy in inferring user-defined and unseen types by 11.2% and 20.1% respectively in Top-5 Exact Match. Moreover, the experimental results not only demonstrate TIGER's superior performance and efficiency, but also underscore the significance of its generating and ranking stages in enhancing automated type inference.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8837,
  title = {TIGER: A Generating-Then-Ranking Framework for Practical Python Type Inference},
  author = {Chong Wang and Jian Zhang and Yiling Lou and Mingwei Liu and Weisong Sun and Yang Liu and Xin Peng},
  booktitle = {ICSE},
  year = {2025},
  doi = {10.1109/icse55347.2025.00019}
}