arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2402.01173cs.CLcs.LG
收藏

基于嵌入相似度的高效提示缓存

Efficient Prompt Caching via Embedding Similarity

UC Berkeley(加州大学伯克利分校)

Hanlin Zhu, Banghua Zhu, Jiantao Jiao

AI总结:

针对大语言模型推理资源消耗高的问题,提出基于蒸馏的嵌入微调方法提升提示缓存预测准确率,在困难数据集上将AUC从0.51提至0.81,缓存效率更优。

摘要:

大语言模型(LLM)已在众多自然语言处理(NLP)任务中取得巨大成功,但其推理阶段存在资源消耗过高的挑战。本文旨在通过提示缓存提升LLM的推理效率:即若当前提示可由某条历史提示的相同响应作答,则无需调用LLM,可直接复用该历史响应。具体而言,本文聚焦单轮问答任务中,基于嵌入相似度的提示缓存的预测准确率问题。现有提示嵌入方法大多关注两条提示是否语义相似,但语义相似并不等同于可由同一响应作答。为此,本文提出一种基于蒸馏的方法对现有嵌入模型进行微调,以提升缓存预测效果。理论层面,本文为该方法在不同类型损失函数下的收敛性提供了有限样本保证。实验层面,本文基于Kwiatkowski等人(2019)的工作精心构建了一个困难数据集,现有嵌入模型(Wang等人,2022)在该数据集上的AUC仅为0.51;经本文方法微调后,该嵌入模型的缓存预测AUC从0.51大幅提升至0.81。本文还开展了模拟实验,结果表明经训练的模型相比原有嵌入模型实现了更优的缓存效率。

英文摘要:

Large language models (LLMs) have achieved huge success in numerous natural language process (NLP) tasks. However, it faces the challenge of significant resource consumption during inference. In this paper, we aim to improve the inference efficiency of LLMs by prompt caching, i.e., if the current prompt can be answered by the same response of a previous prompt, one can directly utilize that previous response without calling the LLM. Specifically, we focus on the prediction accuracy of prompt caching for single-round question-answering tasks via embedding similarity. The existing embeddings of prompts mostly focus on whether two prompts are semantically similar, which is not necessarily equivalent to whether the same response can answer them. Therefore, we propose a distillation-based method to fine-tune the existing embeddings for better caching prediction. Theoretically, we provide finite-sample guarantees for the convergence of our method under different types of loss functions. Empirically, we carefully construct a hard dataset based on Kwiatkowski et al. (2019) where the existing embedding model (Wang et al., 2022) only achieves an AUC of 0.51. We then fine-tune the above embedding model, which significantly improves the AUC of caching prediction from 0.51 to 0.81. We also conduct simulations demonstrating that our trained models achieve better caching efficiency than the previous embedding model.

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

↑