一句话:通过自动化知识校准与反事实缺陷诊断,在免微调、免示例的情况下提升 LLM 的代码任务表现。
针对大语言模型在缺陷检测、程序修复等代码任务上能力受限的问题,微调与上下文学习需大量算力、高质量数据与持续维护,且无法解释模型缺陷。本文提出 Calico,以进化式方法交织知识校准与 AI 缺陷诊断:先定位 LLM 程序理解中的知识缺口,再通过自动化代码重构把被忽视的知识融入源代码,最后用 what-if 分析与反事实推理确定提升代码任务性能所需的最小知识集合。作者在 8,938 个程序、三类常见代码任务上评估,表明原始 ChatGPT 无法充分理解代码结构,知识校准使其提升 20%,达到与微调 LLM 相当的水平,缺陷诊断在保证性能的同时将程序规模缩减 8%。
Recent advancements in large language models (LLMs) have exhibited promising capabilities in addressing various tasks such as defect detection and program repair. Despite their prevalence, LLMs still face limitations in effectively handling these tasks. Common strategies to adapt them and improve their performance for specific tasks involve fine-tuning models based on user data or employing in-context learning with examples of desired inputs and outputs. However, they pose challenges for practical adoption due to the need for extensive computational resources, high-quality data, and continuous maintenance. Furthermore, neither strategy can explain or reason about the deficiencies of LLMs in the given tasks. We propose Calico to address the high cost of fine-tuning, eliminate the necessity for task-specific examples, and provide explanations of LLM deficiency. At the heart of Calico is an evolutionary approach that interleaves knowledge calibration and AI deficiency diagnosis. The key essence of Calico is as follows. First, it focuses on identifying knowledge gaps in LLMs’ program comprehension. Second, it conducts automated code refactoring to integrate the overlooked knowledge into the source code for mitigating those gaps. Third, it employs what-if analysis and counterfactual reasoning to determine a minimum set of overlooked knowledge necessary to improve the performance of LLMs in code tasks. We have extensively evaluated Calico over 8,938 programs on three most commonly seen code tasks. Our experimental results show that vanilla ChatGPT cannot fully understand code structures. With knowledge calibration, Calico improves it by 20% and exhibits comparable proficiency compared to fine-tuned LLMs. Deficiency diagnosis contributes to 8% reduction in program sizes while ensuring performance. These impressive results demonstrate the feasibility of utilizing a vanilla LLM for automated software engineering (SE) tasks, thereby avoiding the high computational costs associated with a fine-tuned model.