用复数向量让注意力头独立处理语义与位置信息,提升长文本生成效果。
ComplexFormer: Disruptively Advancing Transformer Inference Ability via Head-Specific Complex Vector Attention
- 每个注意力头在复平面上独立建模语义与位置差异,通过旋转和缩放表示交互。
- 在语言建模、代码生成等任务上,生成困惑度显著降低,长上下文一致性更强。
- 适合追求高效高精度生成的NLP研究者,尤其关注注意力机制创新者。
Transformer模型依赖自注意力捕捉标记间依赖关系,但在有效融合位置信息与多头注意力灵活性方面面临挑战。现有方法通常分开建模语义与位置差异,或对所有头采用统一的位置调整,可能限制表征能力。本文提出ComplexFormer,引入复数多头注意力(CMHA),使每个头能在复平面中独立建模语义与位置差异,将交互表示为旋转与缩放。核心改进包括:(1) 每头的欧拉变换,将查询/键投影转为极坐标形式的复向量,实现头特定复子空间操作;(2) 每头自适应的差分旋转机制,exp[i(Adapt(ASmn,i) + Delta(Pmn),i)],使各头可学习不同策略融合语义角度差(ASmn,i)与相对位置编码(Delta(Pmn),i)。大量实验显示,ComplexFormer在语言建模、文本生成、代码生成及数学推理任务中表现优异,显著降低生成困惑度,提升长上下文连贯性,优于RoPE-Transformers等强基线。该模型具备强参数效率,提供更富表达力与适应性的注意力机制。
原文摘要 · Abstract (English)
Transformer models rely on self-attention to capture token dependencies but face challenges in effectively integrating positional information while allowing multi-head attention (MHA) flexibility. Prior methods often model semantic and positional differences disparately or apply uniform positional adjustments across heads, potentially limiting representational capacity. This paper introduces ComplexFormer, featuring Complex Multi-Head Attention-CMHA. CMHA empowers each head to independently model semantic and positional differences unified within the complex plane, representing interactions as rotations and scaling. ComplexFormer incorporates two key improvements: (1) a per-head Euler transformation, converting real-valued query/key projections into polar-form complex vectors for head-specific complex subspace operation; and (2) a per-head adaptive differential rotation mechanism, exp[i(Adapt(ASmn,i) + Delta(Pmn),i)], allowing each head to learn distinct strategies for integrating semantic angle differences (ASmn,i) with relative positional encodings (Delta(Pmn),i). Extensive experiments on language modeling, text generation, code generation, and mathematical reasoning show ComplexFormer achieves superior performance, significantly lower generation perplexity , and improved long-context coherence compared to strong baselines like RoPE-Transformers. ComplexFormer demonstrates strong parameter efficiency, offering a more expressive, adaptable attention mechanism.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。