Positional Encoding for Spiking Transformers

Zijian Zhou, Yu Liang, Honglin Cao, Ammar Belatreche, Jieyuan Zhang, Wenjie Wei, Shuai Wang, Malu Zhang, Yang Yang, Haizhou LiICML 2026

Spiking Neural Networks (SNNs) and Transformers are two powerful paradigms in modern AI. Transformers offer unmatched sequential modeling capabilities, while SNNs—which communicate via discrete, binary "spikes" mimicking biological brains—promise incredible energy efficiency. However, merging the two has revealed a critical friction point: positional encoding.

Researchers have recently introduced Spiking Positional Encoding (SPE), a novel method that injects sequence order into Spiking Transformers by modulating neuronal thresholds rather than modifying input embeddings. This approach preserves the energy-efficient, spike-driven nature of these networks while achieving state-of-the-art performance across 13 NLP benchmarks, reducing energy consumption by over 27%, and adding zero extra parameters.

The Positional Dilemma in Spiking Networks

Standard Transformers are inherently "position-agnostic." Without explicit instructions, they treat a sentence like a bag of words, failing to distinguish between "Dog bites man" and "Man bites dog." In standard Artificial Neural Networks (ANNs), Positional Encoding (PE) solves this by adding continuous positional vectors to the input embeddings.

SNNs, however, face a dilemma. Existing PE methods borrowed from ANNs often break the "spike-driven" paradigm by forcing binary signals back into continuous ones. Furthermore, they can destroy the linear complexity ($O(N)$) of Spiking Self-Attention (SSA), forcing it back to the computationally expensive quadratic complexity ($O(N^2)$) of standard Transformers. Without a native, spike-compatible way to handle position, Spiking Transformers struggle with complex language tasks.

The Spiking Positional Encoding (SPE) Solution

To bridge this gap, the authors propose two primary innovations designed specifically for the spiking architecture:

1. The PE-LIF Neuron

Instead of adding positional vectors to the input, SPE bakes positional information directly into the Leaky Integrate-and-Fire (LIF) neurons. Each neuron is assigned a position-dependent threshold ($\theta_{i,j}$) using a sinusoidal function. Because the threshold determines exactly when a neuron fires, the resulting spike train implicitly carries the "signature" of its position.

When applied to the Query ($Q$) and Key ($K$) branches of attention, these thresholds act as a "positional gate." This allows the model to modulate token interactions based on their relative distance without needing the computationally expensive Softmax operation used in ANNs.

2. Membrane Potential Regularization Surrogate Gradient (MPR-SG)

Training SNNs is notoriously difficult because discrete spikes are non-differentiable. To ensure the network learns effectively, the authors developed a specialized surrogate gradient. MPR-SG encourages the network's internal membrane potential to stay close to the spike output during training. This regularization ensures that the mathematical properties required for relative positional encoding are actually realized in the trained model.

Key Insights and Performance Gains

The SPE architecture was rigorously evaluated across 13 diverse NLP benchmarks, including short-text classification (MR, SST-2), long-text classification (AGNEWS, IMDB), and the comprehensive GLUE benchmark.

  • Massive Performance Leaps: On the GLUE benchmark, a Spikingformer equipped with SPE achieved an average score of 72.6, a 5.8-point increase over the baseline model without PE.
  • Mastery of Long-Range Dependencies: In long-text tasks featuring sequences up to 1024 tokens, SPE outperformed the strongest SNN baselines by 7.43 percentage points. The mathematical design of SPE naturally exhibits "long-term decay," meaning the association between two tokens weakens as they get further apart—a highly desirable inductive bias for language modeling.
  • Increased Energy Efficiency: Counter-intuitively, adding positional information lowered energy use. The position-dependent thresholds have a higher average value than standard unit thresholds, which naturally inhibits redundant firing. The model consumed only 4.92 mJ per sample, a 27.2% reduction in energy compared to the baseline Spikingformer.
  • Zero-Parameter Gain: Unlike other SNN-specific PE methods, SPE requires zero additional trainable parameters. The performance gains stem entirely from a superior architectural fit.

Future Directions

While SPE represents a significant leap forward for NLP in spiking networks, the authors note several promising avenues for future research. First, expanding SPE beyond text to multi-modal tasks (like video or joint audio-visual processing) is a logical next step. Second, while theoretical energy savings are substantial, deploying these models on specialized neuromorphic hardware (such as Intel's Loihi or the Tianjic chip) will be crucial to realizing their full physical efficiency. Finally, deeper investigation into the causal relationship between the PE-LIF inductive bias and the MPR-SG training method could yield even more stable and powerful spiking architectures.

Summary updated

BibTeX
@inproceedings{zhou2026positional,
  author = {Zijian Zhou and Yu Liang and Honglin Cao and Ammar Belatreche and Jieyuan Zhang and Wenjie Wei and Shuai Wang and Malu Zhang and Yang Yang and Haizhou Li},
  title = {{Positional Encoding for Spiking Transformers}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=tr8Qv2X5pq},
}
Figure