TypeT5: Seq2seq Type Inference using Static Analysis

03/16/2023
by   Jiayi Wei, et al.
0

There has been growing interest in automatically predicting missing type annotations in programs written in Python and JavaScript. While prior methods have achieved impressive accuracy when predicting the most common types, they often perform poorly on rare or complex types. In this paper, we present a new type inference method that treats type prediction as a code infilling task by leveraging CodeT5, a state-of-the-art seq2seq pre-trained language model for code. Our method uses static analysis to construct dynamic contexts for each code element whose type signature is to be predicted by the model. We also propose an iterative decoding scheme that incorporates previous type predictions in the model's input context, allowing information exchange between related code elements. Our evaluation shows that the proposed approach, TypeT5, not only achieves a higher overall accuracy (particularly on rare and complex types) but also produces more coherent results with fewer type errors – while enabling easy user intervention.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
07/18/2023

Generative Type Inference for Python

Python is a popular dynamic programming language, evidenced by its ranki...
research
02/15/2023

Path-sensitive Type Analysis with Backward Analysis for Quality Assurance of Dynamic Typed Language Code

Precise and fast static type analysis for dynamically typed language is ...
research
08/04/2023

TIPICAL – Type Inference for Python In Critical Accuracy Level

Type inference methods based on deep learning are becoming increasingly ...
research
12/08/2019

TypeWriter: Neural Type Prediction with Search-based Validation

Maintaining large code bases written in dynamically typed languages, suc...
research
09/13/2020

Advanced Graph-Based Deep Learning for Probabilistic Type Inference

Dynamically typed languages such as JavaScript and Python have emerged a...
research
04/06/2020

Typilus: Neural Type Hints

Type inference over partial contexts in dynamically typed languages is c...
research
07/05/2018

Gradual Liquid Type Inference

Liquid typing provides a decidable refinement inference mechanism that i...

Please sign up or login with your details

Forgot password? Click here to reset