MatFormer:用于弹性推理的嵌套Transformer
MatFormer: Nested Transformer for Elastic Inference
AI总结:
MatFormer通过嵌套FFN块结构,在标准Transformer中实现弹性推理,支持从单一模型提取多个不同尺寸的子模型,无需额外训练成本,并在语言和视觉任务中验证了其有效性,显著降低推理延迟。
摘要:
基础模型被广泛应用于具有不同推理约束的多种场景,从大规模多加速器集群到资源受限的独立移动设备。然而,训练这些模型所涉及的巨大成本通常限制了可提供的独特模型尺寸的数量。因此,实践者被迫选择可能与其特定延迟和成本要求并非最优匹配的模型。我们提出MatFormer,一种新颖的Transformer架构,旨在跨多种部署约束提供弹性推理。MatFormer通过将嵌套的前馈网络(FFN)块结构整合到标准Transformer模型中来实现这一点。在训练期间,我们优化多个不同尺寸的嵌套FFN块的参数,从而能够在不产生额外计算成本的情况下提取数百个精确的小型模型。我们通过实验验证了MatFormer在不同模型类别(解码器和编码器)和模态(语言和视觉)中的有效性,展示了其在实际部署中的潜力。我们展示了一个850M参数的仅解码器MatFormer语言模型(MatLM)使我们能够提取多个从582M到850M参数的小型模型,每个模型在验证损失和一次性下游评估方面均优于独立训练的对应模型。此外,我们观察到从基于MatFormer的通用ViT(MatViT)编码器中提取的小型编码器保留了度量空间结构,适用于自适应大规模检索。最后,我们展示了使用从MatFormer提取的准确且一致的子模型进行推测解码可以显著降低推理延迟。项目网站:https://devvrit.github.io/matformer/
英文摘要:
Foundation models are applied in a broad spectrum of settings with different inference constraints, from massive multi-accelerator clusters to resource-constrained standalone mobile devices. However, the substantial costs associated with training these models often limit the number of unique model sizes that can be offered. Consequently, practitioners are compelled to select a model that may not be optimally aligned with their specific latency and cost requirements. We present MatFormer, a novel Transformer architecture designed to provide elastic inference across diverse deployment constraints. MatFormer achieves this by incorporating a nested Feed Forward Network (FFN) block structure within a standard Transformer model. During training, we optimize the parameters of multiple nested FFN blocks with varying sizes, enabling the extraction of hundreds of accurate smaller models without incurring additional computational costs. We empirically validate the efficacy of MatFormer across different model classes (decoders and encoders) and modalities (language and vision), demonstrating its potential for real-world deployment. We show that a 850M decoder-only MatFormer language model (MatLM) allows us to extract multiple smaller models spanning from 582M to 850M parameters, each exhibiting better validation loss and one-shot downstream evaluations than independently trained counterparts. Furthermore, we observe that smaller encoders extracted from a universal MatFormer-based ViT (MatViT) encoder preserve the metric-space structure for adaptive large-scale retrieval. Finally, we showcase that speculative decoding with the accurate and consistent submodels extracted from MatFormer can lead to significant reduction in inference latency. Project website: https://devvrit.github.io/matformer/
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。