TypyBench: Evaluating LLM Type Inference for Untyped Python Repositories

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Dong, Honghua, Yang, Jiacheng, Deng, Xun, Jiang, Yuhe, Pekhimenko, Gennady, Long, Fan, Si, Xujie
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866909711346958336
author Dong, Honghua
Yang, Jiacheng
Deng, Xun
Jiang, Yuhe
Pekhimenko, Gennady
Long, Fan
Si, Xujie
author_facet Dong, Honghua
Yang, Jiacheng
Deng, Xun
Jiang, Yuhe
Pekhimenko, Gennady
Long, Fan
Si, Xujie
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2507_22086
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle TypyBench: Evaluating LLM Type Inference for Untyped Python Repositories
Dong, Honghua
Yang, Jiacheng
Deng, Xun
Jiang, Yuhe
Pekhimenko, Gennady
Long, Fan
Si, Xujie
Software Engineering
Artificial Intelligence
Programming Languages
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.
title TypyBench: Evaluating LLM Type Inference for Untyped Python Repositories
topic Software Engineering
Artificial Intelligence
Programming Languages
url https://arxiv.org/abs/2507.22086