Research Papers 论文研究 19h ago Updated 18h ago 更新于 18小时前 49

Cache-Aware Prompt Compression: A Two-Tier Cost Model for LLM API Caching 缓存感知提示压缩:LLM API 缓存的双层成本模型

Introduces Cache-Aware Prompt Compression (CAPC), a method combining query-agnostic compression with explicit cache control to optimize LLM API costs. Identifies a critical flaw in existing research: standard query-aware compression invalidates prefix-strict caches, leading to suboptimal performance in real-world two-tier caching systems like Anthropic's Sonnet 4.6. Demonstrates that CAPC achieves up to 90% cost reduction compared to vanilla prompting and outperforms both naive caching and query 现有查询感知提示压缩方法因改变前缀导致缓存命中率下降,实际成本高于理论预期。 Anthropic Sonnet 4.6 API 缓存具有双层级架构,在约3,500令牌阈值下命中率 plateau 于 ~0.83。 提出缓存感知提示压缩 (CAPC),结合非查询感知压缩与显式缓存控制,防止过度压缩破坏缓存层级。 CAPC 在 LongBench-v2 及三个生产工作负载中均表现最优,平均节省成本达 49%-90% 且质量无损。

65
Hot 热度
75
Quality 质量
70
Impact 影响力

Analysis 深度分析

TL;DR

  • Introduces Cache-Aware Prompt Compression (CAPC), a method combining query-agnostic compression with explicit cache control to optimize LLM API costs.
  • Identifies a critical flaw in existing research: standard query-aware compression invalidates prefix-strict caches, leading to suboptimal performance in real-world two-tier caching systems like Anthropic's Sonnet 4.6.
  • Demonstrates that CAPC achieves up to 90% cost reduction compared to vanilla prompting and outperforms both naive caching and query-aware compression across 16/16 configurations on LongBench-v2.
  • Validates the approach on three production workloads, including an enterprise assistant and RAG pipelines, showing significant cost savings without compromising quality.

Why It Matters

This research bridges the gap between theoretical prompt compression models and practical API economics by accounting for real-world caching behaviors. For AI practitioners, it provides a concrete strategy to drastically reduce inference costs while maintaining performance, challenging the assumption that query-specific compression is always superior. It highlights the importance of understanding provider-specific cache architectures when designing efficient LLM applications.

Technical Details

  • Two-Tier Cache Analysis: Empirical characterization of Anthropic's Sonnet 4.6 API reveals a two-tier cache architecture with a sharp threshold near 3,500 tokens, where hit rates plateau at ~0.83 rather than the idealized 1.0 assumed in prior literature.
  • CAPC Methodology: The proposed solution uses query-agnostic compression to preserve cache hits, paired with cache_control parameters and a tier-preserving ratio bound to prevent over-compression from dropping prefixes below the hot tier threshold.
  • Performance Metrics: On LongBench-v2, CAPC reduced costs by 49% over cache-only, 64% over query-aware compression, and 90% over vanilla methods, with quality loss less than 0.05 compared to uncompressed baselines.
  • Production Validation: Tested on an enterprise tool-using assistant (51.7% cost reduction at r=3) and a graphify RAG pipeline (9.3x speedup vs cache-all on FastAPI), confirming the negative ROI of query-aware compression in high-frequency scenarios.

Industry Insight

  • Re-evaluate Compression Strategies: Developers should move away from purely query-aware compression for repetitive tasks, as the cache invalidation penalty often outweighs the token savings. Query-agnostic approaches may offer better total cost efficiency.
  • Optimize for Provider Specifics: Cost models must incorporate the specific caching mechanics of the chosen LLM provider (e.g., tier thresholds, hit rate plateaus) rather than assuming idealized caching behavior.
  • Monitor Cache Hit Rates: Implementing explicit cache controls and monitoring actual hit rates can reveal significant optimization opportunities, particularly for applications with large, static system prompts or schemas.

TL;DR

  • 现有查询感知提示压缩方法因改变前缀导致缓存命中率下降,实际成本高于理论预期。
  • Anthropic Sonnet 4.6 API 缓存具有双层级架构,在约3,500令牌阈值下命中率 plateau 于 ~0.83。
  • 提出缓存感知提示压缩 (CAPC),结合非查询感知压缩与显式缓存控制,防止过度压缩破坏缓存层级。
  • CAPC 在 LongBench-v2 及三个生产工作负载中均表现最优,平均节省成本达 49%-90% 且质量无损。

为什么值得看

本文揭示了当前LLM部署中“提示压缩”与“提示缓存”之间的隐性冲突,纠正了学术界对缓存命中率的理想化假设。通过构建双层级成本模型并提出CAPC方案,为工业界降低大模型API调用成本提供了经过实证验证的高效策略。

技术解析

  • 缓存特性实证:通过对 Anthropic Sonnet 4.6 API 的分析,发现其缓存并非理想的 rho=1.0,而是存在约 3,500 令牌的硬性阈值,低于此值时命中率稳定在 ~0.83。
  • CAPC 机制:采用非查询感知压缩以保留公共前缀,配合 cache_control 参数和层级保持比率限制,确保压缩后的前缀仍落在热缓存层级内。
  • 性能基准:在 LongBench-v2 的 16/16 配置中,CAPC 成本最低,相比仅使用缓存、查询感知压缩和原始输入分别节省 49%、64% 和 90%,质量损失控制在 0.05 以内。
  • 生产环境验证:在企业工具助手(94k令牌Schema)中降低成本 51.7%;在 RAG 管道中比全缓存快 9.3 倍;在 tau-bench 零售基准测试中,以相同奖励得分成为最便宜策略,证实了查询感知压缩在高成本下的负 ROI 预测。

行业启示

  • 优化策略转型:企业应重新评估现有的提示压缩策略,从单纯的“减少令牌数”转向“缓存友好型”压缩,避免因为前缀变化导致的缓存失效成本。
  • 基础设施适配:在部署 LLM 应用时,需深入了解底层 API 提供商(如 Anthropic, OpenAI)的具体缓存机制和层级阈值,定制化调整压缩算法参数。
  • 成本效益权衡:在高并发或长上下文场景下,采用 CAPC 等兼顾缓存命中的压缩方案能带来显著的经济效益,同时保持模型输出质量,是提升 ROI 的关键路径。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

LLM 大模型 Inference 推理 Deployment 部署 Research 科学研究