Zeroth-Order Fine-Tuning of LLMs in Random Subspaces

Ziming Yu, Pan Zhou, Sike Wang, Jia Li, Mi Tian +1 more
10/11/2024
cs.LGcs.AI

Official code: zimingyy/SubZero (20 stars, GPL-3.0, last commit 2024-11-22).

Abstract

Fine-tuning Large Language Models (LLMs) has proven effective for a variety of downstream tasks. However, as LLMs grow in size, the memory demands for backpropagation become increasingly prohibitive. Zeroth-order (ZO) optimization methods offer a memory-efficient alternative by using forward passes to estimate gradients, but the variance of gradient estimates typically scales linearly with the model's parameter dimension$\unicode{x2013}$a significant issue for LLMs. In this paper, we propose the random Subspace Zeroth-order (SubZero) optimization to address the challenges posed by LLMs' high dimensionality. We introduce a low-rank perturbation tailored for LLMs that significantly reduces memory consumption while improving training performance. Additionally, we prove that our gradient estimation closely approximates the backpropagation gradient, exhibits lower variance than traditional ZO methods, and ensures convergence when combined with SGD. Experimental results show that SubZero enhances fine-tuning performance and achieves faster convergence compared to standard ZO approaches like MeZO across various language modeling tasks. Code is available at https://github.com/zimingyy/SubZero.

View on arXivView PDF

Code Implementations(1)

zimingyy/SubZeroOfficial100%
GPL-3.0

Zeroth-Order Fine-Tuning of LLMs in Random Subspaces (ICCV 2025)

207PythonOct 9, 20241 years agoGPL-3.0

Similar Papers

Cite this paper

@article{yu2024zerothorder,
  title  = {Zeroth-Order Fine-Tuning of LLMs in Random Subspaces},
  author = {Ziming Yu and Pan Zhou and Sike Wang and Jia Li and Mi Tian and Hua Huang},
  year   = {2024},
  eprint = {2410.08989},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.08989v3}
}

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/2410.08989.svg)](https://codeofpaper.com/paper/2410.08989)

Discussion