一句话:首个面向软件工程的LLM概念级可解释性研究,揭示注释被内化为可区分的潜在概念并显著影响任务性能。
注释是源代码中的非功能元素,但大语言模型(LLM)在软件工程(SE)任务中常依赖它们,而这种依赖位于模型何处、如何影响性能仍不清楚。本文提出首个面向SE的LLM概念级可解释性研究,以内部注释表示为切入点分析代码补全、翻译与精化三项任务。作者使用概念激活向量(CAV)表明,LLM不仅将注释内化为独立的潜在概念,还能区分Javadoc、行内与多行注释等子类型。通过在嵌入空间中系统性地激活与停用这些概念,观察到性能出现显著、模型相关且任务相关的变化,幅度从-90%到+67%。此外,作者用同一组代码输入开展受控实验,让LLM执行10种不同的SE任务并测量其潜在表示中注释概念的激活程度,发现代码摘要始终触发最强的注释概念激活,而代码补全的敏感度最低。该结果为构建基于内部概念表示而非仅依赖表层输入的SE工具与模型开辟了新方向。
While comments are non-functional elements of source code, Large Language Models (LLM) frequently rely on them to perform Software Engineering (SE) tasks. Yet, where in the model this reliance resides, and how it affects performance, remains poorly understood. We present the first concept-level interpretability study of LLMs in SE, analyzing three tasks - code completion, translation, and refinement - through the lens of internal comment representation. Using Concept Activation Vectors (CAV), we show that LLMs not only internalize comments as distinct latent concepts but also differentiate between subtypes such as Javadocs, inline, and multiline comments. By systematically activating and deactivating these concepts in the LLMs’ embedding space, we observed significant, model-specific, and task-dependent shifts in performance ranging from -90% to +67%. Finally, we conducted a controlled experiment using the same set of code inputs, prompting LLMs to perform 10 distinct SE tasks while measuring the activation of the comment concept within their latent representations. We found that code summarization consistently triggered the strongest activation of comment concepts, whereas code completion elicited the weakest sensitivity. These results open a new direction for building SE tools and models that reason about and manipulate internal concept representations rather than relying solely on surface-level input.