Relaxed Recursive Transformers: Effective Parameter Sharing with Layer-wise LoRA

LLM LoRA/Adapter MQIA
大型语言模型(LLM)的部署成本高昂。参数共享提供了一种可能的途径来减少其规模和成本,但在现代LLM中的效果仍然相当有限。在这项工作中,我们重新审视了“层绑定”作为Transformer中的一种参数共享形式,并引入了新的方法,将现有的LLM转换为更小的“递归Transformer”,这些模型在层间共享参数,同时性能损失最小。在这里,我们的递归Transformer从标准预训练Transformer高效初始化,但仅使用一个独特的层块,该层块在循环中多次重复使用。我们进一步通过引入放松的递归Transformer来提高性能,这种模型通过深度低秩适应(LoRA)模块为层绑定约束增加了灵活性,但仍保持了整体模型的紧凑性。我们展示了我们的递归模型(例如,递归Gemma 1B)不仅超过了类似规模的普通预训练模型(如TinyLlama 1.1B和Pythia 1B)和知识蒸馏基线模型,甚至可以恢复大部分原始“全尺寸”模型(例如,没有共享参数的Gemma 2B)的性能。最后,我们提出了连续深度批处理,这是一种由递归Transformer结合提前退出所启用的新推理范式。在理论分析中,我们表明这有可能显著提高(2-3倍)推理吞吐量。
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.
许愿