arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.11083cs.CL
收藏

将基于生成的任务中的模型协作链精简为单次前向传播

Streamlining the Collaborative Chain of Models into A Single Forward Pass in Generation-Based Tasks

University of Science and Technology of China(中国科学技术大学)

Yuanjie Lyu, Chao Zhang, Yuhao Chen, Yong Chen, Tong Xu

AI总结:

针对模型链中纯文本中间输出导致 KV 状态重复计算的问题,本文提出提示微调方法 FTHSS,通过训练时修改输入与注意力掩码实现跨模型 KV 状态共享,在四项任务上保持性能并提升推理效率。

摘要:

在检索增强生成(RAG)和基于智能体的框架中,“模型链”方法被广泛使用,即多个专门化模型按顺序处理不同的子任务。该方法有效,但会增加资源需求,因为每个模型都必须单独部署。近期进展试图通过应用提示微调来解决这一问题,该技术允许共享基础模型以最少的参数变化适应多个任务。然而,一个关键挑战仍然存在:在模型之间以纯文本形式传递的中间输出,在推理期间需要重新计算隐藏状态(即 Transformers 中的键和值(KV)状态)。本文提出 FTHSS,这是一种新颖的提示微调方法,使模型能够共享 KV 隐藏状态,从而消除冗余前向传播并减少 KV 缓存存储。通过在训练期间修改输入掩码和注意力掩码,FTHSS 允许模型在单轮和多轮场景中有效利用来自先前模型的 KV 隐藏状态。在四项任务上的实证结果表明,FTHSS 在提升推理效率的同时,性能与传统模型链相当。

英文摘要:

In Retrieval-Augmented Generation (RAG) and agent-based frameworks, the "Chain of Models" approach is widely used, where multiple specialized models work sequentially on distinct sub-tasks. This approach is effective but increases resource demands as each model must be deployed separately. Recent advancements attempt to address this by applying prompt tuning, which allows a shared base model to adapt to multiple tasks with minimal parameter changes. However, a key challenge remains: intermediate outputs, passed between models as plain text, require recomputation of hidden states (i.e., Key and Value (KV) states in Transformers) during inference. In this paper, we introduce FTHSS, a novel prompt-tuning method that enables models to share KV hidden states, eliminating redundant forward passes and reducing KV cache storage. By modifying input and attention masks during training, FTHSS allows models to effectively utilize KV hidden states from prior models in both single- and multi-round scenarios. Empirical results on four tasks show that FTHSS matches the performance of traditional model chains while improving inference efficiency.

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

↑