Skip to main content
QUICK REVIEW

[Paper Review] Samba: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modeling

Liliang Ren, Yang Liu|arXiv (Cornell University)|Jun 11, 2024
Topic ModelingComputer Science7 citations
TL;DR

Samba jointly integrates Mamba (a selective State Space Model) with Sliding Window Attention to achieve unlimited context length with linear-time complexity, delivering strong performance across benchmarks and substantial throughput gains.

ABSTRACT

Efficiently modeling sequences with infinite context length has long been a challenging problem. Previous approaches have either suffered from quadratic computational complexity or limited extrapolation ability in length generalization. In this work, we present Samba, a simple hybrid architecture that layer-wise combines Mamba, a selective State Space Model (SSM), with Sliding Window Attention (SWA). Samba selectively compresses a given sequence into recurrent hidden states while still maintaining the ability to precisely recall recent memories with the attention mechanism. We scale Samba up to 3.8B parameters with 3.2T training tokens and demonstrate that it significantly outperforms state-of-the-art models across a variety of benchmarks. Pretrained on sequences of 4K length, Samba shows improved perplexity in context lengths of up to 1M in zero-shot. When finetuned on 4K-length sequences, Samba efficiently extrapolates to a 256K context length with perfect memory recall on the Passkey Retrieval task, and exhibits superior retrieval extrapolation on the challenging Phonebook task compared to full-attention models. As a linear-time sequence model, Samba achieves a 3.73x higher throughput compared to Transformers with grouped-query attention for user prompts of 128K length, and a 3.64x speedup when generating 64K tokens with unlimited streaming. Our code for training on open source data is publicly available at https://github.com/microsoft/Samba.

Motivation & Objective

  • Motivate efficient language modeling that extrapolates beyond training context length.
  • Propose a simple hybrid architecture that combines SSMs and attention in a layerwise fashion.
  • Demonstrate scalability to multi-billion parameter models with long-context capabilities.
  • Evaluate performance across diverse tasks including reasoning, math, coding, and long-context retrieval.
  • Analyze training and inference efficiency, and ablation studies to understand the hybrid design.

Proposed method

  • Introduce Samba, a layerwise hybrid of Mamba (SSM) and Sliding Window Attention (SWA).
  • Use Mamba layers to capture time-dependent semantics via input-dependent selective state spaces.
  • Incorporate SWA with a 2048 window to enable precise memory retrieval within a linear-time framework.
  • Leverage SwiGLU MLPs for nonlinear transformations and separate MLPs for different information streams.
  • Train 421M, 1.3B, 1.7B, and 3.8B param models on up to 3.2T tokens and evaluate on diverse benchmarks.
  • Perform efficient long-context extrapolation tests (up to 256K prompts and 1M context) and throughput comparisons.
(a) Perplexity on the test set of Proof-Pile
(a) Perplexity on the test set of Proof-Pile

Experimental results

Research questions

  • RQ1Can a simple layerwise hybrid of an input-dependent SSM and sliding window attention achieve unlimited context length with linear time complexity?
  • RQ2How does Samba compare to pure attention and pure SSM models across long-context and short-context benchmarks?
  • RQ3What architectural choices (e.g., distribution of attention vs. recurrence) yield best performance and efficiency for long-context language modeling?
  • RQ4To what extent can memory recall and retrieval be preserved or enhanced when extrapolating context length?
  • RQ5What are the efficiency and throughput implications for prompt processing and generation?

Key findings

  • Samba achieves state-of-the-art average performance across a broad suite of benchmarks versus strong open-source LLMs up to 8B params.
  • The 3.8B Samba model attains high scores on MMLU (71.2) and GSM8K (69.6) and strong HumanEval (54.9) on 4K-training-length pretraining.
  • Samba demonstrates near-perfect memory recall and effective extrapolation up to 256K context after minimal fine-tuning, and up to 1M context for perplexity improvements on Proof-Pile.
  • Throughput benefits: Samba provides about 3.73x higher prompt-processing throughput than Llama-3 1.6B at 128K prompts and 3.64x speedup for 64K-token generation with streaming.
  • Samba maintains linear time complexity and outperforms SWA-only or pure-attention baselines on long-context tasks and downstream long-context summarization after instruction tuning.
  • Ablations indicate that hybridizing Mamba with SWA yields the best performance across tasks, while reducing attention heads can still retain and even improve performance.
(b) Decoding throughput with a batch size of 16
(b) Decoding throughput with a batch size of 16

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.