TL;DR
Taipan is a hybrid language model architecture that marries the constant-memory inference efficiency of State Space Models (specifically Mamba-2) with the precise recall capability of Transformers. By dynamically routing only a critical subset of tokens (~15%) through a Sliding Window Attention module with feature refinement, Taipan achieves state-of-the-art retrieval and commonsense reasoning while maintaining linear latency and extrapolating smoothly to context lengths of up to 1 million tokens.
What Problem Does This Paper Address?
Standard Transformers excel at capturing long-range dependencies, but their self-attention mechanism imposes a quadratic computational cost during training and demands linearly growing memory (the key-value cache) during inference. Conversely, recurrent State Space Models (SSMs) like Mamba-2 process sequences in linear time and operate with constant memory at test time.
However, pure SSMs rely on a Markovian state representation, which forces the model to compress entire contexts into a fixed-size hidden state. This creates an information bottleneck, leading to degraded performance on recall-intensive tasks (such as needle-in-a-haystack search, long-form document extraction, and multi-turn QA). Existing hybrids (like Jamba) insert standard full attention layers, but re-introduce significant memory overhead and struggle to extrapolate far beyond their training context window.
Methods
Taipan introduces Selective Attention Layers (SALs) interleaved within a backbone of Mamba-2 blocks at a ratio of 1 SAL per 6 Mamba-2 blocks:
[Input] -> [Mamba-2 x6] -> [SAL: Gating + Feature Refinement + SWA] -> [Mamba-2 x6] -> ...
- Differentiable Token Selection: A lightweight gating network $G_\theta$ evaluates each token representation $h_i$ to produce a 2D score vector $s_i$. Using the Straight-Through Gumbel-Softmax trick during training, the network generates a discrete binary mask $m_i \in \{0, 1\}$.
-
Feature Refinement & Representation Augmentation: For selected tokens ($m_i = 1$), Taipan computes mixing weights via $\text{softmax}(s_i) = [1 - \alpha_i, \alpha_i]$. The updated representation combines the original representation and the attention output: $$h_i^s = (1 - \alpha_i)h_i^s + \alpha_i o_i$$ This selectively filters out less useful features before injecting attention context. Unselected tokens completely bypass the attention module.
-
Sliding Window Attention (SWA) Without Positional Embeddings: Taipan uses SWA with a window size of $w = 2048$. Crucially, it completely removes positional embeddings from the attention module, preventing position-bias artifacts when extrapolating to unseen lengths.
- Attention Budget Constraint: A regularization loss term, $\mathcal{L}_{\text{constraint}} = \sum_{n=1}^N \left( C - \frac{\sum m_i}{L} \right)^2$, enforces a target budget capacity $C$ (set to 0.15, meaning only 15% of tokens trigger attention).
Datasets
- Pre-training Corpora: Tokenized with the LLaMA 3 tokenizer.
- 190M parameter model: Trained on 27B tokens from Cosmopedia-v2.
- 450M & 1.3B parameter models: Trained on 100B tokens across a mixture of FineWeb-Edu-dedup, Starcoderdata-Edu, OpenWebMath, NuminaMath-CoT, MetaMathQA, Orca-Math, Wikipedia, and Cosmopedia-v2.
- Evaluation Benchmarks:
- Zero-shot general tasks: Winogrande, PIQA, HellaSwag, ARC-e, ARC-c, OpenBookQA, TruthfulQA, RACE, BoolQ.
- In-context recall tasks: Structured extraction from HTML/PDFs (SWDE, FDA) and extractive QA (SQuAD).
- Extrapolation: Perplexity and latency benchmarks across sequence lengths from 1K to 1M tokens.
Key Insights and Ideas
- Not all tokens require attention: Most tokens in natural language exhibit local or sequential dependencies well-modeled by Mamba’s recurrent state. Restricting attention to just 15% of tokens does not hurt accuracy—in fact, it prevents noise accumulation.
- Removing Positional Embeddings unlocks massive length extrapolation: Removing RoPE/positional encodings from the attention layer prevents the attention weights from degrading out-of-distribution. Mamba-2 already preserves sequence order recurrently, allowing the attention module to serve purely as content-based retrieval up to 1M tokens without perplexity exploding.
- Feature refinement matters: Simply adding attention residuals directly can cause feature drift; scaling down the original representation by $(1 - \alpha_i)$ while adding $\alpha_i o_i$ sharpens retrieval fidelity.
Key Results
- Zero-Shot Accuracy: At the 1.3B parameter scale, Taipan achieves an average score of 53.3% across 9 benchmarks, outperforming Transformer++ (49.9%), pure Mamba-2 (51.7%), and Jamba (51.8%).
- Recall-Intensive Tasks: On in-context retrieval benchmarks (SWDE, FDA, SQuAD), 1.3B Taipan achieves an average score of 52.7%, dramatically surpassing pure Mamba (37.4%) and Jamba (46.5%), while closing the gap with full Transformer++ (56.6%).
- Extreme Long-Context & Latency: In perplexity evaluations from 1K to 1M tokens, Taipan remains flat and avoids the out-of-memory errors seen in full Transformers and Jamba. During generation, Taipan scales linearly with significantly lower latency than both Transformer++ and Jamba.
Limitations and Future Work
- Model Scale: The largest evaluated model is 1.3B parameters trained on 100B tokens. Validation at modern frontier scales (7B–70B+ parameters on trillions of tokens) remains to be demonstrated.
- Dynamic Budgeting: The budget parameter $C$ is currently fixed globally across layers and sequence types; dynamic, layer-adaptive, or prompt-dependent budgeting was not explored.
- Hardware Kernel Specialization: While theoretically linear, routing sparse, non-contiguous token queries through sliding-window attention kernels requires specialized GPU memory layouts and kernel fusions to reach peak hardware utilization.
Summary updated