arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.16745cs.NE
收藏

迈向脉冲 Transformer 中的相对位置编码

Toward Relative Positional Encoding in Spiking Transformers

College of Computer Science and Artificial Intelligence, Fudan University(复旦大学计算机科学技术学院);Microsoft Research Asia(微软亚洲研究院)

Changze Lv, Yansen Wang, Dongqi Han, Yifei Shen, Xiaoqing Zheng, Xuanjing Huang, Dongsheng Li

AI总结:

本文提出多种在保持脉冲二值特性的前提下近似相对位置编码的策略,如 Gray-PE 和 Log-PE,并扩展至二维形式,在时间序列预测、文本分类和图像分类等任务中显著提升了多种 spiking Transformer 架构的性能。

摘要:

脉冲神经网络(SNNs)是受生物启发的网络,模拟大脑中神经元通过离散脉冲进行通信的方式,由于其高能效和时间处理能力,在各种任务中具有巨大潜力。带有自注意力机制的 SNNs(spiking Transformers)最近在各种任务中展现出巨大进步,并且受传统 Transformers 启发,多项研究表明脉冲绝对位置编码有助于捕捉输入数据的序列关系,增强了 spiking Transformers 在序列建模和图像分类等任务中的能力。然而,如何将相对位置信息整合到 SNNs 中仍然是一个挑战。在本文中,我们引入了几种策略来近似 spiking Transformers 中的相对位置编码,同时保持脉冲的二值特性。首先,我们正式证明用 Gray Code 编码相对距离能确保位置索引的二进制表示在十进制值相差 2 的幂时保持恒定的 Hamming distance,并基于此性质提出了 Gray-PE。此外,我们提出了另一种名为 Log-PE 的 RPE 方法,该方法将相对距离矩阵的对数形式直接结合到脉冲注意力图中。进一步地,我们将我们的 RPE 方法扩展到二维形式,使其适用于处理图像块。我们在各种任务上评估了我们的 RPE 方法,包括时间序列预测、文本分类和基于块的图像分类,实验结果表明,通过在多种架构中引入我们的 RPE 方法,获得了令人满意的性能提升。我们的结果为设计 spiking Transformers 以提升其序列建模能力提供了新视角,从而扩展了其在各个领域的适用性。

英文摘要:

Spiking neural networks (SNNs) are bio-inspired networks that mimic how neurons in the brain communicate through discrete spikes, which have great potential in various tasks due to their energy efficiency and temporal processing capabilities. SNNs with self-attention mechanisms (spiking Transformers) have recently shown great advancements in various tasks, and inspired by traditional Transformers, several studies have demonstrated that spiking absolute positional encoding can help capture sequential relationships for input data, enhancing the capabilities of spiking Transformers for tasks such as sequential modeling and image classification. However, how to incorporate relative positional information into SNNs remains a challenge. In this paper, we introduce several strategies to approximate relative positional encoding in spiking Transformers while preserving the binary nature of spikes. Firstly, we formally prove that encoding relative distances with Gray Code ensures that the binary representations of positional indices maintain a constant Hamming distance whenever their decimal values differ by a power of two, and we propose Gray-PE based on this property. In addition, we propose another RPE method called Log-PE, which combines the logarithmic form of the relative distance matrix directly into the spiking attention map. Furthermore, we extend our RPE methods to a two-dimensional form, making them suitable for processing image patches. We evaluate our RPE methods on various tasks, including time series forecasting, text classification, and patch-based image classification, and the experimental results demonstrate a satisfying performance gain by incorporating our RPE methods across many architectures. Our results provide fresh perspectives on designing spiking Transformers to advance their sequential modeling capability, thereby expanding their applicability across various domains.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑