Equivalent Linear Mappings of Large Language Models

📄 arXiv: 2505.24293v3 📥 PDF

作者: James R. Golden

分类: cs.LG, cs.AI, cs.CL

发布日期: 2025-05-30 (更新: 2025-10-11)

备注: title changed; major revisions; code available at https://github.com/jamesgolden1/equivalent-linear-LLMs/; published at https://openreview.net/forum?id=oDWbJsIuEp

期刊: Transactions on Machine Learning Research (TMLR) (10/2025)


💡 一句话要点

提出等效线性映射以解析大型语言模型的推理机制

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 可解释性 线性映射 推理机制 自然语言处理

📋 核心要点

  1. 现有方法在解释大型语言模型的隐藏表示时,无法揭示这些表示的生成机制,导致理解上的困难。
  2. 本文提出了一种将LLM推理映射到等效线性系统的方法,通过固定输入依赖的线性变换,重构输出嵌入。
  3. 实验表明,该方法在多个模型上实现了高达$10^{-13}$的重构精度,揭示了LLMs在低维语义结构中的操作特性。

📝 摘要(中文)

尽管在变换器可解释性方面取得了显著进展,但对大型语言模型(LLMs)计算机制的理解仍然是一个基本挑战。许多方法解释了网络的隐藏表示,但对这些表示的生成方式却无能为力。本文通过将LLM推理映射到一个等效且可解释的线性系统,成功重构了预测输出嵌入,且相对误差低于$10^{-13}$,无需额外的模型训练。我们利用变换器的特性,将每个操作(门控激活、注意力和归一化)表示为$A(x) imes x$,其中$A(x)$表示输入依赖的线性变换。通过战略性地分离与输入序列的梯度计算组件,固定$A(x)$的值,雅可比矩阵得到了等效的线性映射。这一方法展示了LLMs在极低维子空间中操作,且可以将奇异向量解码为可解释的语义概念。

🔬 方法详解

问题定义:本文旨在解决对大型语言模型推理机制的理解不足,现有方法无法解释隐藏表示的生成过程。

核心思路:通过将LLM的推理过程映射到一个等效的线性系统,重构输出嵌入,揭示其线性结构。

技术框架:整体流程包括输入序列的梯度计算、固定$A(x)$值、计算雅可比矩阵,最终得到每个输入标记的线性映射。

关键创新:提出了一种新的方法,通过分离梯度计算并固定线性变换,构建了等效的线性映射,与现有方法相比,提供了更深层次的可解释性。

关键设计:在实现过程中,采用了双浮点精度,确保重构输出的相对误差低于$10^{-13}$,并展示了不同层和模块的线性表示如何构建预测。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,使用等效线性映射方法,模型在重构输出嵌入时相对误差低于$10^{-13}$,且适用于多个大型语言模型,如Qwen 3、Gemma 3和Llama 3。这一成果显著提高了对LLMs的可解释性,揭示了其在低维语义空间中的操作特性。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理、文本生成和语义理解等。通过提供对大型语言模型的可解释性,能够帮助研究人员和开发者更好地理解和优化模型,推动智能系统的透明性和可靠性。未来,这种方法可能会影响模型设计和训练策略,促进更高效的AI应用。

📄 摘要(原文)

Despite significant progress in transformer interpretability, an understanding of the computational mechanisms of large language models (LLMs) remains a fundamental challenge. Many approaches interpret a network's hidden representations but remain agnostic about how those representations are generated. We address this by mapping LLM inference for a given input sequence to an equivalent and interpretable linear system which reconstructs the predicted output embedding with relative error below $10^{-13}$ at double floating-point precision, requiring no additional model training. We exploit a property of transformers wherein every operation (gated activations, attention, and normalization) can be expressed as $A(x) \cdot x$, where $A(x)$ represents an input-dependent linear transform and $x$ preserves the linear pathway. To expose this linear structure, we strategically detach components of the gradient computation with respect to an input sequence, freezing the $A(x)$ terms at their values computed during inference, such that the Jacobian yields an equivalent linear mapping. This detached Jacobian of the model reconstructs the output with one linear operator per input token, which is shown for Qwen 3, Gemma 3 and Llama 3, up to Qwen 3 14B. These linear representations demonstrate that LLMs operate in extremely low-dimensional subspaces where the singular vectors can be decoded to interpretable semantic concepts. The computation for each intermediate output also has a linear equivalent, and we examine how the linear representations of individual layers and their attention and multilayer perceptron modules build predictions, and use these as steering operators to insert semantic concepts into unrelated text. Despite their global nonlinearity, LLMs can be interpreted through equivalent linear representations that reveal low-dimensional semantic structures in the next-token prediction process.