Typilus: neural type hints

By Miltiadis Allamanis, Earl T. Barr, Soline Ducousso, Zheng Gao. 2020

150 citations recorded by the source corpus.

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.

Subfields: Cellular and Molecular Neuroscience, Cognitive Neuroscience, Paleontology, Natural Language Processing, Program Analysis & Verification

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Cellular and Molecular Neuroscience

  1. Prem Devanbu
  2. Kevin Jesse
  3. Sida I. Wang

In Cognitive Neuroscience

  1. Tianjun Zhang
  2. Prem Devanbu
  3. Kevin Jesse
  4. Wen-tau Yih
  5. Pieter Abbeel
  6. Ion Stoica
  7. Sida I. Wang
  8. Sergey Levine

In Paleontology

  1. Prem Devanbu
  2. Kevin Jesse

In Natural Language Processing

  1. Luke S. Zettlemoyer
  2. Wen-tau Yih
  3. Percy Liang
  4. Michael Lewis
  5. Eric Wallace
  6. Dan Roth
  7. Mohit Bansal
  8. Yejin Choi

In Program Analysis & Verification

  1. Prem Devanbu
  2. Milod Kazerounian
  3. Anand Ashok Sawant
  4. Kevin Jesse
  5. Bonan Min
  6. Jeffrey S. Foster
  7. Georgios Gousios
  8. Amir M. Mir

Citations in the corpus