Typilus: Neural Type Hints
- URL: http://arxiv.org/abs/2004.10657v1
- Date: Mon, 6 Apr 2020 11:14:03 GMT
- Title: Typilus: Neural Type Hints
- Authors: Miltiadis Allamanis, Earl T. Barr, Soline Ducousso, and Zheng Gao
- Abstract summary: We present a graph neural network model that predicts types by probabilistically reasoning over a program's structure, names, and patterns.
Our model can employ one-shot learning to predict an open vocabulary of types, including rare and user-defined ones.
We show that Typilus confidently predicts types for 70% of all annotatable symbols.
- Score: 17.332608142043004
- License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/
- 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.
Related papers
- Generative Type Inference for Python [62.01560866916557]
This paper introduces TypeGen, a few-shot generative type inference approach that incorporates static domain knowledge from static analysis.
TypeGen creates chain-of-thought (COT) prompts by translating the type inference steps of static analysis into prompts based on the type dependency graphs (TDGs)
Experiments show that TypeGen outperforms the best baseline Type4Py by 10.0% for argument type prediction and 22.5% in return value type prediction in terms of top-1 Exact Match.
arXiv Detail & Related papers (2023-07-18T11:40:31Z) - TypeT5: Seq2seq Type Inference using Static Analysis [51.153089609654174]
We present a new type inference method that treats type prediction as a code infilling task.
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.
arXiv Detail & Related papers (2023-03-16T23:48:00Z) - Do Machine Learning Models Produce TypeScript Types That Type Check? [2.1365083849371747]
We present TypeWeaver, a TypeScript type migration tool that can be used with an arbitrary type prediction model.
We evaluate it with three models from the literature: DeepTyper, a recurrent neural network; LambdaNet, a graph neural network; and InCoder, a general-purpose, multi-language transformer.
With the best type prediction model, we find that only 21% of packages type check, but more encouragingly, 69% of files type check successfully.
arXiv Detail & Related papers (2023-02-23T16:59:38Z) - Scalable Font Reconstruction with Dual Latent Manifolds [55.29525824849242]
We propose a deep generative model that performs typography analysis and font reconstruction.
Our approach enables us to massively scale up the number of character types we can effectively model.
We evaluate on the task of font reconstruction over various datasets representing character types of many languages.
arXiv Detail & Related papers (2021-09-10T20:37:43Z) - Type4Py: Deep Similarity Learning-Based Type Inference for Python [9.956021565144662]
We present Type4Py, a deep similarity learning-based type inference model for Python.
We design a hierarchical neural network model that learns to discriminate between types of the same kind and dissimilar types in a high-dimensional space.
Considering the Top-1 prediction, Type4Py obtains 19.33% and 13.49% higher precision than Typilus and TypeWriter, respectively.
arXiv Detail & Related papers (2021-01-12T13:32:53Z) - SIGTYP 2020 Shared Task: Prediction of Typological Features [78.95376120154083]
A major drawback hampering broader adoption of typological KBs is that they are sparsely populated.
As typological features often correlate with one another, it is possible to predict them and thus automatically populate typological KBs.
Overall, the task attracted 8 submissions from 5 teams, out of which the most successful methods make use of such feature correlations.
arXiv Detail & Related papers (2020-10-16T08:47:24Z) - Linguistic Typology Features from Text: Inferring the Sparse Features of
World Atlas of Language Structures [73.06435180872293]
We construct a recurrent neural network predictor based on byte embeddings and convolutional layers.
We show that some features from various linguistic types can be predicted reliably.
arXiv Detail & Related papers (2020-04-30T21:00:53Z) - LambdaNet: Probabilistic Type Inference using Graph Neural Networks [46.66093127573704]
This paper proposes a probabilistic type inference scheme for TypeScript based on a graph neural network.
Our approach can predict both standard types, like number or string, as well as user-defined types that have not been encountered during training.
arXiv Detail & Related papers (2020-04-29T17:48:40Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.