arXiv:2506.20746cs.LG2025-06被引 2

揭示大模型微调后如何定位和使用新知识。

Dynamic Weight Grafting: Localizing Finetuned Factual Knowledge in Transformers

  • 通过动态权重嫁接技术,精准分析微调知识在模型中的存储位置。
  • 发现知识检索依赖两种路径:实体处理时即时增强与生成前回溯记忆。
  • 定位到最终层注意力和前馈网络中特定组件负责知识召回,适合模型可解释性研究者。

当大语言模型在微调过程中学习新事实(如新电影上映、新当选教皇等)时,这些信息存储在哪里?是立即在残差流中增强实体关系,还是在生成前即时回忆?现有定位方法(如激活修补)通常替换残差流部分,覆盖原有信息,难以有效分析。为此,我们提出动态权重嫁接技术,将微调模型的子集权重选择性嫁接到预训练模型上。实验表明,存在两条独立的知识检索路径:1)在处理对应实体的词元时(如“Zendaya”在“Zendaya与蒂莫西·查拉梅共同出演”中),将关系信息嵌入残差流;2)在生成目标事实前的最后一个词元位置,主动回溯该信息。某些情况下需双路径协同,而另一些情况仅依赖其一即可正确生成。我们进一步定位‘回溯’路径至模型组件,发现其通过任务特定注意力机制以及最终层前馈网络中的实体特异性提取步骤实现。相比仅关注激活,该方法从参数层面揭示了微调知识在生成过程中的具体获取机制。

原文摘要 · Abstract (English)

When an LLM learns a new fact during finetuning (e.g., new movie releases, newly elected pope, etc.), where does this information go? Are entities enriched with relation information immediately, or do models recall information just-in-time before a prediction? Or, are "all of the above" true, with LLMs implementing multiple redundant heuristics? Existing localization approaches (e.g., activation patching) are ill-suited for this analysis because they usually replace parts of the residual stream, thus overriding previous information. To fill this interpretability gap, we propose dynamic weight grafting, an analysis technique that selectively grafts subsets of weights from a finetuned model onto a pretrained model. Using this technique, we show two separate pathways for retrieving finetuned relation information: 1) "enriching" the residual stream with relation information while processing the tokens that correspond to an entity (e.g., "Zendaya" in "Zendaya co-starred with Timothée Chalamet" and 2) "recalling" this information at the final token position before generating a target fact. In some cases, models need information from both of these pathways to correctly generate finetuned facts while, in other cases, either the "enrichment" or "recall" pathway alone is sufficient. We localize the "recall" pathway to model components -- finding that "recall" occurs via both task-specific attention mechanisms and an entity-specific extraction step in the feedforward networks of the final layers before prediction. By targeting model components and parameters, as opposed to just activations, we are able to understand the mechanisms by which finetuned knowledge is retrieved during generation.

模型可解释性知识定位微调机制

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。