PLLGMLApr 6, 2020

Typilus: Neural Type Hints

arXiv:2004.10657v1149 citationsHas Code
AI Analysis

This addresses the challenge of type inference for developers in dynamically typed languages like Python, offering a tool that can predict and correct type annotations, though it is incremental as it builds on existing neural and type-checking methods.

The paper tackles type inference in dynamically typed languages by introducing a graph neural network model that predicts types using probabilistic reasoning over program structure, names, and patterns, achieving 70% coverage for annotatable symbols and 95% type-check accuracy when predictions are made.

Type inference over partial contexts in dynamically typed languages is challenging. In this work, we present a graph neural network model that predicts types by probabilistically reasoning over a program's structure, names, and patterns. The network uses deep similarity learning to learn a TypeSpace -- a continuous relaxation of the discrete space of types -- and how to embed the type properties of a symbol (i.e. identifier) into it. Importantly, our model can employ one-shot learning to predict an open vocabulary of types, including rare and user-defined ones. We realise our approach in Typilus for Python that combines the TypeSpace with an optional type checker. We show that Typilus accurately predicts types. Typilus confidently predicts types for 70% of all annotatable symbols; when it predicts a type, that type optionally type checks 95% of the time. Typilus can also find incorrect type annotations; two important and popular open source libraries, fairseq and allennlp, accepted our pull requests that fixed the annotation errors Typilus discovered.

Code Implementations3 repos
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes