Skip to main content
Back

AI21 Labs' Jamba Proves Transformers Don't Need Attention at Every Layer

AI21 Labs open-sourced Jamba, a hybrid Transformer-Mamba-MoE model with a 256K context that runs 3x faster than similar Transformers.

Pro

  • AI21 released Jamba-v0.1, the first production-scale hybrid Transformer-Mamba-MoE model, under Apache 2.0.
  • 52B total parameters, 12B active at inference, 256K context window, fits 140K tokens on one 80GB GPU.
  • Delivers 3x throughput over Mixtral 8x7B on long-context workloads thanks to Mamba's linear-time layers.
  • Architecture uses a 1:7 attention-to-Mamba ratio with MoE layers applied every other block.
  • Competitive benchmarks: 67.4% MMLU, 87.1% HellaSwag, 59.9% GSM8K, matching similarly-sized Transformers.
  • Base model only, not instruction-tuned or safety-aligned; see the paper for details.

AI21 Labs has released a production-scale model built on the Mamba state-space architecture, blended with Transformer attention and mixture-of-experts routing. Jamba-v0.1 ships under Apache 2.0, weighs in at 52B total parameters with 12B active at inference, and handles a 256K context window while fitting up to 140K tokens on a single 80GB GPU.

For months, the open-source community has debated whether state-space models could replace attention at scale. Jamba sidesteps the framing entirely by alternating Transformer and Mamba layers inside a single 52B-parameter network, offering the first serious evidence that pure attention is not the only viable path to a strong LLM at scale.

Why hybridize the stack

Transformer attention scales quadratically with sequence length, which is what makes long contexts expensive in memory and compute. State-space models like Mamba scale linearly and carry a small, constant memory footprint per token, but on their own they struggle with tasks that demand precise recall across the context. Jamba's wager is that you can sprinkle attention in sparingly for recall and in-context learning, and let Mamba handle the rest.

Multiple independent research groups have reached the same empirical answer: you can use far fewer attention layers than intuition suggests, with a small quality hit and a large efficiency gain. AI21 landed on a 1:7 ratio after ablations, meaning one Transformer layer for every seven Mamba layers.

Inside a Jamba block

The core unit is what AI21 calls a Jamba block. Each block contains either an attention or a Mamba layer, followed by a multi-layer perceptron (MLP), yielding an overall ratio of one Transformer layer for every eight total layers. Mixture-of-experts is layered on top to expand capacity without inflating the compute bill.

Three design choices define the architecture:

  • Attention-to-Mamba ratio of 1:7. This hits a sweet spot: most of attention's quality benefit, most of Mamba's memory benefit. Going further (fewer attention layers) shows diminishing memory savings alongside rising quality loss.
  • MoE every other layer. The reference implementation uses l=8, a 1:7 attention-to-Mamba ratio, and MoE applied every e=2 layers.
  • Sparse activation. MoE inflates total parameter count while keeping active parameters modest at inference, so capacity grows without a matching jump in compute.

The payoff is concrete. Jamba delivers 3x throughput on long contexts against Transformer-based models of similar size, such as Mixtral 8x7B, and it is the only model in its class that can hold a 140K-token context on a single 80GB GPU when loaded in 8-bit.

How it performs

Jamba is a pretrained base model, not instruction-tuned, but the raw benchmark numbers hold their own against dense Transformers in the same size class:

BenchmarkScore
HellaSwag87.1%
Arc Challenge64.4%
WinoGrande82.5%
PIQA83.2%
MMLU67.4%
BBH45.4%
TruthfulQA46.4%
GSM8K (CoT)59.9%

The Jamba paper reports that these results hold up alongside vanilla Transformers of comparable size while using dramatically less memory at long sequence lengths, with strong scores extending to 256K tokens.

Getting it running

Jamba is available directly through the Hugging Face transformers library. You will want transformers 4.40 or higher, plus mamba-ssm and causal-conv1d for the optimized kernels. Running without them works but is significantly slower.

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
    "ai21labs/Jamba-v0.1",
    torch_dtype=torch.bfloat16,
    attn_implementation="flash_attention_2",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("ai21labs/Jamba-v0.1")

To fit the full 256K window on smaller hardware, AI21 recommends 8-bit quantization with the Mamba blocks skipped to preserve quality. That configuration is what unlocks the 140K-token single-GPU claim. The model also works with vLLM and SGLang for serving, and PEFT/LoRA for fine-tuning, which the model card demonstrates with a roughly 120GB GPU RAM footprint on 2xA100 80GB.

Strengths and rough edges

The strengths line up with what a hybrid should deliver:

  • Long-context throughput and memory efficiency
  • General knowledge and commonsense reasoning benchmarks in the mid-teens billions active-parameter range
  • A workable foundation for custom instruct or domain-specific fine-tunes

The weaknesses are equally clear. As a base model, Jamba is meant as a foundation layer for fine tuning, training, and developing custom solutions. It ships without safety moderation, so guardrails must be added for responsible deployment. Out of the box it will not follow instructions or refuse harmful prompts, and it is not aligned for chat. AI21 has since shipped instruction-tuned successors in the Jamba 1.5 family for those use cases.

Where this leaves the field

Until this release, Mamba lived mostly in research demos at the sub-3B scale. The open-source community kept asking whether SSMs could replace attention in a serious model, and the honest answer was "we don't know yet." Jamba is the first data point at production scale, and the fact that it arrives as an MoE under Apache 2.0 makes it broadly reusable.

The release also signals a strategic pivot for AI21. Earlier models like Jurassic were unified Transformers and shipped under proprietary licenses. Jamba is an open-source model under Apache 2.0, and the lab that spent years building closed systems is now betting that opening a novel architecture is the fastest way to make it stick.

Assumptions worth updating

Several things the field took as roughly settled look different after Jamba:

  1. Attention at every layer is optional. A 1:7 ratio held up in ablations and has since been validated by follow-up hybrid architectures.
  2. Mamba is production-viable. The "cool but experimental" label no longer fits. AI21 has already scaled the same recipe to 398B total parameters with 94B active in Jamba 1.5.
  3. Long context need not be a memory nightmare. Linear-time layers change the economics of 100K-plus token workloads.
  4. Architecture design is back on the table. After years of "just scale the Transformer," mixing model families has become a serious axis of exploration.

For anyone building retrieval-augmented systems, long-document summarization pipelines, or agents that chew through large tool traces, Jamba is worth benchmarking against your current Transformer stack. The base model is no drop-in ChatGPT replacement, but as a foundation to fine-tune, it opens throughput budgets that were previously locked behind much larger GPU bills.