arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2511.22118cs.SE
收藏

面向LLM工作流的统计独立性感知缓存

Statistical Independence Aware Caching for LLM Workflows

Peking University(北京大学)

Yihan Dai, Dimitrios Stamatios Bouras, Haoxiang Jia, Sergey Mechtaev

AI总结:

Mnimi通过封装统计约束在LLM引用类型中,提升代码修复工作流的可重复性、调试效率和统计正确性。

摘要:

大型语言模型(LLM)的推理过程既昂贵又缓慢。本地缓存响应提供了一种实用的解决方案,以减少LLM查询的成本和延迟。在研究环境中,缓存还增强了可重复性和为实验提供了灵活性。然而,简单地重用缓存响应会破坏统计独立性,这是概率工作流的关键属性。在LLM用于代码的应用中,它支撑着诸如Pass@k和不确定性估计等性能指标,以及程序修复循环和重试等算法。现有的LLM缓存系统缺乏强制执行统计独立性约束的方法。为了解决这个问题,我们引入了Mnimi,一种缓存设计模式,它支持模块化的LLM工作流,同时在组件层面确保统计完整性。其核心创新在于将统计约束封装在LLM引用的类型中,允许用户根据其算法的范围和需求管理和转换这些类型。我们使用装饰器和无限序列的迭代器组合在Python中实现了这种设计模式。对SpecFix,一个最近的自动程序规范修复系统的案例研究展示了Mnimi如何提高可重复性、调试的便利性、时间和成本效率,同时保持统计正确性。

英文摘要:

Large language models (LLMs) inference is both expensive and slow. Local caching of responses offers a practical solution to reduce the cost and latency of LLM queries. In research contexts, caching also enhances reproducibility and provides flexibility for experimentation. However, naive reuse of cached responses compromises statistical independence, a critical property for probabilistic workflows. In applications of LLM for code, it underpins performance metrics such as Pass@k and uncertainty estimation, as well as algorithms like program repair loops and retries. Existing LLM caching systems lack ways to enforce statistical independence constraints. To address this, we introduce Mnimi, a cache design pattern that supports modular LLM workflows while ensuring statistical integrity at the component level. Its core innovation lies in encapsulating statistical constraints within the type of LLM references, allowing users to manage and transform these types according to the scope and requirements of their algorithm. We implemented this design pattern in Python using a combination of decorators and iterators over infinite sequences. A case study on SpecFix, an recent automated program specification repair system, highlights how Mnimi improves reproducibility, ease of debugging, time and cost efficiency while preserving statistical correctness.

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

↑