分析代码语言模型中的潜在概念
Analyzing Latent Concepts in Code Language Models
AI总结:
针对代码大语言模型内部行为解释难题,提出CoCoA全局事后可解释性框架与混合标注流水线,结合局部归因生成概念级解释,经实验验证稳定性与微调演化规律,用户研究中可解释性提升37个百分点。
摘要:
解释在代码上训练的大语言模型的内部行为仍是一项关键挑战,尤其对于要求可信度、透明度和语义鲁棒性的应用而言。我们提出Code Concept Analysis(CoCoA,代码概念分析):这是一个全局事后可解释性框架,通过将上下文化的词元嵌入聚类为人类可理解的概念组,揭示代码语言模型表示空间中涌现的词汇、句法和语义结构。我们提出一种混合标注流水线,将基于静态分析工具的句法对齐与提示工程优化的大语言模型(LLMs)相结合,可跨抽象层级对潜在概念进行可扩展标注。我们分析了概念在各层之间以及在三个微调任务中的分布情况。涌现的概念簇有助于识别意外的潜在交互,还可用于识别模型习得表示中的趋势和偏差。我们进一步将LCA与局部归因方法相结合,生成基于概念的解释,提升了词元级显著性的一致性与可解释性。跨多个模型和任务的实证评估表明,LCA发现的概念在保语义扰动下保持稳定(平均簇敏感度指数CSI = 0.288),且随微调呈现可预测的演化。在一项针对编程语言分类任务的用户研究中,与使用Integrated Gradients的词元级归因相比,概念增强的解释明确了词元角色,将以人为中心的可解释性提升了37个百分点。
英文摘要:
Interpreting the internal behavior of large language models trained on code remains a critical challenge, particularly for applications demanding trust, transparency, and semantic robustness. We propose Code Concept Analysis (CoCoA): a global post-hoc interpretability framework that uncovers emergent lexical, syntactic, and semantic structures in a code language model's representation space by clustering contextualized token embeddings into human-interpretable concept groups. We propose a hybrid annotation pipeline that combines static analysis tool-based syntactic alignment with prompt-engineered large language models (LLMs), enabling scalable labeling of latent concepts across abstraction levels. We analyse the distribution of concepts across layers and across three finetuning tasks. Emergent concept clusters can help identify unexpected latent interactions and be used to identify trends and biases within the model's learned representations. We further integrate LCA with local attribution methods to produce concept-grounded explanations, improving the coherence and interpretability of token-level saliency. Empirical evaluations across multiple models and tasks show that LCA discovers concepts that remain stable under semantic-preserving perturbations (average Cluster Sensitivity Index, CSI = 0.288) and evolve predictably with fine-tuning. In a user study on the programming-language classification task, concept-augmented explanations disambiguated token roles and improved human-centric explainability by 37 percentage points compared with token-level attributions using Integrated Gradients.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。