arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2407.19580cs.LGcs.AIcs.CL
收藏

用于在数据混合物上进行内存高效语言模型训练的小批量核心集

Mini-batch Coresets for Memory-efficient Language Model Training on Data Mixtures

Computer Science Department, UCLA(计算机科学系,加州大学洛杉矶分校)

Dang Nguyen, Wenhan Yang, Rathul Anand, Yu Yang, Baharan Mirzasoleiman

AI总结:

提出CoLM方法,通过包含小数据源样本、梯度历史指数归一化和零阶方法稀疏化V投影矩阵梯度,解决LLM在数据混合物上小批量核心集训练的内存瓶颈,实现2倍内存降低且优于4倍大批量训练。

摘要:

使用更大的小批量进行训练能提高收敛速度,并可能带来更优的性能。然而,由于巨大的 GPU 内存需求,使用大小批量训练对大型语言模型(LLMs)来说变得不可行。为了解决这个问题,一种有效的方法是寻找能够紧密匹配较大小批量梯度的小小批量核心集。然而,由于语言数据中数据源的高度不平衡混合、Adam 优化器的使用以及 LLMs 极大的梯度维度,这种方法对 LLMs 来说变得不可行且无效。在这项工作中,我们通过提出用于训练 LLMs 的核心集(CoLM)来解决上述挑战。首先,我们证明了通过梯度匹配找到的小批量核心集在大概率下(w.h.p.)不包含小型数据源的代表性样本,因此将小型数据源的所有样本包含在小批量核心集中对于实现最佳性能至关重要。其次,我们通过梯度的历史指数对梯度进行归一化,以找到用于 Adam 训练的小批量核心集。最后,我们利用零阶方法来寻找最后 V 投影矩阵的平滑梯度,并将其稀疏化以保留具有最大归一化梯度幅度的维度。我们将 CoLM 应用于在 MathInstruct 和 SuperGLUE 基准上使用 LoRA 微调 Phi-2、Phi-3、Zephyr 和 Llama-3 模型。值得注意的是,CoLM 将微调的内存需求减少了 2 倍,甚至优于使用 4 倍大小批量进行的训练。此外,CoLM 能与 LoRA 等现有的内存高效训练方法无缝集成,进一步降低了训练 LLMs 的内存需求。我们的代码可在 https://github.com/BigML-CS-UCLA/CoLM 获取。

英文摘要:

Training with larger mini-batches improves the convergence rate and can yield superior performance. However, training with large mini-batches becomes prohibitive for Large Language Models (LLMs), due to the large GPU memory requirement. To address this problem, an effective approach is finding small mini-batch coresets that closely match the gradient of larger mini-batches. However, this approach becomes infeasible and ineffective for LLMs, due to the highly imbalanced mixture of sources in language data, use of the Adam optimizer, and the very large gradient dimensionality of LLMs. In this work, we address the above challenges by proposing Coresets for Training LLMs (CoLM). First, we show that mini-batch coresets found by gradient matching do not contain representative examples of the small sources w.h.p., and thus including all examples of the small sources in the mini-batch coresets is crucial for optimal performance. Second, we normalize the gradients by their historical exponential to find mini-batch coresets for training with Adam. Finally, we leverage zeroth-order methods to find smooth gradient of the last V-projection matrix and sparsify it to keep the dimensions with the largest normalized gradient magnitude. We apply CoLM to fine-tuning Phi-2, Phi-3, Zephyr, and Llama-3 models with LoRA on MathInstruct and SuperGLUE benchmark. Remarkably, CoLM reduces the memory requirement of fine-tuning by 2x and even outperforms training with 4x larger mini-batches. Moreover, CoLM seamlessly integrates with existing memory-efficient training methods like LoRA, further reducing the memory requirements of training LLMs. Our code is available at https://github.com/BigML-CS-UCLA/CoLM.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑