Variance-reduced Zeroth-Order Methods for Fine-Tuning Language Models

Tanmay Gautam, Youngsuk Park, Hao Zhou, Parameswaran Raman, Wooseok Ha
4/11/2024
cs.LGcs.AIcs.CL

No official code found. Best implementation: amazon-science/mezo_svrg (12 stars, Apache-2.0, last commit 2024-06-25).

Abstract

Fine-tuning language models (LMs) has demonstrated success in a wide array of downstream tasks. However, as LMs are scaled up, the memory requirements for backpropagation become prohibitively high. Zeroth-order (ZO) optimization methods can leverage memory-efficient forward passes to estimate gradients. More recently, MeZO, an adaptation of ZO-SGD, has been shown to consistently outperform zero-shot and in-context learning when combined with suitable task prompts. In this work, we couple ZO methods with variance reduction techniques to enhance stability and convergence for inference-based LM fine-tuning. We introduce Memory-Efficient Zeroth-Order Stochastic Variance-Reduced Gradient (MeZO-SVRG) and demonstrate its efficacy across multiple LM fine-tuning tasks, eliminating the reliance on task-specific prompts. Evaluated across a range of both masked and autoregressive LMs on benchmark GLUE tasks, MeZO-SVRG outperforms MeZO with up to 20% increase in test accuracies in both full- and partial-parameter fine-tuning settings. MeZO-SVRG benefits from reduced computation time as it often surpasses MeZO's peak test accuracy with a $2\times$ reduction in GPU-hours. MeZO-SVRG significantly reduces the required memory footprint compared to first-order SGD, i.e. by $2\times$ for autoregressive models. Our experiments highlight that MeZO-SVRG's memory savings progressively improve compared to SGD with larger batch sizes.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Code the ICML 2024 paper: "Variance-reduced Zeroth-Order Methods for Fine-Tuning Language Models"

120Shell, PythonMay 28, 20242 years agoApache-2.0
deep-learningfine-tuninglanguage-modellarge-language-modelsllm-training+8 more

Similar Papers

Cite this paper

@article{gautam2024variancereduced,
  title  = {Variance-reduced Zeroth-Order Methods for Fine-Tuning Language Models},
  author = {Tanmay Gautam and Youngsuk Park and Hao Zhou and Parameswaran Raman and Wooseok Ha},
  year   = {2024},
  eprint = {2404.08080},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2404.08080v1},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2404.08080.svg)](https://codeofpaper.com/paper/2404.08080)

Discussion