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.


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

0
下载
关闭预览

相关内容

【CIKM2020】多模态知识图谱推荐系统,Multi-modal KG for RS
专知会员服务
98+阅读 · 2020年8月24日
Python图像处理,366页pdf,Image Operators Image Processing in Python
【NeurIPS2019】图变换网络:Graph Transformer Network
NAACL 2019 | 一种考虑缓和KL消失的简单VAE训练方法
PaperWeekly
20+阅读 · 2019年4月24日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Arxiv
18+阅读 · 2024年12月27日
Arxiv
176+阅读 · 2023年4月20日
A Survey of Large Language Models
Arxiv
501+阅读 · 2023年3月31日
Generalized Out-of-Distribution Detection: A Survey
Arxiv
15+阅读 · 2021年10月21日
A Survey on Edge Intelligence
Arxiv
52+阅读 · 2020年3月26日
Exploring Visual Relationship for Image Captioning
Arxiv
15+阅读 · 2018年9月19日
VIP会员
最新内容
非对称优势:美海军开发低成本反无人机技术
专知会员服务
4+阅读 · 今天4:39
《美战争部小企业创新研究(SBIR)计划》
专知会员服务
5+阅读 · 今天2:48
《军事模拟:将军事条令与目标融入AI智能体》
专知会员服务
8+阅读 · 今天2:43
【NTU博士论文】3D人体动作生成
专知会员服务
6+阅读 · 4月24日
以色列军事技术对美国军力发展的持续性赋能
专知会员服务
8+阅读 · 4月24日
《深度强化学习在兵棋推演中的应用》40页报告
专知会员服务
13+阅读 · 4月24日
《多域作战面临复杂现实》
专知会员服务
9+阅读 · 4月24日
《印度的多域作战:条令与能力发展》报告
专知会员服务
4+阅读 · 4月24日
相关VIP内容
【CIKM2020】多模态知识图谱推荐系统,Multi-modal KG for RS
专知会员服务
98+阅读 · 2020年8月24日
Python图像处理,366页pdf,Image Operators Image Processing in Python
相关论文
Arxiv
18+阅读 · 2024年12月27日
Arxiv
176+阅读 · 2023年4月20日
A Survey of Large Language Models
Arxiv
501+阅读 · 2023年3月31日
Generalized Out-of-Distribution Detection: A Survey
Arxiv
15+阅读 · 2021年10月21日
A Survey on Edge Intelligence
Arxiv
52+阅读 · 2020年3月26日
Exploring Visual Relationship for Image Captioning
Arxiv
15+阅读 · 2018年9月19日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员