Structured Memory for Edge Language Models: Persistent Context and Corpus Retrieval via O(1) SSM State Injection
This work addresses the high latency of conventional Retrieval-Augmented Generation (RAG) on edge devices, caused by context prefilling and KV cache overhead, which impedes real-time interaction. The authors propose PRECOG, a mechanism integrating Structured Memory Consolidation (SMC) with state space models (SSMs), leveraging their fixed-size hidden states to encode document corpora offline and inject the optimal matching state directly at query time. This approach achieves O(1) complexity for zero-context reinjection and enables hierarchical persistent memory fusion, circumventing the positional entanglement limitations inherent in Transformers. Evaluated on a 1.2B-parameter TENNs-LLM, the method reduces prefill latency from 27 seconds to under 6 milliseconds—a speedup of approximately 4,500×—enabling real-time edge interaction while preserving answer quality comparable to traditional RAG.