arXiv:2604.13066cs.CLcs.AI2026-04

用词典编码压缩提示词,不微调模型也能省80%成本。

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

论文配图:Lossless Prompt Compression via Dictionary-Encoding and In-Context Learning: Enabling Cost-Effective LLM Analysis of Repetitive Data
图 1 · 摘自论文原文
  • 通过上下文学习让模型理解压缩符号,无需训练即可解码。
  • 在LogHub 2.0上压缩率达60%-80%时,相似度仍超0.91。
  • 适合处理重复数据的大规模分析,尤其适合接口调用场景。

上下文学习已成为大语言模型的重要范式。本文表明,LLMs可在上下文中学习编码键,并直接对编码表示进行分析。这一发现实现了无需微调的无损提示压缩:频繁出现的子序列被替换为紧凑的元标记,当系统提示中提供压缩词典时,模型能正确解析这些元标记,输出等同于未压缩输入的结果。我们提出一种多尺度识别重复模式的压缩算法,采用保真度优化准则,确保压缩节省超过词典开销。压缩比最高可达80%,具体取决于数据特征。为验证压缩后分析精度不变,以解压作为具有明确真值的代理任务。在LogHub 2.0基准上使用Claude 3.7 Sonnet评估,模板压缩的准确匹配率超过0.99,算法压缩的平均莱文斯坦相似度高于0.91,即使压缩比达60%-80%也保持稳定。压缩比解释的相似度方差不足2%,说明解压质量主要由数据特性决定,而非压缩强度。该免训练方法适用于基于API的模型,直接应对令牌限制与调用成本两大部署瓶颈,实现大规模重复数据的低成本动态分析。

原文摘要 · Abstract (English)

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.

提示压缩无损压缩成本优化上下文学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。