arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.18824cs.CLcs.LG
收藏

通过 Token 选择实现 Transformer 的内存高效微调

Memory-Efficient Fine-Tuning of Transformers via Token Selection

Meta AI

Antoine Simoulin, Namyong Park, Xiaoyi Liu, Grey Yang

AI总结:

本文提出 TokenTune 方法,通过仅对部分输入 token 反向传播并缓存其中间激活值,大幅降低 Transformer 模型微调的内存开销,且可与 LoRA 等方法结合,在数十亿参数模型的少样本任务中达到与全量微调相当的性能。

摘要:

微调提供了一种有效手段,使预训练模型能够专用于各种下游任务。然而,微调通常会产生很高的内存开销,特别是对于大型基于 Transformer 的模型,如 LLMs。虽然现有方法可以减少微调所需内存的某些部分,但它们仍然需要缓存前向传播中计算出的所有中间激活值,以便在反向传播期间更新权重。在这项工作中,我们开发了 TokenTune,这是一种减少基于 Transformer 的模型微调过程中内存使用的方法,特别是减少存储中间激活值的内存。在反向传播期间,TokenTune 仅通过一部分输入 token 进行反向传播来近似计算梯度。因此,使用 TokenTune 时,在前向传播期间仅缓存一部分中间激活值。此外,TokenTune 可以轻松地与 LoRA 等现有方法结合,进一步降低内存成本。我们在具有多达数十亿参数的预训练 Transformer 模型上评估了我们的方法,考察了在少样本学习设置下在文本分类和问答等多个下游任务上的性能。总体而言,TokenTune 实现了与全量微调或代表性内存高效微调方法相当的性能,同时大大减少了内存占用,特别是当与其他具有互补内存减少机制的方法结合使用时。我们希望我们的方法能促进大型 Transformer 的微调,使其专用于特定领域,或与更大系统中的其他神经组件进行协同训练。我们的代码可在 https://github.com/facebookresearch/tokentune 获取。

英文摘要:

Fine-tuning provides an effective means to specialize pre-trained models for various downstream tasks. However, fine-tuning often incurs high memory overhead, especially for large transformer-based models, such as LLMs. While existing methods may reduce certain parts of the memory required for fine-tuning, they still require caching all intermediate activations computed in the forward pass to update weights during the backward pass. In this work, we develop TokenTune, a method to reduce memory usage, specifically the memory to store intermediate activations, in the fine-tuning of transformer-based models. During the backward pass, TokenTune approximates the gradient computation by backpropagating through just a subset of input tokens. Thus, with TokenTune, only a subset of intermediate activations are cached during the forward pass. Also, TokenTune can be easily combined with existing methods like LoRA, further reducing the memory cost. We evaluate our approach on pre-trained transformer models with up to billions of parameters, considering the performance on multiple downstream tasks such as text classification and question answering in a few-shot learning setup. Overall, TokenTune achieves performance on par with full fine-tuning or representative memory-efficient fine-tuning methods, while greatly reducing the memory footprint, especially when combined with other methods with complementary memory reduction mechanisms. We hope that our approach will facilitate the fine-tuning of large transformers, in specializing them for specific domains or co-training them with other neural components from a larger system. Our code is available at https://github.com/facebookresearch/tokentune.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑