[论文解读] Fine-Tuning Language Models with Just Forward Passes
本文介绍 MeZO,一种仅通过前向传播配合提示进行微调的方法,在显著降低内存使用的同时,能在各种模型规模和任务中接近完全微调的性能。它还实现零-shot、线性探测和 PEFT 的对比。
Fine-tuning language models (LMs) has yielded success on diverse downstream tasks, but as LMs grow in size, backpropagation requires a prohibitively large amount of memory. Zeroth-order (ZO) methods can in principle estimate gradients using only two forward passes but are theorized to be catastrophically slow for optimizing large models. In this work, we propose a memory-efficient zerothorder optimizer (MeZO), adapting the classical ZO-SGD method to operate in-place, thereby fine-tuning LMs with the same memory footprint as inference. For example, with a single A100 80GB GPU, MeZO can train a 30-billion parameter model, whereas fine-tuning with backpropagation can train only a 2.7B LM with the same budget. We conduct comprehensive experiments across model types (masked and autoregressive LMs), model scales (up to 66B), and downstream tasks (classification, multiple-choice, and generation). Our results demonstrate that (1) MeZO significantly outperforms in-context learning and linear probing; (2) MeZO achieves comparable performance to fine-tuning with backpropagation across multiple tasks, with up to 12x memory reduction and up to 2x GPU-hour reduction in our implementation; (3) MeZO is compatible with both full-parameter and parameter-efficient tuning techniques such as LoRA and prefix tuning; (4) MeZO can effectively optimize non-differentiable objectives (e.g., maximizing accuracy or F1). We support our empirical findings with theoretical insights, highlighting how adequate pre-training and task prompts enable MeZO to fine-tune huge models, despite classical ZO analyses suggesting otherwise.
研究动机与目标
- 提高大语言模型微调的效率,降低内存占用。
- 证明基于提示的前向仅优化可以近似全量微调的性能。
- 将 MeZO 与零-shot、情景学习、线性探测以及全量微调在不同模型规模和任务上进行比较。
提出的方法
- 使用提示将微调目标与预训练对齐,从而实现 zeroth-order 优化。
- 在中等规模的掩码语言模型(RoBERTa-large)和大型自回归语言模型(OPT-13B、30B、66B)上评估 MeZO。
- 在 MeZO 下比较全参数微调、LoRA 和前缀微调,与传统反向传播微调进行对比。
- 记录内存使用量和训练步骤,展示 MeZO 的内存节省与训练效率。
- 探索对不可微分目标(如准确率和 F1 得分)的优化。
实验结果
研究问题
- RQ1基于提示的前向传播微调目标是否在不同模型规模下近似全部参数微调的性能?
- RQ2就准确率和内存使用而言,MeZO 与零-shot、ICL、LP、FT 的比较如何?
- RQ3使用提示是否使 zeroth-order 优化在 NLP 微调中有效?
- RQ4在不同规模下使用 MeZO 时,训练步骤与内存节省之间的权衡是什么?
主要发现
- MeZO 在不同模型类型和任务上优于零-shot 和线性探测。
- MeZO 在某些配置(如 k=512)下,接近全量微调的性能,误差大约在 5% 内,同时显著降低内存使用。
- 与 FT 相比,MeZO 提供显著的内存节省,例如在所报道的实验中,OPT-13B 大约节省 12 倍。
- MeZO 支持对不可微分目标(如准确率和 F1 得分)进行优化。
- 实验包括中等规模的掩码语言模型和大型自回归语言模型,在少-shot 和多-shot 的情景中使用提示。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。