RetypeR: Integrated Retrieval-based Automatic Program Repair for Python Type Errors

Python is a widely popular dynamic programming language. While Python's dynamic type system facilitates the development of Python programs, it also introduces type errors at run-time which are often challenging to repair. Large language models (LLMs) have recently demonstrated impressive performance in code understanding and generation, and have been applied to patch synthesis. However, the ability of LLMs to repair type errors is often limited by their finite input context window, which may not fully encompass the repair information necessary for fixing a specific type error, such as valuable context code and fix patterns. In this paper, we introduce RetypeR, an integrated retrieval-based framework to repair Python type errors automatically. RetypeR comprises two stages: external retrieval and internal retrieval. The external retrieval stage retrieves applicable fix patterns from external code repositories containing historical error fixes via an abstract syntax tree (AST)-based retrieval strategy. In the internal retrieval stage, a novel fix ingredient retriever is designed to extract valuable repair ingredients from local context within source files based on both lexical and semantic similarity. To integrate the information retrieved from the aforementioned external and internal stages, RetypeR constructs context-aware repair prompts for LLMs to guide them in generating correct patches for type errors. We evaluate RetypeR on two real-world benchmarks, TypeBugs and BugsInPy. The experimental results demonstrate that RetypeR achieves state-of-the-art performance, improving the best baseline by 12.73% and 11.54% on TypeBugs and BugsInPy benchmarks, respectively.

Authors

Institutions

Publication Details

Published
2024-10-06
DOI
https://doi.org/10.1109/icsme58944.2024.00028
Primary Topic
Computational Physics and Python Applications
Type
article
Field-Weighted Citation Impact
0.00

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

RetypeR: Integrated Retrieval-based Automatic Program Repair for Python Type Errors

Hongwei Liu, Sichong Hao, Xianjun Shi
Computational Physics and Python Applications
article

RetypeR: Integrated Retrieval-based Automatic Program Repair for Python Type Errors

Hongwei Liu, Sichong Hao, Xianjun Shi
article en

Abstract

Python is a widely popular dynamic programming language. While Python's dynamic type system facilitates the development of Python programs, it also introduces type errors at run-time which are often challenging to repair. Large language models (LLMs) have recently demonstrated impressive performance in code understanding and generation, and have been applied to patch synthesis. However, the ability of LLMs to repair type errors is often limited by their finite input context window, which may not fully encompass the repair information necessary for fixing a specific type error, such as valuable context code and fix patterns. In this paper, we introduce RetypeR, an integrated retrieval-based framework to repair Python type errors automatically. RetypeR comprises two stages: external retrieval and internal retrieval. The external retrieval stage retrieves applicable fix patterns from external code repositories containing historical error fixes via an abstract syntax tree (AST)-based retrieval strategy. In the internal retrieval stage, a novel fix ingredient retriever is designed to extract valuable repair ingredients from local context within source files based on both lexical and semantic similarity. To integrate the information retrieved from the aforementioned external and internal stages, RetypeR constructs context-aware repair prompts for LLMs to guide them in generating correct patches for type errors. We evaluate RetypeR on two real-world benchmarks, TypeBugs and BugsInPy. The experimental results demonstrate that RetypeR achieves state-of-the-art performance, improving the best baseline by 12.73% and 11.54% on TypeBugs and BugsInPy benchmarks, respectively.

Harbin Institute of Technology (CN)
National Key Research and Development Program of China
Openalex Percentile: Top 79%
Computational Physics and Python Applications
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

RetypeR: Integrated Retrieval-based Automatic Program Repair for Python Type Errors — Hongwei Liu, Sichong Hao, et al. · (2024) | TGRS Research Map | TGRS