Keyword Mamba: Efficient Keyword Spotting Architecture
- Keyword Mamba is a spoken keyword spotting architecture that applies selective, bidirectional state-space modeling to efficiently process MFCC-based speech features.
- It replaces traditional self-attention in Transformers with a Mamba block, yielding linear-time complexity and high accuracy on Google Speech Commands benchmarks.
- The model achieves strong performance with fewer parameters and supports efficient deployment on edge devices and voice assistants.
Keyword Mamba is a spoken keyword spotting architecture that applies the Mamba neural state space model along the time axis of speech features and also explores replacing the self-attention part in Transformer models. In the reported formulation, it operates on MFCC sequences, uses bidirectional Mamba encoders for contextual aggregation, and attains strong accuracy with fewer parameters and lower computational cost on Google Speech Commands benchmarks. The work states that, to its knowledge, this is the first time a state space model has been used for keyword spotting (Ding et al., 10 Aug 2025).
1. Research context and problem setting
Keyword spotting (KWS) is described as an essential task in speech processing and is widely used in voice assistants and smart devices. The motivating claim behind Keyword Mamba is that CNNs, RNNs, and Transformers have all performed well in KWS, but often struggle to handle long-term patterns and stay efficient at the same time; Mamba is introduced as a selective state space model intended to retain long-range temporal structure while avoiding the quadratic cost of self-attention (Ding et al., 10 Aug 2025).
Within speech and audio research more broadly, this model sits inside a wider shift toward selective SSMs. A broader speech study reported that bidirectional Mamba consistently outperforms vanilla Mamba and is effective as an alternative to the self-attention module in Transformer-style architectures, particularly for semantic-aware tasks (Zhang et al., 2024). In self-supervised audio representation learning, SSAMBA introduced a self-supervised, attention-free, and SSM-based audio model and evaluated it on keyword spotting among other downstream tasks, indicating that Mamba-based sequence modeling was already becoming relevant to audio classification pipelines before Keyword Mamba specialized the approach to spoken KWS (Shams et al., 2024).
This suggests that Keyword Mamba should be understood less as an isolated architecture than as a task-specific instantiation of bidirectional selective SSM design for speech.
2. Selective state-space formulation
Keyword Mamba begins from the continuous-time linear state-space model
Because keyword spotting operates on discrete audio frames, the model applies zero-order hold discretization with step size ,
and then uses the discrete-time recurrence
Unrolling this recurrence over a length- input yields a global convolutional kernel
The specifically Mamba-like step is the selective parameterization: , , and are made input-dependent through small selection networks,
Here 0 and 1 are learned linear projections, 2 broadens to match the hidden dimension, and 3 such as softplus ensures stability (Ding et al., 10 Aug 2025).
The architectural consequence is that long-range temporal mixing is implemented by a linear-time scan rather than an 4 attention matrix. In the paper’s own complexity discussion, Mamba layers are 5 in sequence length, whereas self-attention is 6 (Ding et al., 10 Aug 2025).
3. Model architecture
The front end computes a 40-dimensional MFCC representation with a 7 window and 8 hop, then zero-pads or truncates to 9. Each time step is treated as one patch of size 0, projected with 1, combined with a learnable positional embedding of size 2, and augmented by a 3 class token inserted in the centre of the sequence (Ding et al., 10 Aug 2025).
Two encoder families are studied. The pure Mamba variant is denoted KWM. The hybrid variant, KWM-T, replaces the multi-head self-attention block in a Transformer layer with the same bidirectional Mamba block and then keeps the second LayerNorm plus feed-forward network with GELU, two linear layers, and residual connection. For the commonly reported configuration 4 and 5, parameter counts are 3.4 M for KWM, 5.2 M for KWM-T, and 5.36 M for the 12-layer pure Transformer baseline KWT-3 (Ding et al., 10 Aug 2025).
Inside each pure Mamba layer, LayerNorm is followed by two linear heads that produce 6. Forward and backward streams then apply Conv1D, SiLU, and linear projections that generate 7, run the SSM convolution, and gate the result with 8. The two directions are summed, projected out, and added residually. The use of both directions is central: the model is explicitly designed as a bidirectional Mamba encoder rather than a causal scan-only network (Ding et al., 10 Aug 2025).
A salient architectural feature is that Mamba is applied strictly along the time axis. The paper’s own discussion interprets the resulting state-space convolutional kernels as very long 1D convolutions, which are naturally suited to the temporal patterns of spoken keywords (Ding et al., 10 Aug 2025).
4. Training regime and benchmark results
Training uses Google Speech Commands v1 and v2 in both reduced-label and full-label settings: v1 (12- and 30-way) and v2 (12- and 35-way). The reported split is 80/10/10 train/validation/test. Augmentation includes time-shift in 9, resample in 0, random background noise with volume 0.1, and SpecAugment with two time masks of length 1 and two frequency masks of length 2. Optimization uses AdamW with initial learning rate 3, cosine decay with 10-epoch linear warm-up, weight decay 4, batch size 5, and 200 epochs on v1 and 140 on v2; the loss is cross-entropy (Ding et al., 10 Aug 2025).
For the principal 6 models, the pure Mamba system already matches or exceeds larger Transformer baselines with fewer parameters, and the hybrid Mamba-Transformer gives small additional gains. The paper also states that small-footprint variants with 7 and 8 still outperform most CNN and RNN baselines (Ding et al., 10 Aug 2025).
| Model | v1-12 | v1-30 |
|---|---|---|
| BC-ResNet-8 | 98.0 | 97.5 |
| KWT-3 | 97.5 | 96.8 |
| KWM-192 | 98.01 | 97.73 |
| KWM-T-192 | 98.05 | 97.80 |
| Model | v2-12 | v2-35 |
|---|---|---|
| BC-ResNet-8 | 98.7 | 97.7 |
| KWT-3 | 98.6 | 97.7 |
| KWM-192 | 98.79 | 97.86 |
| KWM-T-192 | 98.91 | 97.89 |
These numbers place the pure Mamba model slightly above the Transformer baseline in all four reported settings and place the hybrid variant marginally higher again. The strongest result in the table is KWM-T-192 on Speech Commands v2 12-way, at 98.91%. The parameter comparison is also notable: KWM-192 uses 3.40 M parameters against 5.36 M for KWT-3 (Ding et al., 10 Aug 2025).
5. Ablation findings and architectural sensitivities
The ablation study isolates three design choices: patch shape, class-token placement, and directionality. Temporal patches of size 9 are reported as the best patching strategy, reaching 98.01% on v1-12, while hybrid and frequency patches drop by 0.2–0.5 percentage points. The class token performs best when inserted in the middle of the sequence rather than at the head or end. Most strikingly, bidirectionality is not a minor refinement but an essential component of the reported performance profile (Ding et al., 10 Aug 2025).
| Factor | Option | v1-12 |
|---|---|---|
| Patch shape | Temporal=0 | 98.01 |
| Class-token position | Mid | 98.01 |
| Class-token position | Head | 97.75 |
| Class-token position | End | 97.92 |
| Mamba directionality | BiMamba-Bi-Bi | 98.01 |
| Mamba directionality | BiMamba-Fo-Bi | 97.69 |
| Mamba directionality | Mamba-Fo-Fo | 78.29 |
The causal-only setting loses more than 20 percentage points relative to the fully bidirectional setting. In the paper’s own summary, bidirectional SSM plus convolution is essential, and purely causal scanning is inadequate for full-utterance KWS (Ding et al., 10 Aug 2025).
A plausible implication is that Keyword Mamba’s strongest contribution is not merely the substitution of one sequence block for another, but the combination of time-axis tokenization, centred class-token aggregation, and explicitly bidirectional selective scanning.
6. Efficiency, deployment, and relation to broader audio Mamba work
The paper’s computational argument is straightforward: Mamba layers scale as 1 in sequence length, whereas self-attention scales as 2. In the reported implementation, this translated into an observed 3 speed-up on CPU relative to a same-sized Transformer, attributed to the combination of 1D convolution and SSM scan (Ding et al., 10 Aug 2025).
Separate deployment work strengthens the relevance of Mamba-based KWS for constrained devices. MambaLite-Micro reported a fully C-based runtime-free inference engine for Mamba inference on microcontrollers, reduced peak memory by 83.0%, maintained an average numerical error of only 4 relative to PyTorch, and achieved 100% prediction consistency with the PyTorch baselines on Speech Commands v2 3-class and 10-class tasks. Reported embedded measurements were 235 620 B peak RAM and 1133.2 ms latency on ESP32S3, and 282 932 B peak RAM and 934.9 ms latency on STM32H7 (Xu et al., 5 Sep 2025).
Broader audio evidence is supportive but not uniformly monotone. SSAMBA, a self-supervised audio Mamba model, outperformed SSAST in most tasks and reported keyword spotting accuracies of 96.4% and 96.9% on Speech Commands V1 for its small and base models, with 96.3% and 97.4% on V2, while also reporting that its tiny model lagged SSAST-tiny on V2. For long-input inference at 22k tokens, SSAMBA-tiny was reported as 92.7% faster and used 46 MB rather than 1024 MB of peak GPU memory (Shams et al., 2024).
Taken together, these results characterize Keyword Mamba as part of a broader technical trajectory: selective SSMs are being used not only to replace attention in speech models, but to make keyword spotting architectures simultaneously accurate, parameter-efficient, and increasingly plausible for edge deployment.