通过全维梯度聚类,让大模型学会按任务分工,提升指令微调效果。
GradientSpace: Unsupervised Data Clustering for Improved Instruction Tuning
- 在完整梯度空间聚类数据,避免降维损失
- 单专家路由比专家集成更准且快30%以上
- 适合需要高效多任务推理的工业级应用
指令微调是使大语言模型适应多种下游任务的关键步骤。然而,真实数据往往混杂多样,导致梯度冲突,降低模型性能。现有方法基于语义相似性分组数据,但无法反映数据对参数的影响。虽有研究尝试直接聚类梯度,却通过随机投影降维,造成精度损失;且依赖专家集成,需多次推理和实时计算梯度,成本高昂。为此,我们提出GradientSpace,直接在全维梯度空间聚类样本。采用在线SVD算法处理LoRA梯度,无需存储全部梯度即可识别隐含技能。每个聚类训练一个专用LoRA专家,搭配轻量路由器在推理时选择最优专家。实验表明,单专家路由优于以往专家集成,且推理延迟显著降低。在数学推理、代码生成、金融分析和创意写作任务中,GradientSpace实现专家专业化,准确率持续超越当前最优聚类方法与微调技术。
原文摘要 · Abstract (English)
Instruction tuning is one of the key steps required for adapting large language models (LLMs) to a broad spectrum of downstream applications. However, this procedure is difficult because real-world datasets are rarely homogeneous; they consist of a mixture of diverse information, causing gradient interference, where conflicting gradients pull the model in opposing directions, degrading performance. A common strategy to mitigate this issue is to group data based on semantic or embedding similarity. However, this fails to capture how data influences model parameters during learning. While recent works have attempted to cluster gradients directly, they randomly project gradients into lower dimensions to manage memory, which leads to accuracy loss. Moreover, these methods rely on expert ensembles which necessitates multiple inference passes and expensive on-the-fly gradient computations during inference. To address these limitations, we propose GradientSpace, a framework that clusters samples directly in full-dimensional gradient space. We introduce an online SVD-based algorithm that operates on LoRA gradients to identify latent skills without the infeasible cost of storing all sample gradients. Each cluster is used to train a specialized LoRA expert along with a lightweight router trained to select the best expert during inference. We show that routing to a single, appropriate expert outperforms expert ensembles used in prior work, while significantly reducing inference latency. Our experiments across mathematical reasoning, code generation, finance, and creative writing tasks demonstrate that GradientSpace leads to coherent expert specialization and consistent accuracy gains over state-of-the-art clustering methods and finetuning techniques.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。