SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.17333 · NeurIPS · 2023

Fine-Tuning Language Models with Just Forward Passes

Jason Lee, Sanjeev Arora, Sadhika Malladi, Danqi Chen, Alex Damian, Tianyu Gao, Eshaan Nichani

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 17 functions out of this paper's own repositories and ran 9 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
princeton-nlp/mezo canonical 7 of 14
liangyuwang/zo2 — 2 of 3
FunctionStatusWhere it lives
BaseOptimizer Ran liangyuwang/zo2/zo2/optimizer/mezo_sgd/zo.py
code served (permissive licence) · get_code("506b0c89834f1424")
MeZOSGD Ran liangyuwang/zo2/zo2/optimizer/mezo_sgd/zo.py
code served (permissive licence) · get_code("f9a6c1b932010ab6")
encode_prompt Ran princeton-nlp/mezo/large_models/utils.py
code served (permissive licence) · get_code("7c5d9ba063f6642c")
find_module Ran princeton-nlp/mezo/large_models/lora.py
code served (permissive licence) · get_code("b5adfd6ac99a1b18")
forward_wrap_with_option_len Ran princeton-nlp/mezo/large_models/utils.py
code served (permissive licence) · get_code("54a6124d697bc2c2")
input_example_to_string Ran princeton-nlp/mezo/medium_models/src/dataset.py
code served (permissive licence) · get_code("e768e25ca95f70cd")
input_example_to_tuple Ran princeton-nlp/mezo/medium_models/src/dataset.py
code served (permissive licence) · get_code("fbef70dc7c700501")
normalize_answer Ran princeton-nlp/mezo/large_models/metrics.py
code served (permissive licence) · get_code("e7e75981cb464788")
tokenize_multipart_input Ran princeton-nlp/mezo/medium_models/src/dataset.py
code served (permissive licence) · get_code("9a62fa939fc563a4")
MeZOSGDConfig Not yet run liangyuwang/zo2/zo2/optimizer/mezo_sgd/zo.py
code served (permissive licence) · get_code("00b3e776ab20cb69")
attn_forward_hook Not yet run princeton-nlp/mezo/large_models/prefix.py
code served (permissive licence) · get_code("bdb460cb247501dc")
calculate_metric Not yet run princeton-nlp/mezo/large_models/metrics.py
code served (permissive licence) · get_code("84c658f2c9252878")
f1 Not yet run princeton-nlp/mezo/large_models/metrics.py
code served (permissive licence) · get_code("b989d4bce26f77ce")
get_task Not yet run princeton-nlp/mezo/large_models/tasks.py
code served (permissive licence) · get_code("f7c384f1e681ea7a")
prepare_inputs_for_generation Not yet run princeton-nlp/mezo/large_models/prefix.py
code served (permissive licence) · get_code("84920a8095dca4fa")
tensor_all_gather Not yet run princeton-nlp/mezo/medium_models/src/linearhead_trainer.py
code served (permissive licence) · get_code("c239cb1add74b809")
varsize_tensor_all_gather Not yet run princeton-nlp/mezo/medium_models/src/linearhead_trainer.py
code served (permissive licence) · get_code("734d0491ecbc7841")

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

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 inplace, 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 12× memory reduction and up to 2× 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. 1

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2305.17333")
get_code_for_paper("2305.17333")
have("2305.17333")

Connect an agent — have() is free.