用量子电路替代softmax,让注意力更稳定且表现更好
Quantum Doubly Stochastic Transformers

- 用可变量子电路代替softmax,生成双随机注意力矩阵
- 在小规模图像任务上优于标准ViT和传统双随机Transformer
- 提升训练稳定性,适合小数据场景下的模型设计
Transformer中的softmax将注意力矩阵归一化为右随机矩阵。已有研究表明,强制其为双随机矩阵(通过Sinkhorn算法)能持续提升不同任务、领域和Transformer变体的性能。然而,Sinkhorn算法具有迭代性、近似性、非参数性,难以灵活控制所得双随机矩阵。最近研究证明,可通过参数化量子电路实现双随机矩阵,引入一种无经典对应物的新型量子归纳偏置。受此启发,我们展示了混合经典-量子双随机Transformer(QDSFormer)的可行性,用变分量子电路替代自注意力层中的softmax。研究发现该电路表达能力更强,生成的双随机矩阵更具多样性且信息保留更佳。在多个小规模物体识别任务中,QDSFormer始终优于标准ViT及其他双随机Transformer。对比对象包括基于QR分解的新型量子启发双随机Transformer,亦具独立价值。此外,QDSFormer展现出更优的训练稳定性与更低性能波动,可能缓解小数据下ViT训练不稳定的难题。
原文摘要 · Abstract (English)
At the core of the Transformer, the softmax normalizes the attention matrix to be right stochastic. Previous research has shown that this often de-stabilizes training and that enforcing the attention matrix to be doubly stochastic (through Sinkhorn's algorithm) consistently improves performance across different tasks, domains and Transformer flavors. However, Sinkhorn's algorithm is iterative, approximative, non-parametric and thus inflexible w.r.t. the obtained doubly stochastic matrix (DSM). Recently, it has been proven that DSMs can be obtained with a parametric quantum circuit, yielding a novel quantum inductive bias for DSMs with no known classical analogue. Motivated by this, we demonstrate the feasibility of a hybrid classical-quantum doubly stochastic Transformer (QDSFormer) that replaces the softmax in the self-attention layer with a variational quantum circuit. We study the expressive power of the circuit and find that it yields more diverse DSMs that better preserve information than classical operators. Across multiple small-scale object recognition tasks, we find that our QDSFormer consistently surpasses both a standard ViT and other doubly stochastic Transformers. Beyond the Sinkformer, this comparison includes a novel quantum-inspired doubly stochastic Transformer (based on QR decomposition) that can be of independent interest. Our QDSFormer also shows improved training stability and lower performance variation suggesting that it may mitigate the notoriously unstable training of ViTs on small-scale data.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。