arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.17415cs.CLcs.AIcs.LG
收藏

逐层量化:一种超越整数比特级的实用且有效的 LLM 量化方法

Layer-Wise Quantization: A Pragmatic and Effective Method for Quantizing LLMs Beyond Integer Bit-Levels

ServiceNow Research(ServiceNow研究院);University of Arizona(亚利桑那大学);Università di Bologna(博洛尼亚大学)

Razvan-Gabriel Dumitru, Vikas Yadav, Rishabh Maheshwary, Paul-Ioan Clotan, Sathwik Tejaswi Madhusudhan, Mihai Surdeanu

AI总结:

本文提出独立于底层技术的 LLM 逐层混合比特量化方法,通过两种层重要性指标分配精度,在显著压缩模型的同时保持性能,并验证其与动态量化互补及在大模型上的优势。

摘要:

我们提出了一种简单的元量化方法,可将大型语言模型(LLM)的不同层以不同比特级进行量化,并且独立于底层量化技术。具体而言,我们将最重要的层量化为更高比特精度,而将不太重要的层量化为更低比特。我们提出了两种有效策略来衡量 LLM 中层的重要性:第一种根据某一层的输出嵌入与输入嵌入之间的差异程度来衡量该层的重要性(越高越好);第二种利用远大于平均值的层权重数量来估计层的重要性(越小越好)。我们表明,根据我们的重要性分数以不同比特量化不同层,可在性能下降极小的同时实现高得多的模型压缩率。最后,我们给出了从可变逐层量化实验中得到的若干实用关键结论:(a) 在使用我们提出的排序将 25–50% 的层移至更低量化级别之前,可变量化下的 LLM 性能仍接近原始模型;但如果不使用特定排序进行移动,则仅有 5–10% 的层可被移动;(b) 将层重要性加入本质上动态的量化技术可进一步提升其性能,表明我们的方法与其他动态量化方法互补;(c) 除非采用极端量化(2-bit),否则将 LLM 量化至更低比特的表现显著优于剪枝;以及 (d) 与层数较少的较小 LLM 相比,向更低比特的逐层量化在层数更多的较大 LLM 中效果更好。我们的代码已公开发布于 https://github.com/RazvanDu/LayerwiseQuant/。

英文摘要:

We present a simple meta quantization approach that quantizes different layers of a large language model (LLM) at different bit levels, and is independent of the underlying quantization technique. Specifically, we quantize the most important layers to higher bit precision and less important layers to lower bits. We propose two effective strategies to measure the importance of layers within LLMs: the first measures the importance of a layer based on how different its output embeddings are from the input embeddings (higher is better); the second estimates the importance of a layer using the number of layer weights that are much larger than average (smaller is better). We show that quantizing different layers at varying bits according to our importance scores results in minimal performance drop with a far more compressed model size. Finally, we present several practical key takeaways from our variable layer-wise quantization experiments: (a) LLM performance under variable quantization remains close to the original model until 25-50% of layers are moved in lower quantization using our proposed ordering but only until 5-10% if moved using no specific ordering; (b) Adding layer importance to inherently dynamic quantization techniques can further improve their performance, showing that our approach is complementary to other dynamic quantization methods; (c) Quantizing LLMs to lower bits performs substantially better than pruning unless extreme quantization (2-bit) is used; and (d) Layer-wise quantization to lower bits works better in the case of larger LLMs with more layers compared to smaller LLMs with fewer layers. Our code is publicly available at https://github.com/RazvanDu/LayerwiseQuant/.

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

↑