[Paper Review] Fine-Tuning Language Models with Just Forward Passes
The paper introduces MeZO, a fine-tuning approach that uses only forward passes with prompts to closely match full fine-tuning performance while significantly reducing memory usage, across model sizes and tasks. It also enables zero-shot, linear probing, and PEFT comparisons.
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.
Motivation & Objective
- Motivate efficient fine-tuning of large language models with reduced memory footprint.
- Demonstrate that prompt-based forward-only optimization can approximate full fine-tuning performance.
- Compare MeZO against zero-shot, in-context learning, linear probing, and full fine-tuning across model sizes and tasks.
Proposed method
- Use prompts to align the fine-tuning objective with pre-training, enabling zeroth-order optimization.
- Evaluate MeZO across medium-sized masked LMs (RoBERTa-large) and large autoregressive LMs (OPT-13B, 30B, 66B).
- Compare full-parameter fine-tuning, LoRA, and prefix-tuning under MeZO versus traditional backpropagation fine-tuning.
- Record memory usage and training steps, showing MeZO’s memory savings and training efficiency.
- Explore optimization with non-differentiable objectives such as accuracy and F1 score.
Experimental results
Research questions
- RQ1Can a prompt-based forward-pass fine-tuning objective approximate full parameter fine-tuning performance across model sizes?
- RQ2How does MeZO compare to zero-shot, ICL, LP, and FT in terms of accuracy and memory usage?
- RQ3Does using prompts enable zeroth-order optimization to be effective for NLP fine-tuning?
- RQ4What is the trade-off between training steps and memory savings when using MeZO at different scales?
Key findings
- MeZO outperforms zero-shot and linear probing across model types and tasks.
- MeZO approaches full fine-tuning performance, within about 5% for certain configurations (e.g., k=512) while using significantly less memory.
- MeZO provides substantial memory savings compared to FT, e.g., around 12× on OPT-13B in reported experiments.
- MeZO supports optimization of non-differentiable objectives such as accuracy and F1 score.
- Experiments include both medium-sized masked LMs and large autoregressive LMs across few-shot and many-shot settings with prompts.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.