Skip to main content
QUICK REVIEW

[Paper Review] Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models

Aviv Bick, Kevin Y. Li|arXiv (Cornell University)|Aug 19, 2024
Topic ModelingComputer Science3 citations
TL;DR

This paper proposes MOHAWK, a three-phase distillation framework that transfers knowledge from a large, quadratic-time Transformer (Phi-1.5) to subquadratic state space models (SSMs), such as Mamba-2, by progressively aligning mixing matrices, hidden states, and final predictions. Despite using only 3B tokens—less than 1% of the data used to train the teacher model—Phi-Mamba achieves state-of-the-art performance among open-source non-Transformer models, outperforming prior SSMs on multiple benchmarks.

ABSTRACT

Transformer architectures have become a dominant paradigm for domains like language modeling but suffer in many inference settings due to their quadratic-time self-attention. Recently proposed subquadratic architectures, such as Mamba, have shown promise, but have been pretrained with substantially less computational resources than the strongest Transformer models. In this work, we present a method that is able to distill a pretrained Transformer architecture into alternative architectures such as state space models (SSMs). The key idea to our approach is that we can view both Transformers and SSMs as applying different forms of mixing matrices over the token sequences. We can thus progressively distill the Transformer architecture by matching different degrees of granularity in the SSM: first matching the mixing matrices themselves, then the hidden units at each block, and finally the end-to-end predictions. Our method, called MOHAWK, is able to distill a Mamba-2 variant based on the Phi-1.5 architecture (Phi-Mamba) using only 3B tokens and a hybrid version (Hybrid Phi-Mamba) using 5B tokens. Despite using less than 1% of the training data typically used to train models from scratch, Phi-Mamba boasts substantially stronger performance compared to all past open-source non-Transformer models. MOHAWK allows models like SSMs to leverage computational resources invested in training Transformer-based architectures, highlighting a new avenue for building such models.

Motivation & Objective

  • To enable subquadratic models like Mamba-2 to leverage the knowledge from large, pre-trained quadratic Transformers.
  • To address the performance gap between SSMs and Transformers by transferring knowledge from high-resource, high-quality pretraining.
  • To develop a distillation method that progressively transfers knowledge at multiple levels of granularity: matrix-level, hidden-state, and end-to-end.
  • To demonstrate that SSMs can match or exceed the performance of larger, more data-intensive SSMs when distilled from a strong teacher model.
  • To validate that matrix approximation quality (via Frobenius distance) correlates with downstream performance, guiding model design.

Proposed method

  • The method, called MOHAWK, uses a three-stage distillation process: (1) matrix orientation to align sequence mixing matrices between teacher and student, (2) hidden-state alignment to match intermediate representations layer-by-layer, and (3) end-to-end fine-tuning with knowledge distillation.
  • The framework treats both Transformers and SSMs as sequence mixers that apply structured matrices over token sequences, enabling direct comparison and alignment of their mixing mechanisms.
  • Matrix-level distillation minimizes the Frobenius distance between the attention matrices of the teacher (Transformer) and the SSM’s state transition matrices.
  • Hidden-state distillation uses contrastive or distillation loss to align the hidden representations of corresponding layers in the teacher and student networks.
  • End-to-end distillation fine-tunes the student model using a combination of knowledge distillation and standard language modeling objectives.
  • The approach is applied to a modified Mamba-2 architecture (Phi-Mamba), which is designed to mirror the block structure of the Phi-1.5 Transformer for direct comparison.
Figure 1 : Plot of trained token budget to averaged accuracy on Winogrande, Arc-E, Arc-C, PIQA, and Hellaswag on various open-source models (mainly non-Transformer-based models). Our model (Phi-Mamba) uses more than $33\times$ less token budget to achieve 5% higher average accuracy than the next bes
Figure 1 : Plot of trained token budget to averaged accuracy on Winogrande, Arc-E, Arc-C, PIQA, and Hellaswag on various open-source models (mainly non-Transformer-based models). Our model (Phi-Mamba) uses more than $33\times$ less token budget to achieve 5% higher average accuracy than the next bes

Experimental results

Research questions

  • RQ1Can a subquadratic state space model (SSM) like Mamba-2 be effectively trained by distilling knowledge from a large, pre-trained Transformer model?
  • RQ2Does progressive, multi-level distillation—targeting matrices, hidden states, and final outputs—yield better performance than direct end-to-end distillation?
  • RQ3To what extent does the quality of matrix approximation (measured by Frobenius distance) correlate with downstream model performance?
  • RQ4Can a hybrid model with only four attention layers and the rest replaced by SSMs match or exceed the performance of the full Transformer?
  • RQ5Can a model trained on significantly less data (e.g., 3B tokens) outperform models trained from scratch on larger datasets?

Key findings

  • Phi-Mamba, distilled using only 3B tokens, achieves 71.7% accuracy on Winogrande, outperforming the original Mamba-2 model (60.9%) and all prior open-source non-Transformer models.
  • On the ARC-C benchmark, Phi-Mamba reaches 44.1% accuracy, compared to 33.3% for the original Mamba-2, demonstrating a significant performance gain from distillation.
  • The hybrid Phi-Mamba model, with four attention layers and 20 Mamba layers, achieves an average accuracy of 66.0% across benchmarks, closely matching Phi-1.5’s 67.2% despite using less data and fewer attention layers.
  • Ablation studies show that each stage of MOHAWK contributes significantly: skipping matrix or hidden-state distillation leads to substantial performance drops, confirming the necessity of the multi-stage approach.
  • A strong correlation is observed between the Frobenius distance of the approximated mixing matrices and downstream performance, validating that better matrix approximation leads to better model behavior.
  • Even when trained on the lower-quality C4 dataset, Phi-Mamba outperforms Samba, a larger model trained on the higher-quality Phi-2 dataset, indicating the effectiveness of distillation from a strong teacher.
Figure 2 : The Phi-Mamba architecture consists of a stack of blocks, each of which contains a Mamba block and an MLP block. The Mamba block is a simplified version of the Mamba-2 block [ 8 ] that omits the non-linear activation function after the convolutional operation, as well as the layer normali
Figure 2 : The Phi-Mamba architecture consists of a stack of blocks, each of which contains a Mamba block and an MLP block. The Mamba block is a simplified version of the Mamba-2 block [ 8 ] that omits the non-linear activation function after the convolutional operation, as well as the layer normali

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.