DeepAI AI Chat
Log In Sign Up

LambdaNet: Probabilistic Type Inference using Graph Neural Networks

04/29/2020
by   Jiayi Wei, et al.
The University of Texas at Austin
19

As gradual typing becomes increasingly popular in languages like Python and TypeScript, there is a growing need to infer type annotations automatically. While type annotations help with tasks like code completion and static error catching, these annotations cannot be fully determined by compilers and are tedious to annotate by hand. This paper proposes a probabilistic type inference scheme for TypeScript based on a graph neural network. Our approach first uses lightweight source code analysis to generate a program abstraction called a type dependency graph, which links type variables with logical constraints as well as name and usage information. Given this program abstraction, we then use a graph neural network to propagate information between related type variables and eventually make type predictions. Our neural architecture can predict both standard types, like number or string, as well as user-defined types that have not been encountered during training. Our experimental results show that our approach outperforms prior work in this space by 14% (absolute) on library types, while having the ability to make type predictions that are out of scope for existing techniques.

READ FULL TEXT

page 1

page 2

page 3

page 4

06/27/2021

PYInfer: Deep Learning Semantic Type Inference for Python Variables

Python type inference is challenging in practice. Due to its dynamic pro...
04/06/2020

Typilus: Neural Type Hints

Type inference over partial contexts in dynamically typed languages is c...
09/13/2020

Advanced Graph-Based Deep Learning for Probabilistic Type Inference

Dynamically typed languages such as JavaScript and Python have emerged a...
05/08/2021

HiTyper: A Hybrid Static Type Inference Framework with Neural Prediction

Type inference for dynamic programming languages is an important yet cha...
04/01/2020

OptTyper: Probabilistic Type Inference by Optimising Logical and Natural Constraints

We present a new approach to the type inference problem for dynamic lang...
05/16/2019

Inferring Javascript types using Graph Neural Networks

The recent use of `Big Code' with state-of-the-art deep learning methods...
02/23/2023

Do Machine Learning Models Produce TypeScript Types that Type Check?

Type migration is the process of adding types to untyped code to gain as...