PulseExploreJournal ClubDebatesTrendingResearchersJournals
Instagram
HomeExploreJournal ClubTrending
Synapse
⌘+K
Synapse
January 25, 20260 citationsOpen Access

Assessing Large Language Models for Type Inference in python on real-world dataset

View Full Paper
BRBharmal Rashida

Key Points

  • The study examines how well large language models can perform type inference in Python using real-world datasets.
  • Investigated two large language models: Codestral and Qwen2.5-Coder.
  • Utilized the ManyTypes4Py dataset for comprehensive evaluation.
  • Implemented two prompting strategies: mask-based and question-and-answer (QnA).
  • Applied Parameter-Efficient Fine-Tuning (PEFT) with LoRA to enhance model performance.
  • QnA prompting outperforms mask-based prompting in type inference.
  • Codestral achieved an 88.7% exact match accuracy with QnA prompting.
  • Qwen2.5-Coder improved from 61.5% to 83.6% with QnA prompting.
  • Fine-tuning increased Codestral's performance from 86.4% to 96.9% and Qwen2.5-Coder from 84.0% to 93.8%.
  • Analysis revealed improvements in structured type inference, but occasional misclassification of rare types.

Abstract

Python’s dynamic type system offers flexibility but often leads to runtime errors and reduced maintainability in large-scale software systems. While optional type annotations (PEP 484) help mitigate these issues, they are inconsistently adopted across real-world codebases. To address this gap, recent studies have explored the use of Large Language Models (LLMs) for type inference, showing promising results on micro-benchmarks. However, their performance on real-world codebases remains underexplored.This thesis investigates the effectiveness of LLMs for Python type inference using a real-world dataset. We extend the TypeEvalPy framework by incorporating the ManyTypes4Py dataset, enabling a comprehensive evaluation of LLM performance across frequent, rare, and user-defined types. Two state-of-the-art LLMs, Codestral (22B) and Qwen2.5-Coder (7B), are evaluated using two prompting strategies on microbenchmark: mask-based prompting and question-and-answer (QnA) prompting. Furthermore, we apply Parameter-Efficient Fine-Tuning (PEFT) using LoRA to adapt these models to the type inference task.Our results show that QnA prompting significantly outperforms mask-based prompting on the TypeEvalPy micro-benchmark. Codestral achieves an overall exact match accuracy of 88.7% with QnA prompting, compared to 67.8% with mask-based prompting. Qwen2.5-Coder improves from 61.5% to 83.6% using the same strategy. Finetuning further boosts performance: Codestral improves from 86.4% to 96.9% , and Qwen2.5-Coder from 84.0% to 93.8%. Analysis of frequent and rare types shows that fine-tuning enhances structured type inference while occasionally misclassifying generictypes. These findings suggest that LLMs provide a robust solution for type inference in real-world scenarios, though improvements are needed for rare and user-defined types.

Ask AI
Helpful
Bookmark
Share
View Full Paper

Cite This Study

Bharmal Rashida (2025) studied this question.

synapsesocial.com/papers/6975b1a9feba4585c2d6d382https://doi.org/10.17619/unipb/1-2481
Ask AI
Helpful
Bookmark
Share
View Full Paper