TCRA-LLM: Token Compression Retrieval Augmented Large Language Model for Inference Cost Reduction
作者: Junyi Liu, Liangzhi Li, Tong Xiang, Bowen Wang, Yiming Qian
分类: cs.CL, cs.IR
发布日期: 2023-10-24 (更新: 2023-10-25)
备注: EMNLP 2023 Findings
💡 一句话要点
提出TCRA-LLM以解决检索增强大语言模型推理成本问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 大语言模型 检索增强 token压缩 自然语言处理 食品推荐
📋 核心要点
- 现有的检索增强大语言模型在推理过程中由于输入token的增加,导致成本显著上升。
- 本文提出了一种token压缩方案,包括摘要压缩和语义压缩,以有效减少输入token的大小。
- 实验结果表明,摘要压缩可减少65%的token大小并提高0.3%的准确率,而语义压缩可减少20%的token大小,准确率仅下降1.6%。
📝 摘要(中文)
自ChatGPT发布API以来,基于商业大语言模型(LLMs)的应用数量迅速增加。这些模型的一个常见用法是利用其上下文学习能力,通过检索增强生成用户查询的响应。然而,部署商业检索增强LLMs时,由于额外检索的上下文大幅增加了输入token的大小,导致成本上升。为此,本文提出了一种token压缩方案,包括摘要压缩和语义压缩两种方法。摘要压缩使用基于T5的模型,通过自我指导生成的不同长度样本数据集进行微调,减少token大小。语义压缩则通过去除对语义影响较小的词进一步压缩token大小。我们提出并使用了一个名为Food-Recommendation DB (FRDB)的数据集,专注于孕期或婴儿的女性食品推荐。摘要压缩可减少65%的检索token大小,同时提高0.3%的准确率;语义压缩则提供了一种灵活的方式,在token大小与性能之间进行权衡,能够将token大小减少20%,而准确率仅下降1.6%。
🔬 方法详解
问题定义:本文旨在解决检索增强大语言模型在推理过程中因输入token数量增加而导致的高成本问题。现有方法在处理大量上下文时,未能有效控制token大小,造成资源浪费。
核心思路:提出的token压缩方案通过摘要压缩和语义压缩两种方法,旨在在保持模型性能的同时,显著减少输入token的数量。摘要压缩通过生成简洁的上下文,而语义压缩则通过去除低影响词汇来实现。
技术框架:整体架构包括两个主要模块:摘要压缩模块和语义压缩模块。摘要压缩模块使用微调的T5模型生成简化的上下文,而语义压缩模块则分析上下文中的词汇重要性,去除冗余信息。
关键创新:最重要的技术创新在于提出了两种互补的压缩方法,摘要压缩和语义压缩,能够灵活地在token大小与模型性能之间进行权衡,显著提升了检索增强LLMs的实用性。
关键设计:摘要压缩使用基于T5的模型,经过自我指导生成的数据集进行微调,确保生成的摘要在保留关键信息的同时减少token数量;语义压缩则通过分析词汇的重要性,去除对语义影响较小的词汇,进一步优化token的使用。
🖼️ 关键图片
📊 实验亮点
实验结果显示,摘要压缩方法能够将检索token大小减少65%,并在此基础上提高0.3%的准确率;而语义压缩方法则实现了20%的token大小减少,准确率仅下降1.6%。这些结果表明,提出的方法在有效性和灵活性方面均有显著提升。
🎯 应用场景
该研究的潜在应用领域包括智能客服、个性化推荐系统以及其他需要实时响应的自然语言处理任务。通过降低推理成本,TCRA-LLM可以使得大语言模型在资源受限的环境中更具可用性,推动其在商业和学术领域的广泛应用。
📄 摘要(原文)
Since ChatGPT released its API for public use, the number of applications built on top of commercial large language models (LLMs) increase exponentially. One popular usage of such models is leveraging its in-context learning ability and generating responses given user queries leveraging knowledge obtained by retrieval augmentation. One problem of deploying commercial retrieval-augmented LLMs is the cost due to the additionally retrieved context that largely increases the input token size of the LLMs. To mitigate this, we propose a token compression scheme that includes two methods: summarization compression and semantic compression. The first method applies a T5-based model that is fine-tuned by datasets generated using self-instruct containing samples with varying lengths and reduce token size by doing summarization. The second method further compresses the token size by removing words with lower impact on the semantic. In order to adequately evaluate the effectiveness of the proposed methods, we propose and utilize a dataset called Food-Recommendation DB (FRDB) focusing on food recommendation for women around pregnancy period or infants. Our summarization compression can reduce 65% of the retrieval token size with further 0.3% improvement on the accuracy; semantic compression provides a more flexible way to trade-off the token size with performance, for which we can reduce the token size by 20% with only 1.6% of accuracy drop.