paperbot · PL 论文追踪

全部论文 待读 收藏

P1 Prompt-tuned Code Language Model as a Neural Knowledge Base for Type Inference in Statically-Typed Partial Code

提示调优的代码语言模型作为静态类型部分代码类型推断的神经知识库
ASE Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering2022匹配度 6/10 · 论文将提示调优的代码掩码语言模型用于静态类型部分代码的类型推断,属于“AI→PL:用 LLM 改进静态分析”的方向,与程序分析和类型推断相关;但它不涉及 Agentic 程序、ML 系统静态分析、浮点或贝叶斯程序分析,且方法基于代码 MLM 提示调优而非当前较强 LLM/Agent 工具,因此匹配度中等。引用 40 inbox
Qing Huang, Zhiqiang Yuan, Zhenchang Xing, Xiwei Xu, Liming Zhu, Qinghua Lu
crossref: 2026-09-12

AI 速览

一句话:将类型推断重构为完形填空任务,用提示调优的代码掩码语言模型作为神经知识库实现模糊类型推断。

部分代码中常含非全限定类型名(non-FQN)与未声明的接收者对象,解析它们的全限定名(类型推断)是有效搜索与复用部分代码的前提。现有基于字典查找的方法需构建 API 名与代码上下文的符号知识库,编译开销大,且对未见 API 名与上下文变化敏感。本文把类型推断形式化为 cloze 式填空语言任务,基于源码自然性,采用新颖的“预训练—提示—预测”范式,在原始源码上微调代码掩码语言模型(MLM),将其训练为代码元素的神经知识库,把 FQN 的语法与用法编码进模型参数。该方法轻量、对代码编译依赖极小,并支持模糊的神经类型推断,而非符号化的名称与上下文匹配。作者在来自 GitHub 与 Stack Overflow 的大量源码上系统评估,验证了方法设计的有效性与对部分代码类型推断的实用性,作为同类首创为部分代码的创新使用打开了空间。

问题
部分代码中的非全限定类型名和未声明接收者对象妨碍了代码检索与复用,而现有基于字典查找的类型推断依赖符号知识库,编译开销大且对未见 API 名和上下文变化敏感。
方法
将类型推断建模为 cloze 式填空语言任务,以“预训练、提示、预测”范式在原始源码上微调代码掩码语言模型,使其参数中蕴含 FQN 的语法与用法,从而进行模糊的神经类型推断。
评估
在 GitHub 与 Stack Overflow 收集的大量源码上开展系统实验,验证方法设计的有效性与在部分代码类型推断上的实用性。
原文摘要(Abstract)

Partial code usually involves non-fully-qualified type names (non-FQNs) and undeclared receiving objects. Resolving the FQNs of these non-FQN types and undeclared receiving objects (referred to as type inference) is the prerequisite to effective search and reuse of partial code. Existing dictionary-lookup based methods build a symbolic knowledge base of API names and code contexts, which involve significant compilation overhead and are sensitive to unseen API names and code context variations. In this paper, we formulate type inference as a cloze-style fill-in-blank language task. Built on source code naturalness, our approach fine-tunes a code masked language model (MLM) as a neural knowledge base of code elements with a novel “pre-train, prompt and predict” paradigm from raw source code. Our approach is lightweight and has minimum requirements on code compilation. Unlike existing symbolic name and context matching for type inference, our prompt-tuned code MLM packs FQN syntax and usage in its parameters and supports fuzzy neural type inference. We systematically evaluate our approach on a large amount of source code from GitHub and Stack Overflow. Our results confirm the effectiveness of our approach design and the practicality for partial code type inference. As the first of its kind, our neural type inference method opens the door to many innovative ways of using partial code.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot7200,
  title = {Prompt-tuned Code Language Model as a Neural Knowledge Base for Type Inference in Statically-Typed Partial Code},
  author = {Qing Huang and Zhiqiang Yuan and Zhenchang Xing and Xiwei Xu and Liming Zhu and Qinghua Lu},
  booktitle = {ASE},
  year = {2022},
  doi = {10.1145/3551349.3556912}
}