Typilus:神经类型提示
Typilus: Neural Type Hints
摘要:
在动态类型语言中,部分上下文上的类型推断是一个挑战。在这项工作中,我们提出了一个图神经网络模型,预测类型的概率推理程序的结构,名称和模式。该网络使用深度相似性学习来学习TypeSpace(类型离散空间的连续松弛)以及如何将符号(即标识符)的类型属性嵌入其中。重要的是,我们的模型可以使用一次性学习来预测开放的类型词汇表,包括罕见和用户定义的类型。我们在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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。