Skip to main content
QUICK REVIEW

[论文解读] QLoRA: Efficient Finetuning of Quantized LLMs

Tim Dettmers, Artidoro Pagnoni|arXiv (Cornell University)|May 23, 2023
Ferroelectric and Negative Capacitance Devices被引用 485
一句话总结

QLoRA 使用低秩适配器对量化至4位的语言模型进行微调,以在显著更少内存的情况下达到与16位相近的性能,使大型模型能够在单个 GPU 上训练。

ABSTRACT

We present QLoRA, an efficient finetuning approach that reduces memory usage enough to finetune a 65B parameter model on a single 48GB GPU while preserving full 16-bit finetuning task performance. QLoRA backpropagates gradients through a frozen, 4-bit quantized pretrained language model into Low Rank Adapters~(LoRA). Our best model family, which we name Guanaco, outperforms all previous openly released models on the Vicuna benchmark, reaching 99.3% of the performance level of ChatGPT while only requiring 24 hours of finetuning on a single GPU. QLoRA introduces a number of innovations to save memory without sacrificing performance: (a) 4-bit NormalFloat (NF4), a new data type that is information theoretically optimal for normally distributed weights (b) double quantization to reduce the average memory footprint by quantizing the quantization constants, and (c) paged optimziers to manage memory spikes. We use QLoRA to finetune more than 1,000 models, providing a detailed analysis of instruction following and chatbot performance across 8 instruction datasets, multiple model types (LLaMA, T5), and model scales that would be infeasible to run with regular finetuning (e.g. 33B and 65B parameter models). Our results show that QLoRA finetuning on a small high-quality dataset leads to state-of-the-art results, even when using smaller models than the previous SoTA. We provide a detailed analysis of chatbot performance based on both human and GPT-4 evaluations showing that GPT-4 evaluations are a cheap and reasonable alternative to human evaluation. Furthermore, we find that current chatbot benchmarks are not trustworthy to accurately evaluate the performance levels of chatbots. A lemon-picked analysis demonstrates where Guanaco fails compared to ChatGPT. We release all of our models and code, including CUDA kernels for 4-bit training.

研究动机与目标

  • 推动对超大语言模型(LLMs)进行内存高效的微调。
  • 提出将4位 NF4量化与低秩适配器相结合以保持性能。
  • 展示在7B–65B模型及多种指令跟随基准上的可扩展性。
  • 分析数据质量与数据集规模的关系,并使用人工评估和GPT-4评估来评估聊天机器人性能。

提出的方法

  • 将预训练权重量化为4位 NF4,并使用双量化以降低内存占用。
  • 通过对量化权重反向传播梯度来学习插入到每个 transformer 层的 LoRA 适配器。
  • 使用分页优化器和 NVIDIA 统一内存以处理训练过程中的内存峰值。
  • 保持一个计算路径,将前向/反向传播去量化为 BF16,同时仅更新 LoRA 参数。
  • 在多种模型规模和数据集上与完整16位微调和16位 LoRA 基线进行对比评估。
Figure 1: Different finetuning methods and their memory requirements. QLoRA improves over LoRA by quantizing the transformer model to 4-bit precision and using paged optimizers to handle memory spikes.
Figure 1: Different finetuning methods and their memory requirements. QLoRA improves over LoRA by quantizing the transformer model to 4-bit precision and using paged optimizers to handle memory spikes.

实验结果

研究问题

  • RQ1在配合 LoRA 适配器时,4位 NF4 量化结合双量化是否能保留完整的16位微调性能?
  • RQ2就准确性和内存效率而言,QLoRA 如何在7B–65B的模型规模和指令数据集上进行扩展?
  • RQ3数据质量和数据集选择是否在指令微调和聊天机器人能力方面胜过数据集规模?
  • RQ4在 Vicuna/OASST1 基准上,以 GPT-4 与人类评估对用 QLoRA 训练的聊天机器人进行排名时,两者的比较如何?

主要发现

  • 使用 NF4 + 双量化的 QLoRA 在学术基准上与16位全量化微调及16位 LoRA 性能相匹配。
  • NF4 在零-shot 和微调任务中优于 FP4 和 Int4,双量化在不降低性能的前提下降低了内存占用。
  • Guanaco 模型(7B–65B)在 Vicuna 基准上接近 ChatGPT 的表现,Guanaco 65B 在 GPT-4 评估的 Vicuna 结果中达到 ChatGPT 的 99.3%。
  • 4-bit QLoRA 使在单个 48GB GPU 上对65B模型进行微调成为可能,在21GB上可对33B进行微调,与完整16位微调相比可节省大量内存。
  • 数据集的质量对指令跟随和聊天机器人性能比规模更重要,强的 MMLU 表现并不总是意味着更出色的聊天机器人性能。
  • 基于 GPT-4 的评估在锦标赛式聊天机器人比较中在很大程度上与人类判断一致,但存在显著的分歧,需谨慎解读。
Figure 5: The crowdsourcing form used by human annotators.
Figure 5: The crowdsourcing form used by human annotators.

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。