2025-03-13 · 进阶 · 机器学习 · 自然语言处理

Cost-Optimal Grouped-Query Attention for Long-Context LLMs

本文提出了一种基于分组查询注意力(GQA)的优化方法,旨在最小化大型语言模型(LLM)的训练和推理成本,同时最大化其语言建模能力。

更新于 2025-03-19。作者:Yingfa Chen、Yutong Wu、Xu Han、Zhiyuan Liu、Maosong Sun。

中文摘要

构建有效且高效的基于Transformer的大型语言模型(LLMs)最近成为研究焦点,需要最大化模型的语言能力并最小化训练和部署成本。现有的工作主要描述了模型性能、参数大小和数据大小之间的复杂关系,以及寻找训练LLMs的最佳计算分配。然而,它们忽略了上下文长度和注意力头配置(分组查询注意力中的查询和键值头的数量)对训练和推理的影响。在本文中,我们系统地比较了不同参数大小、上下文长度和注意力头配置的模型,在模型性能、计算成本和内存成本方面的表现。然后,我们将现有的仅基于参数大小和训练计算量的扩展方法,扩展到指导训练和推理过程中成本最优的LLMs构建。我们的量化扩展研究表明,当处理足够长的序列时,一个具有较少注意力头的较大模型可以在产生较低损失的同时,产生较低的计算和内存成本。我们的发现为开发实用的LLMs提供了宝贵的见解,特别是在长上下文处理场景中。我们将公开发布我们的代码和数据。

英文摘要

Building effective and efficient Transformer-based large language models (LLMs) has recently become a research focus, requiring maximizing model language capabilities and minimizing training and deployment costs. Existing efforts have primarily described complex relationships among model performance, parameter size, and data size, as well as searched for the optimal compute allocation to train LLMs. However, they overlook the impacts of context length and attention head configuration (the number of query and key-value heads in grouped-query attention) on training and inference. In this paper, we systematically compare models with different parameter sizes, context lengths, and attention head configurations in terms of model performance, computational cost, and memory cost. Then, we extend the existing scaling methods, which are based solely on parameter size and training compute, to guide the construction of cost-optimal LLMs during both training and inference. Our quantitative scaling studies show that, when processing sufficiently long sequences, a larger model with fewer attention heads can achieve a lower loss while incurring lower computational and memory costs. Our findings provide valuable insights for developing practical LLMs, especially in long-context processing scenarios. We will publicly release our code and data.

解读

一句话总结

本文提出了一种基于分组查询注意力(GQA)的优化方法,旨在最小化大型语言模型(LLM)的训练和推理成本,同时最大化其语言建模能力。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源