基于程序分解与类型填充训练的类型预测
Type Prediction With Program Decomposition and Fill-in-the-Type Training
AI总结:
本文提出 OpenTau,一种基于搜索和 LLM 的类型预测方法,通过树状程序分解、新质量度量及 fill-in-the-type 微调,在 TypeScript 数据集上将类型检查通过率提升至 47.4%。
摘要:
TypeScript 和 Python 是两种支持可选类型注解的编程语言,这些注解虽然有用,但引入和维护起来十分繁琐。这推动了自动化类型预测的研究:给定一个无类型程序,生成一个类型良好的输出程序。大语言模型(LLMs)在类型预测方面很有前景,但存在诸多挑战:fill-in-the-middle 表现不佳,程序可能无法放入上下文窗口,生成的类型可能无法通过类型检查,并且难以衡量输出程序的类型良好程度。我们通过构建 OpenTau 来应对这些挑战,OpenTau 是一种利用大语言模型的基于搜索的类型预测方法。我们提出了一种新的类型预测质量度量标准,给出了一种基于树的程序分解方法,用于搜索生成类型的空间,并提出了面向 LLM 的 fill-in-the-type 微调方法。我们使用一个新的 TypeScript 类型预测数据集评估了我们的工作,结果表明 47.4% 的文件通过类型检查(绝对提升 14.5%),每个文件的总体类型错误率为 3.3 个。所有代码、数据和模型均可在以下地址获取:https://github.com/GammaTauAI/opentau。
英文摘要:
TypeScript and Python are two programming languages that support optional type annotations, which are useful but tedious to introduce and maintain. This has motivated automated type prediction: given an untyped program, produce a well-typed output program. Large language models (LLMs) are promising for type prediction, but there are challenges: fill-in-the-middle performs poorly, programs may not fit into the context window, generated types may not type check, and it is difficult to measure how well-typed the output program is. We address these challenges by building OpenTau, a search-based approach for type prediction that leverages large language models. We propose a new metric for type prediction quality, give a tree-based program decomposition that searches a space of generated types, and present fill-in-the-type fine-tuning for LLMs. We evaluate our work with a new dataset for TypeScript type prediction, and show that 47.4% of files type check (14.5% absolute improvement) with an overall rate of 3.3 type errors per file. All code, data, and models are available at: https://github.com/GammaTauAI/opentau.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。