HackerPapers

arXiv:2004.10657cs.PL

Typilus: Neural Type Hints

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

Early discovery. Linked by one identifiable commenter. This paper is outside the main ranking; a mention is not an endorsement.

Abstract

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.

arXiv comments
Accepted to PLDI 2020
Journal reference
DOI
doi:10.1145/3385412.3385997
Subjects
cs.PLProgramming Languages cs.LGMachine Learning stat.MLMachine Learning (Statistics)

On Hacker News

Linked by 1 identifiable commenter in 1 comment across 1 thread, from Aug 2020 to Aug 2020.

Comments linking this paper, per year.

Discussed in comments1 thread

    • It used to be that "type inference" would successfully disambiguate, but now things like these exist https://arxiv.org/abs/2005.02161 https://arxiv.org/abs/2004.10657

      shmageggyView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.