Statistical Independence Aware Caching for LLM Workflows

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Dai, Yihan, Bouras, Dimitrios Stamatios, Jia, Haoxiang, Mechtaev, Sergey
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866908677770838016
author Dai, Yihan
Bouras, Dimitrios Stamatios
Jia, Haoxiang
Mechtaev, Sergey
author_facet Dai, Yihan
Bouras, Dimitrios Stamatios
Jia, Haoxiang
Mechtaev, Sergey
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2511_22118
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Statistical Independence Aware Caching for LLM Workflows
Dai, Yihan
Bouras, Dimitrios Stamatios
Jia, Haoxiang
Mechtaev, Sergey
Software Engineering
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.
title Statistical Independence Aware Caching for LLM Workflows
topic Software Engineering
url https://arxiv.org/abs/2511.22118