[论文解读] SE Factual Knowledge in Frozen Giant Code Model: A Study on FQN and its Retrieval
本文提出了一种轻量级的上下文学习方法,无需微调或代码编译,即可从 GitHub Copilot(一个冻结的大型代码模型)中检索 API 完全限定名(FQN)。实验表明,Copilot 存储了大量关于 FQN 的事实性知识,仅需极少的 few-shot 示例即可实现高推理准确率,从而实现面向代码分析与复用任务的实用化、可部署的 FQN 预测。
Pre-trained giant code models (PCMs) start coming into the developers' daily practices. Understanding what types of and how much software knowledge is packed into PCMs is the foundation for incorporating PCMs into software engineering (SE) tasks and fully releasing their potential. In this work, we conduct the first systematic study on the SE factual knowledge in the state-of-the-art PCM CoPilot, focusing on APIs' Fully Qualified Names (FQNs), the fundamental knowledge for effective code analysis, search and reuse. Driven by FQNs' data distribution properties, we design a novel lightweight in-context learning on Copilot for FQN inference, which does not require code compilation as traditional methods or gradient update by recent FQN prompt-tuning. We systematically experiment with five in-context-learning design factors to identify the best in-context learning configuration that developers can adopt in practice. With this best configuration, we investigate the effects of amount of example prompts and FQN data properties on Copilot's FQN inference capability. Our results confirm that Copilot stores diverse FQN knowledge and can be applied for the FQN inference due to its high inference accuracy and non-reliance on code analysis. Based on our experience interacting with Copilot, we discuss various opportunities to improve human-CoPilot interaction in the FQN inference task.
研究动机与目标
- 探究冻结的大型代码模型(如 GitHub Copilot)中存储的事实性软件工程知识(特别是 API 完全限定名,FQN)的范围与特征。
- 评估上下文学习是否能在不进行模型微调或代码分析的情况下,有效从 Copilot 中检索 FQN 知识。
- 识别在部分代码中进行 FQN 推理时最优的提示设计配置,以最小化对外部符号知识库的依赖。
- 探索在真实软件工程工作流中,使用冻结的程序代码模型(PCMs)进行 FQN 推理时,人机协作的实际模式。
提出的方法
- 设计一种新颖的上下文学习框架,仅通过提示示例进行 FQN 推理,无需梯度更新或代码编译。
- 利用 FQN 的数据分布特性——时间上的突发性、齐普夫分布(Zipfian distribution)以及语义的动态性——指导提示设计。
- 系统评估五种上下文学习设计因素(如 few-shot 示例数量、提示格式、示例顺序等),以识别最优配置。
- 使用来自六个主要库(Android SDK、JDK、Hibernate 等)的 FQN 收集数据集,评估 Copilot 的 FQN 推理性能。
- 应用零样本和 few-shot 提示技术,在部分代码片段中推断 FQN,测量在不同数据属性下的准确率与鲁棒性。
- 分析 FQN 频率、长度及使用模式对推理性能的影响,以理解模型的泛化能力。
实验结果
研究问题
- RQ1GitHub Copilot 在多大程度上将事实性 FQN 知识作为神经知识库进行存储?
- RQ2何种上下文学习提示设计可在不微调模型的前提下,使 Copilot 实现最高的 FQN 推理准确率?
- RQ3few-shot 示例的数量以及 FQN 数据属性(如频率、长度)如何影响推理性能?
- RQ4在冻结的 Copilot 上使用上下文学习,是否能优于传统的符号分析或编译分析方法进行 FQN 推理?
- RQ5在 FQN 推理任务中,人机协作具有哪些实际影响与潜在机会?
主要发现
- Copilot 存储了大量且多样的事实性 FQN 知识,可在不进行模型微调或代码编译的情况下实现高精度推理。
- 表现最佳的上下文学习配置仅使用少量 few-shot 示例,即可实现高 FQN 推理准确率,且在不同 FQN 频率水平下性能稳定。
- FQN 数据呈现齐普夫分布,其中 12% 的 FQN 使用次数超过 10,000 次,且模型对罕见或未登录词(out-of-vocabulary)FQN 的泛化能力良好。
- 在 Copilot 上进行上下文学习在技术上是可行且可规模化部署的,因为它无需模型更新或解析,仅需提示工程。
- 模型性能对提示设计的变化具有鲁棒性,但最优配置能显著提升准确率,尤其在处理模糊或一词多义的简单名称时。
- 通过结构化提示设计与 AI 链范式,可增强人机协作在 FQN 推理中的效果,从而实现更可靠、可复用的代码分析工作流。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。