TL;DR
Large Language Models (LLMs) struggle to maintain coherent long-term memory over extended conversations due to context window limits. This paper introduces MemGAS, a novel retrieval-augmented memory framework that stores dialogue at multiple granularities (sessions, turns, summaries, keywords) and uses an entropy-based router to dynamically select the best level of detail for any given query, significantly boosting both retrieval accuracy and question-answering performance.
What Problem Does This Paper Address?
As users interact with AI agents over weeks or months, the conversation history grows massive. Because LLMs have limited context windows, developers typically use Retrieval-Augmented Generation (RAG) to store past conversations in a database and fetch relevant chunks when the user asks a question.
However, existing memory systems usually rely on a single granularity—for example, they only store raw session transcripts, or they only store high-level summaries. This creates a painful trade-off:
- Too coarse (Summaries only): You lose specific, fine-grained details.
- Too fine (Raw turns only): You pull in massive amounts of conversational noise, confusing the LLM.
Furthermore, answering complex questions (e.g., "How many online courses have I completed in total?") often requires connecting a specific keyword in one session to a broad summary in another. Single-granularity systems fail to capture these cross-session, cross-granularity links, leading to partial retrieval and incorrect answers.
Methods: The MemGAS Framework
To solve this, the authors propose MemGAS (Multi-Granularity Association and Selection), which operates in four main steps:
- Multi-Granular Memory Construction: Instead of picking one format, MemGAS keeps them all. For every conversation session, it stores the raw session, segments it into turns, and uses an LLM to generate a concise summary and a list of keywords.
- Dynamic Association via GMM: When a new memory is added, the system doesn't just dump it in a vector database. It uses a Gaussian Mixture Model (GMM) to cluster historical memories into "accept" (highly relevant) and "reject" (irrelevant) sets. This builds a clean association graph connecting related memories across time.
- Entropy-Driven Granularity Router: When a user asks a question, how does the system know whether to look at summaries, keywords, or raw turns? MemGAS calculates the similarity between the query and the memories at each granularity, then measures the Shannon entropy of those similarity scores.
- Low entropy means the query strongly matches one specific memory but not others (high confidence).
-
High entropy means the query matches everything equally or poorly (low confidence). The router automatically assigns higher weights to the granularities with the lowest entropy.
-
Retrieval and Filtering: Finally, MemGAS runs Personalized PageRank (PPR) over the association graph to surface memories that are both directly relevant and contextually linked. An LLM then filters out redundant information before passing the final context to the generator.
Datasets
The authors evaluated MemGAS on four comprehensive long-term memory benchmarks designed to test dynamic memorization and multi-session reasoning:
- LongMemEval-s & LongMemEval-m: Datasets featuring 50 and 500 sessions per question, respectively, testing temporal reasoning, knowledge updates, and multi-session logic.
- LoCoMo: A dataset of very long conversations (averaging 300 turns) focusing on multi-hop retrieval and adversarial questions.
- Long-MT-Bench+: A reconstructed benchmark merging consecutive sessions to evaluate long-range conversational mechanisms.
Key Insights and Ideas
- Different queries demand different granularities: The authors found that temporal reasoning queries perform best when retrieving raw session-level data, while single-session preference queries do best with summary-level data. A fixed-granularity system is doomed to fail on diverse query types; adaptive routing is essential.
- Entropy is an elegant proxy for confidence: Using Shannon entropy to route queries eliminates the need for a separate, trained classification model to pick the right granularity. It mathematically naturally favors the representation where the signal-to-noise ratio is sharpest.
- Graph propagation finds "hidden" memories: By using Personalized PageRank on the GMM-built association graph, the system successfully retrieves memories that have low direct embedding similarity to the query but are highly contextually relevant (e.g., a follow-up conversation that doesn't explicitly repeat the target keywords).
Key Results
MemGAS consistently outperformed state-of-the-art baselines, including standard RAG (Contriever), recursive summarization (RecurSum), and advanced graph/tree-based memory systems (HippoRAG 2, RAPTOR).
- Question Answering: On LongMemEval-s, MemGAS achieved an F1 score of 20.38 and a GPT4o-as-Judge score of 60.20, comfortably beating the next best structured memory baseline, HippoRAG 2 (F1: 14.73, GPT4o-J: 57.60).
- Retrieval Accuracy: On the same dataset, MemGAS achieved a Recall@10 of 94.47%, compared to Contriever's 90.00% and HippoRAG 2's 91.28%.
- High Efficiency: Despite building a multi-granular graph, MemGAS is surprisingly token-efficient. It required only 52.9 million input tokens to construct its memory on LongMemEval-s, compared to 111.1 million for HippoRAG 2 and 106.2 million for SeCom, because it avoids complex, iterative LLM graph-building steps.
Limitations and Future Work
- Latency Bottleneck: The authors note that LLM API calls (specifically for the final redundancy filtering and answer generation) account for over 98% of the system's end-to-end latency.
- Scaling Costs: While the GMM updates and PageRank algorithms are highly efficient (taking only milliseconds), their computational cost does scale linearly with the size of the memory graph.
- Future Directions: The findings suggest that future work could focus on replacing the LLM-based redundancy filter with a faster, smaller local model to drastically cut down on the remaining latency and API costs.
Summary updated