用小模型+适配器在边缘设备上高效训练检索增强生成模型
Federated Learning with Ad-hoc Adapter Insertions: The Case of Soft-Embeddings for Training Classifier-as-Retriever
- 用冻结的小语言模型加可训练适配器生成增强嵌入
- 分类器作为检索器,显著提升文档匹配准确率
- 联邦学习实现边缘端隐私保护在线训练
当现有检索增强生成(RAG)系统需适配新知识领域时,需更新其编码器(即预训练大语言模型),但全量微调计算与内存开销巨大,难以在资源受限的边缘设备上部署。本文提出一种新型编码器架构:采用冻结的小语言模型(SLM),并在其Transformer块前插入小型适配器网络。该适配器接收新语料的词元嵌入,学习生成增强的软嵌入,更新所需计算量远低于全量微调。进一步提出一种新型检索机制,在SLM编码器上附加分类器头,训练其学习输入嵌入与对应文档间的相似性映射。为实现边缘设备上软嵌入与分类器-检索器的在线微调,采用联邦学习(FL)与差分隐私(DP),构建高效、隐私保护且具备产品级实用性的训练方案。理论分析表明,在梯度方差满足弱假设条件下,方法对一般光滑非凸损失函数具有收敛性保证。大量数值实验验证了:(i) 软嵌入有效提升编码器性能;(ii) 分类器能显著改善检索效果;(iii) 联邦学习带来训练加速优势。
原文摘要 · Abstract (English)
When existing retrieval-augmented generation (RAG) solutions are intended to be used for new knowledge domains, it is necessary to update their encoders, which are taken to be pretrained large language models (LLMs). However, fully finetuning these large models is compute- and memory-intensive, and even infeasible when deployed on resource-constrained edge devices. We propose a novel encoder architecture in this work that addresses this limitation by using a frozen small language model (SLM), which satisfies the memory constraints of edge devices, and inserting a small adapter network before the transformer blocks of the SLM. The trainable adapter takes the token embeddings of the new corpus and learns to produce enhanced soft embeddings for it, while requiring significantly less compute power to update than full fine-tuning. We further propose a novel retrieval mechanism by attaching a classifier head to the SLM encoder, which is trained to learn a similarity mapping of the input embeddings to their corresponding documents. Finally, to enable the online fine-tuning of both (i) the encoder soft embeddings and (ii) the classifier-as-retriever on edge devices, we adopt federated learning (FL) and differential privacy (DP) to achieve an efficient, privacy-preserving, and product-grade training solution. We conduct a theoretical analysis of our methodology, establishing convergence guarantees under mild assumptions on gradient variance when deployed for general smooth nonconvex loss functions. Through extensive numerical experiments, we demonstrate (i) the efficacy of obtaining soft embeddings to enhance the encoder, (ii) training a classifier to improve the retriever, and (iii) the role of FL in achieving speedup.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。