atlas

Research map / Large language models / Agents, code and math

TypyBench: Evaluating LLM Type Inference for Untyped Python Repositories

ICML 2025 · Large language models › Agents, code and math · approach: Code generation benchmarks

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Introduces TypyBench, a benchmark of 50 Python repositories with two metrics (TypeSim, a semantic type-similarity score, and TypeCheck, mypy-error-based consistency) to evaluate LLM type inference at repository level.

Problem

Existing type inference evaluation relies on exact or parametric-outer-type matching and judges types in isolation, missing semantic similarity and repository-wide type consistency of LLM-predicted Python annotations.

Approach

Score predicted type stubs with a continuous Jaccard-over-method-sets similarity computed recursively over generic type trees and optimal matching for unions, and measure consistency as the number of mypy errors the predicted types induce across the repository.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use full repository context instead of single-file contextGPT type inference · gptmeTypeCheck errors: 84 -> 15Helped
Use full repository context instead of single-file contextGPT type inference · private-gptTypeCheck errors: 17 -> 4Helped
Use full repository context instead of single-file contextGPT type inference · screenshot-to-codeTypeCheck errors: 6 -> 0Helped
Use full repository context instead of single-file contextGPT type inference · gptmeTypeSim: 0.877 -> 0.966Helped
Use full repository context instead of single-file contextGPT type inference · private-gptTypeSim: 0.855 -> 0.601Hurt
Use full repository context instead of single-file contextGPT type inference · screenshot-to-codeTypeSim: 0.915 -> 0.696Hurt
Increase type complexity from depth 1 to depth 5LLM type inference · TypyBench types by depthTypeSim: Average: 0.725 -> 0.598Mixed
Evaluate on repositories created in 2024 or later rather than before 2024LLM type inference · TypyBench repositories by creation dateTypeSim: pre-2024 avg: 0.705; 2024+ avg: 0.649Hurt
Evaluate rare types rather than all typesLLM type inference · TypyBench repositoriesTypeSimHurt
Use TypeSim instead of exact match for deeper typesType inference evaluation · TypyBench types by depthscore: -0.026; -0.114; -0.228; -0.289; -0.387Helped

Surprising findings

Limitations

Experimental setup

Datasets: 50 curated Python repositories from GitHub and PyPI

Benchmarks: TypyBench

Metrics: TypeSim TypeCheck (mypy error count) exact match missing rate

Baselines: GPT-4o GPT-4o-mini Claude 3.5 Sonnet DeepSeek-V3 Llama 3 Qwen2.5

Builds on: Typilus PEP 484 mypy

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy