Typilus: neural type hints

Typilus: neural type hints
复制标题

DOI:
10.1145/3385412.3385997
复制
发表时间:
2020-04
期刊:
Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation
影响因子:
--
通讯作者:
Miltiadis Allamanis;Earl T. Barr;Soline Ducousso;Zheng Gao
Miltiadis Allamanis;Earl T. Barr;Soline Ducousso;Zheng Gao
中科院分区:
其他
文献类型:
--
作者:
Miltiadis Allamanis;Earl T. Barr;Soline Ducousso;Zheng Gao

文献摘要

被引文献

相似文献

在动态类型语言中对部分上下文进行类型推断具有挑战性。在这项工作中,我们提出了一个图神经网络模型,它通过对程序的结构、名称和模式进行概率推理来预测类型。该网络使用深度相似性学习来学习类型空间(类型离散空间的连续松弛)以及如何将符号(即标识符)的类型属性嵌入其中。重要的是,我们的模型可以采用一次性学习来预测类型的开放词汇,包括罕见的和用户定义的词汇。我们在 Typilus for Python 中实现了将 TypeSpace 与可选类型检查器相结合的方法。我们证明 Typilus 能够准确预测类型。 Typilus 可以自信地预测 70% 的可注释符号的类型;当它预测一个类型时,该类型在 95% 的时间里都可以进行类型检查。 Typilus 还可以发现不正确的类型注释;两个重要且流行的开源库 fairseq 和 allennlp 接受了我们的 Pull 请求,修复了 Typilus 发现的注释错误。
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.