Mahalanobis-Based Multi-Head Attention for Complex State Propagation
Organizations: GuangDong Police College
Abstract
In this paper, we propose Mahalanobis-Based Multi-Head Attention (MHA-CSP), a novel attention mechanism that replaces the standard dot-product with a Mahalanobis distance-based RBF kernel, which effectively computes attention in an infinite-dimensional feature space without increasing the parameter count. Crucially, the positive definiteness of the Mahalanobis distance enables a direct construction of Tree Attention: attention scores are built directly from accumulated distances, with a LogSumExp correction that rectifies the raw distance by subtracting the log-sum of edge exponentials. Moreover, the multi-head Mahalanobis distance matrices are themselves repurposed to construct an attention meshing mechanism, enabling cross-head kernel collaboration that simultaneously boosts accuracy and training efficiency. Extensive experiments demonstrate that MHA-CSP, with only 119K parameters and teacher forcing applied exclusively at the final hidden state, consistently outperforms Transformer and GCN baselines trained from scratch under identical conditions on long-sequence state tracking tasks. While these baselines rely on dense attention or graph propagation, MHA-CSP achieves robust structured reasoning via synthetic distance rectification---powered by Mahalanobis-based attention---and efficient information bypass inherited from the CSP backbone. This result highlights the effectiveness of complex-valued state propagation with collaborative multi-head rectification in capturing symbolic structures, establishing a new efficiency-performance trade-off for structured reasoning.
Figures & tables
| Model | Parenthesis | Arithmetic+Repeat | Parity |
|---|---|---|---|
| LSTM | 12.4 1.8 | 8.7 2.1 | 62.3 1.2 |
| GRU | 15.6 1.2 | 11.2 1.8 | 65.1 0.8 |
| GDN | 22.1 1.4 | 18.3 1.5 | 78.4 0.5 |
| ARFormer | 38.7 1.0 | 32.1 1.2 | 91.2 0.3 |
| Vanilla CSP [ 26 ] | 99.8 0.06 | 30.8 2.3 | 100.0 0.0 |
| MHA-CSP (Ours) | 50.3 1.6 | 50.3 1.6 | 100.0 0.0 |
| Training Format | Airthetic Accuracy |
|---|---|
| Direct answer only (e.g., 8 ) | 34.7% |
| Answer with input copy (e.g., (3+5) mod 9 = 8 ) | 41.2% |
| Repeat format (e.g., 8 repeat (3+5) mod 9 = 8 ) | 50.3% |
| Model Variant | Parenthesis Accuracy |
|---|---|
| MHA-CSP (full) | 50.3% |
| w/o tree-structured accumulation | 41.8% |
| w/o LogSumExp correction | 44.2% |
| w/o confusion matrix (mean fusion instead) | 42.6% |
| w/o complex normalization | 38.1% |
Attention Mechanisms
Attention mechanisms let neural networks weight information from other tokens or regions according to relevance, enabling context-dependent processing.
See all 511 papers