TL;DR
SpikeBERT adapts deep Spiking Neural Networks (SNNs) to natural language processing by restructuring the vision-based Spikformer architecture for text and training it via a two-stage knowledge distillation process from BERT. Across six English and Chinese text classification benchmarks, SpikeBERT outperforms prior SNN approaches and approaches BERT-level performance while slashing theoretical inference energy consumption by over 72% on neuromorphic hardware.
What Problem Does This Paper Address?
Large Transformer models achieve state-of-the-art NLP results at the expense of massive computational and electrical energy. Spiking Neural Networks (SNNs)—often called the third generation of neural networks—process and communicate information using discrete binary spikes ($0$ or $1$) over time steps. When deployed on specialized neuromorphic hardware (e.g., Intel Loihi, IBM TrueNorth), SNNs replace power-hungry floating-point multiply-and-accumulate (MAC) operations with lightweight additions (accumulate, or AC operations).
However, SNNs in NLP have historically been confined to shallow architectures like TextCNN. Directly training deep spiking Transformers with standard backpropagation through time (BPTT) and surrogate gradients suffers from vanishing or exploding gradients caused by "self-accumulating dynamics." Furthermore, bridging the gap between continuous floating-point features in pre-trained language models and discrete spatio-temporal spike trains in SNNs has remained an open challenge.
Methods
The authors tackle these challenges through two main contributions:
- Architecture Adaptation (Spikformer $\rightarrow$ SpikeBERT):
- Embedding Layer: Replaces vision-specific Spiking Patch Splitting (SPS) with a standard token embedding layer followed by a spiking neuron layer.
- Token-Level Spiking Self-Attention (SSA): Reshapes the attention map from $D \times D$ (feature dimension-wise) to $N \times N$ (sequence length-wise), capturing token-to-token interactions crucial for text.
- Linear & LayerNorm: Replaces 2D convolutions and batch normalization with linear layers and layer normalization.
- Leaky Integrate-and-Fire (LIF) Neurons: Uses LIF dynamics with an arctangent surrogate gradient function for backpropagation.
- Two-Stage Knowledge Distillation:
- Stage 1 (Pre-training Distillation): Using unlabelled text (Wikipedia + BookCorpus), student spike features are aligned with continuous BERT representations. Spikes across time steps $T$ are summed and projected via an MLP and LayerNorm before minimizing Mean Squared Error against teacher embeddings and chosen hidden layers.
- Stage 2 (Task-Specific Distillation): Using a fine-tuned BERT teacher on downstream tasks with data augmentation (token masking, POS substitution, n-gram sampling), the student is optimized with a composite loss combining feature alignment, embedding alignment, KL-divergence over soft output logits, and ground-truth cross-entropy.
Datasets
- Pre-training: English Wikipedia (
20220301.en) + BookCorpus; Chinese Wikipedia dump. - Downstream Benchmarks: Six sentiment and topic classification datasets across two languages:
- English: MR, SST-2, SST-5, Subj.
- Chinese: ChnSenti, Waimai.
- Evaluation Benchmark: GLUE benchmark (evaluated in the appendix).
Key Insights and Ideas
- Distillation Bypasses Optimization Traps: Training deep SNNs from scratch with masked language modeling (MLM) fails to converge. Distilling representations from an ANN teacher circumvents gradient accumulation instabilities.
- Aligning Temporal Spikes to Static Decimals: Accumulating student spikes across the temporal dimension $T$ prior to linear projection enables direct feature matching between discrete SNN spike trains and continuous ANN activations.
- Diminishing Returns of Temporal Depth: Increasing time steps improves performance up to $T = 4$; larger values ($T = 8, 12$) actually degrade accuracy on some datasets due to spike train noise accumulation.
- Surrogate Gradient Bottlenecks with Depth: SpikeBERT exhibits plateauing or declining accuracy when scaled from 12 to 18 layers, confirming that deeper spiking architectures introduce excess surrogate gradient noise.
Key Results
- Classification Accuracy: SpikeBERT achieves an average accuracy of 80.20% across the six benchmarks, outperforming the previous state-of-the-art SNN (SNN-TextCNN at 76.71%) and directly trained Spikformer (77.36%), while trailing fine-tuned BERT (84.33%) by only 4.13%.
- Energy Efficiency: On simulated 45nm neuromorphic hardware ($E_{\text{MAC}} = 4.6\text{ pJ}$, $E_{\text{AC}} = 0.9\text{ pJ}$), SpikeBERT requires only 27.82% of the energy needed by fine-tuned BERT (a 70.49% to 73.63% energy reduction per sample).
- Ablation Findings: Removing either distillation stage incurs an average accuracy drop of ~3.2%. Among loss components in Stage 2, omitting the soft logit distillation loss ($L_{\text{logits}}$) caused the largest drop (from 76.30% to 73.27%).
Limitations and Future Work
- Fine-Grained Language Tasks: SpikeBERT struggles on Natural Language Inference (QNLI, RTE, MNLI) and fails to converge on grammatical acceptability (CoLA) and semantic similarity (STS-B), suggesting discrete binary spikes struggle to encode fine-grained lexical nuances.
- GPU Memory Overhead: Training requires unfolding across time steps $T$, scaling GPU memory consumption by a factor of $T$ and constraining input sequence lengths.
- Evaluation Paradigms: The model is evaluated on conventional text datasets rather than native neuromorphic event-based language inputs. True hardware energy gains remain theoretical until end-to-end neuromorphic chip deployment is realized.
Summary updated