arXiv:2510.11963cs.LG2025-10

用量子力学视角重新理解Transformer的推理过程

QLENS: Towards A Quantum Perspective of Language Transformers

  • 将模型激活态映射到希尔伯特空间,层间演变为酉算子
  • 通过波函数坍缩机制计算最终输出概率分布
  • 为理解注意力机制演化提供全新物理类比视角

在自然语言处理中,现有方法虽能识别Transformer推理过程中的中间预测,但仅作为有限诊断节点,缺乏对各层如何推动状态演变的数学建模框架。受跨学科研究启发,我们转向物理学寻求描述性数学框架。观察到语言模型具有内在概率性,与量子力学基本假设高度相似,因此尝试将量子理论思想迁移至NLP。本文提出QLENS,一种基于物理视角的Transformer生成过程建模方法:将模型隐层激活转化为由输出单元构成的希尔伯特空间中的状态矢量,该状态在推理过程中通过被重定义的酉算子(对应隐藏层)和哈密顿量演化;最终输出概率分布通过应用玻恩规则,结合特定测量算子得到。为验证其潜力,我们以小型Transformer为例,探究单个层对预测轨迹的影响。本工作为跨领域洞见提供了基础,有望深化对Transformer运作机制的理解。

原文摘要 · Abstract (English)

In natural language processing, current methods for understanding Transformers are successful at identifying intermediate predictions during a model's inference. However, these approaches function as limited diagnostic checkpoints, lacking a mathematical framework for mechanistically modeling how each layer facilitates transitions between these evolving states. This interpretability gap and past successes of interdisciplinary outlooks inspire us to turn to physics in search of a descriptive mathematical framework for Transformers. We observe that language models are intrinsically probabilistic, an attribute that is echoed in the core postulates of quantum mechanics. This parallel inspires us to translate insights from this discipline to that of natural language processing. Towards this objective, we propose QLENS a novel attempt to develop a physics-based perspective on the Transformer generation process. Under QLENS, a Transformer is studied by converting its latent activations into a state vector in a Hilbert space derived from the model's output units. This state subsequently evolves through hidden layers - reformulated as unitary operators and analogously defined Hamiltonians - during inference. The model's final probability distribution is obtained by applying the Born rule to the end state using a specific measurement operator. To demonstrate QLENS's potential, we conduct a proof-of-concept by probing a toy Transformer to investigate the influence of individual layers in a model's prediction trajectory. We present our work as a foundation for cross-domain insights to be leveraged towards a broader understanding of Transformers.

Transformer量子计算可解释性物理建模

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