Abstract
Large Language Model (LLM) conversational agents often struggle to maintain coherence over long-term interactions due to limited context windows. Traditional Retrieval-Augmented Generation (RAG) systems rely on single-granularity memory chunks, which often lead to either excessive noise or loss of critical detail. We present MemGAS (Multi-Granularity Association and Selection), a framework that stores memories across four granularities—turns, sessions, summaries, and keywords. By employing a Gaussian Mixture Model for memory association and an entropy-based router for dynamic granularity selection, MemGAS significantly enhances retrieval accuracy and question-answering performance on long-term memory benchmarks while maintaining computational efficiency.
Introduction
As AI assistants engage in interactions spanning weeks or months, the resulting conversation history grows beyond the processing capacity of standard LLM context windows. Current solutions utilize RAG to store and retrieve relevant history. However, these systems typically segment logs at a fixed granularity—either raw transcripts or high-level summaries. This "Goldilocks" problem results in raw transcripts being too noisy and summaries being too sparse. Answering complex queries often requires a hybrid approach that connects specific keywords with broader session contexts.
Methodology: The MemGAS Framework
MemGAS addresses these limitations through a multi-stage process designed to mimic human memory consolidation and retrieval.
1. Multi-Granularity Memory Construction
MemGAS stores memory in four distinct formats: raw session transcripts, turn-level dialogue segments, LLM-generated summaries, and extracted keywords. This ensures that both fine-grained details and high-level themes are preserved.
2. Dynamical Memory Association
New memories are embedded and compared against historical data. A Gaussian Mixture Model (GMM) clusters these comparisons into "Accept" and "Reject" sets, building a clean, interconnected graph of memories. This process prevents the accumulation of spurious ties that can degrade retrieval performance over time.
3. Entropy-Driven Router
To determine the optimal granularity for a given query, MemGAS calculates the similarity between the query and memories at each level. It then measures the Shannon entropy of these scores. A sharp match in a specific granularity (e.g., keywords) results in low entropy, signaling high confidence. The router dynamically weights granularities with the lowest entropy.
4. Retrieval and Filtering
The system applies a Personalized PageRank (PPR) algorithm over the memory graph to identify the most relevant context nodes. A lightweight LLM-based filter then removes redundant information before the final context is provided to the main LLM for response generation.
Experimental Evaluation
The authors evaluated MemGAS on four long-term memory benchmarks: LongMemEval-s, LongMemEval-m (scaling up to 500 sessions), LoCoMo (focusing on temporal reasoning), and Long-MT-Bench+.
Key Results
MemGAS consistently outperformed state-of-the-art baselines, including HippoRAG, RAPTOR, and SeCom.
- QA Performance: On LongMemEval-s, MemGAS achieved an F1 score of 20.38, significantly higher than HippoRAG's 14.73.
- Retrieval Accuracy: The system reached a 94.47% Recall@10 on LongMemEval-s, surpassing both HippoRAG (91.28%) and standard Contriever (90.00%).
- Efficiency: MemGAS is token-efficient, processing 52.9 million input tokens on LongMemEval-s—comparable to the raw corpus size and far less than graph-heavy methods like HippoRAG (111.1 million).
- Overhead: The multi-granularity approach adds only approximately 10% extra RAM overhead, making it a practical solution for real-world deployment.
Discussion and Insights
The study reveals that different query types favor different granularities. For instance, temporal reasoning queries benefit from raw session data, whereas single-session preference queries are better served by summary-level data. The entropy-driven routing mechanism acts as an effective, tuning-free proxy for confidence, allowing the system to automatically adapt to the specific needs of each user query.
Conclusion and Future Work
While MemGAS significantly improves long-term memory retrieval, challenges remain. High Top-K retrieval can introduce noise that distracts the LLM, a manifestation of the "lost in the middle" phenomenon. Future research will focus on refining redundancy filters and extending the dynamic routing framework to multimodal memory systems involving text, images, and audio.
Summary updated