Preprint
Large Language Models

Relaxed Recursive Transformers

Sangmin Bae, Adam Fisch, Hrayr Harutyunyan, Zi-Wei Ji, Seungyeon Kim, Tal Schuster
October 28, 2024International Conference on Learning Representations139 citations

139

Citations

13

Influential Citations

International Conference on Learning Representations

Venue

2024

Year

Abstract

Large language models (LLMs) are expensive to deploy. Parameter sharing offers a possible path towards reducing their size and cost, but its effectiveness in modern LLMs remains fairly limited. In this work, we revisit"layer tying"as form of parameter sharing in Transformers, and introduce novel methods for converting existing LLMs into smaller"Recursive Transformers"that share parameters across layers, with minimal loss of performance. Here, our Recursive Transformers are efficiently initialized from standard pretrained Transformers, but only use a single block of unique layers that is then repeated multiple times in a loop. We further improve performance by introducing Relaxed Recursive Transformers that add flexibility to the layer tying constraint via depth-wise low-rank adaptation (LoRA) modules, yet still preserve the compactness of the overall model. We show that our recursive models (e.g., recursive Gemma 1B) outperform both similar-sized vanilla pretrained models (such as TinyLlama 1.1B and Pythia 1B) and knowledge distillation baselines -- and can even recover most of the performance of the original"full-size"model (e.g., Gemma 2B with no shared parameters). Finally, we propose Continuous Depth-wise Batching, a promising new inference paradigm enabled by the Recursive Transformer when paired with early exiting. In a theoretical analysis, we show that this has the potential to lead to significant (2-3x) gains in inference throughput.

Analysis

Why This Paper Matters

Large language models (LLMs) are notoriously expensive to deploy due to their massive parameter counts and computational requirements. While parameter sharing has long been explored as a compression technique, its effectiveness in modern LLMs has been limited. This paper revisits layer tying and introduces Recursive Transformers, a practical method to convert existing pretrained LLMs into smaller, parameter-shared versions with minimal performance loss. By enabling efficient initialization from standard models, the approach bridges the gap between theoretical compression and real-world applicability.

The significance lies in its potential to democratize LLM deployment. Recursive Transformers can reduce model size without sacrificing much accuracy, making it feasible to run powerful models on resource-constrained devices. Moreover, the proposed Continuous Depth-wise Batching inference paradigm, enabled by early exiting, promises 2-3x throughput gains, which could drastically lower serving costs for LLM providers.

Technical Contributions

  • Recursive Transformers: A method to convert pretrained Transformers into models that share a single block of layers repeated multiple times, initialized efficiently from the original model.
  • Relaxed Recursive Transformers: Introduction of depth-wise low-rank adaptation (LoRA) modules to relax the strict layer tying constraint, adding flexibility while preserving compactness.
  • Continuous Depth-wise Batching: A novel inference paradigm that leverages early exiting in recursive models to process inputs with varying computational depths in a single batch, theoretically improving throughput by 2-3x.
  • Empirical validation: Demonstrates that recursive models (e.g., recursive Gemma 1B) outperform similar-sized vanilla models (TinyLlama 1.1B, Pythia 1B) and knowledge distillation baselines, and recover most of the performance of the full-size model (Gemma 2B).

Results

The paper provides concrete comparisons: recursive Gemma 1B outperforms both TinyLlama 1.1B and Pythia 1B, and achieves performance close to Gemma 2B, despite having half the parameters. Knowledge distillation baselines are also surpassed, indicating the effectiveness of the recursive approach. The theoretical analysis of Continuous Depth-wise Batching suggests significant inference speedups (2-3x), though empirical validation of this paradigm is left for future work.

Significance

This work has broader implications for the AI field by offering a viable path to compress LLMs without retraining from scratch. The ability to convert existing models into recursive versions with minimal loss opens doors for deploying LLMs in edge devices and reducing inference costs. The introduction of Continuous Depth-wise Batching also points toward more efficient inference strategies that could be integrated into existing serving systems. As LLMs continue to grow, such parameter-sharing techniques and inference optimizations will be crucial for sustainable and accessible AI deployment.