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

通过字典编码和上下文学习实现无损提示压缩:使LLM能够高效分析重复数据

Lossless Prompt Compression via Dictionary-Encoding and In-Context Learning: Enabling Cost-Effective LLM Analysis of Repetitive Data

Anonymous Institution, Anonymous City, Anonymous Region, Anonymous Country(匿名机构,匿名城市,匿名地区,匿名国家)

Andresa Rodrigues de Campos, David Lee, Imry Kissos, Piyush Paritosh

AI总结:

本文提出一种无损提示压缩方法,利用字典编码和上下文学习,无需微调即可高效分析重复数据,压缩比达80%且保持高精度。

摘要:

在上下文学习中,大型语言模型(LLM)能够通过上下文学习编码键并直接对编码表示进行分析。本文展示,通过字典编码可实现无损提示压缩,无需模型微调:频繁出现的子序列被替换为紧凑的元标记,当在系统提示中提供压缩字典时,LLM能正确解释这些元标记,生成与未压缩输入等效的输出。我们提出了一种压缩算法,识别多个长度尺度的重复模式,结合一个标记节省优化准则,确保压缩减少成本,防止字典开销超过节省。该算法可达到高达80%的压缩比,取决于数据集特性。通过解压作为代理任务验证LLM分析精度在压缩下保持不变。在LogHub 2.0基准测试中使用Claude 3.7 Sonnet,模板压缩的精确匹配率超过0.99,算法压缩的平均Levenshtein相似度分数超过0.91,即使在60%-80%的压缩比下。此外,压缩比解释了相似度指标中不到2%的方差,表明解压质量取决于数据集特性而非压缩强度。这种无需训练的方法适用于基于API的LLM,直接解决部署约束——token限制和API成本——并使大规模重复数据的高效分析成为可能,即使数据模式随时间演变。

英文摘要:

In-context learning has established itself as an important learning paradigm for Large Language Models (LLMs). In this paper, we demonstrate that LLMs can learn encoding keys in-context and perform analysis directly on encoded representations. This finding enables lossless prompt compression via dictionary encoding without model fine-tuning: frequently occurring subsequences are replaced with compact meta-tokens, and when provided with the compression dictionary in the system prompt, LLMs correctly interpret these meta-tokens during analysis, producing outputs equivalent to those from uncompressed inputs. We present a compression algorithm that identifies repetitive patterns at multiple length scales, incorporating a token-savings optimization criterion that ensures compression reduces costs by preventing dictionary overhead from exceeding savings. The algorithm achieves compression ratios up to 80$\%$ depending on dataset characteristics. To validate that LLM analytical accuracy is preserved under compression, we use decompression as a proxy task with unambiguous ground truth. Evaluation on the LogHub 2.0 benchmark using Claude 3.7 Sonnet demonstrates exact match rates exceeding 0.99 for template-based compression and average Levenshtein similarity scores above 0.91 for algorithmic compression, even at compression ratios of 60$\%$-80$\%$. Additionally, compression ratio explains less than 2$\%$ of variance in similarity metrics, indicating that decompression quality depends on dataset characteristics rather than compression intensity. This training-free approach works with API-based LLMs, directly addressing fundamental deployment constraints -- token limits and API costs -- and enabling cost-effective analysis of large-scale repetitive datasets, even as data patterns evolve over time.

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

↑