Hierarchical Memory for High-Efficiency Long-Term Reasoning in LLM Agents

AuthorsHaoran Sun, Shaoning Zeng

2025

TL;DR

H-MEM uses four-level hierarchical memory with positional index routing to cut retrieval complexity from O(a·10^6·D) to O((a + k·300)·D) while boosting average F1 by 14.98 points on LoCoMo.

SharePost on XLinkedIn

Read our summary here, or open the publisher PDF on the next tab.

THE PROBLEM

Flat vector memories scale to a · 10^6 entries and explode retrieval cost

Existing vector memory systems store all entries in a flat structure, leading to computational complexity O(a · 10^6 · D) as memory grows.

When LLM agents like MemoryBank handle long multi session dialogues, this flat retrieval makes long term reasoning slow and lets irrelevant memories dominate similarity search, hurting answer quality.

HOW IT WORKS

H-MEM — Hierarchical memory with positional index routing

H-MEM builds a four level hierarchy using Domain Layer, Category Layer, Memory Trace Layer, and Episode Layer, with positional index encoding and a dynamic memory update mechanism.

You can think of H-MEM like a book catalog: domains are shelves, categories are sections, memory traces are chapters, and episodes are the detailed pages linked by index numbers.

By routing queries layer by layer via index pointers instead of scanning all episodes, H-MEM enables targeted long term retrieval that plain context windows and flat vector stores cannot achieve.

DIAGRAM

Hierarchical retrieval pipeline with positional indices

This diagram shows how H-MEM performs top down FAISS retrieval using positional index pointers from domains to episodes during inference.

DIAGRAM

LoCoMo evaluation and efficiency comparison setup

This diagram shows how H-MEM is evaluated on LoCoMo tasks and compared to MemoryBank in computational efficiency experiments.

PROCESS

How H-MEM Handles a Long Term Dialogue Session

  1. 01

    Memory Storage

    H-MEM uses the Domain Layer, Category Layer, Memory Trace Layer, and Episode Layer to encode each interaction into multi level structured memory with dense vectors.

  2. 02

    Memory Retrieval

    H-MEM embeds the query, runs FAISS similarity at the Domain Layer, and follows positional index pointers down through Category and Memory Trace to Episode Layer.

  3. 03

    Memory Update

    H-MEM applies a dynamic memory regulation mechanism that adjusts memory weights along the hierarchy based on user approval, no feedback, or rebuttal.

  4. 04

    Computational Efficiency Analysis

    H-MEM runs Single Hop, Multi Hop, Temporal, Open Domain, and Adversarial tasks sequentially on LoCoMo to measure compute ops and latency under growing memory.

KEY CONTRIBUTIONS

Key Contributions

  • 01

    Hierarchical Memory Architecture

    H-MEM introduces a four level hierarchy with Domain Layer, Category Layer, Memory Trace Layer, and Episode Layer, enabling structured storage and index based retrieval in long term dialogues.

  • 02

    Dynamic Memory Update Mechanism

    H-MEM designs a dynamic memory regulation mechanism that adjusts memory weights using user feedback, extending Ebbinghaus forgetting curves to handle changing preferences.

  • 03

    LoCoMo Evaluation and Efficiency Gains

    H-MEM improves average F1 by 14.98 and BLEU 1 by 12.77 over baselines on LoCoMo while reducing adversarial task compute from 7.34 × 10^9 to 4.38 × 10^7 operations.

RESULTS

By the Numbers

Average F1

30.37 %

+4.64 over A-MEM on Qwen2.5 1.5b

Average BLEU-1

26.14 %

+4.44 over A-MEM on Qwen2.5 1.5b

Compute Ops A.

4.38 × 10^7

vs 7.34 × 10^9 for MemoryBank on adversarial tasks

Time A.

80.07 ms

vs 461.54 ms for MemoryBank on adversarial tasks

On the LoCoMo dataset, which includes Single Hop, Multi Hop, Temporal, Open Domain, and Adversarial questions, H-MEM consistently raises F1 and BLEU 1 while cutting compute and latency. These results show that H-MEM maintains long range coherence and efficient retrieval even as memory grows across up to 35 sessions and 9,000 tokens per dialogue.

BENCHMARK

By the Numbers

On the LoCoMo dataset, which includes Single Hop, Multi Hop, Temporal, Open Domain, and Adversarial questions, H-MEM consistently raises F1 and BLEU 1 while cutting compute and latency. These results show that H-MEM maintains long range coherence and efficient retrieval even as memory grows across up to 35 sessions and 9,000 tokens per dialogue.

BENCHMARK

Experimental results on the LoCoMo dataset are reported across five QA task categories

Average F1 on LoCoMo for Qwen2.5 1.5b across baselines and H-MEM.

KEY INSIGHT

The Counterintuitive Finding

H-MEM keeps inference time below 100 ms even at maximum memory load, while MemoryBank exceeds 400 ms with 461.54 ms on adversarial tasks.

This is surprising because both systems use vector retrieval, yet H-MEM’s hierarchical routing and positional indices overturn the assumption that more memory must always mean much slower retrieval.

WHY IT MATTERS

What this unlocks for the field

H-MEM unlocks scalable long term reasoning by letting LLM agents traverse four level hierarchical memory with index based routing instead of flat similarity search.

Builders can now deploy smaller 1.5B to 3B models with H-MEM to handle multi session, 9,000 token dialogues while maintaining coherent answers and bounded retrieval cost.

~12 min read← Back to papers

Related papers

Agent MemoryLong-Term Memory

Adaptive Memory Admission Control for LLM Agents

Guilin Zhang, Wei Jiang et al.

· 2026

A-MAC scores candidate memories using Utility, Confidence, Novelty, Recency, and Type Prior combined by a learned linear admission policy with Algorithm 1 A-MAC Memory Admission. On the LoCoMo benchmark, A-MAC achieves F1 0.583 and 2644 ms latency, improving F1 by 0.042 and reducing latency by 1187 ms compared to A-mem.

Long-Term Memory

Advancing Open-source World Models

Robbyant Team, Zelin Gao et al.

arXiv 2026 · 2026

LingBot-World combines a Data Engine, Fundamental World Model, Action-Conditioned World Model, and Post-Training causal adaptation to turn a 28B-parameter video generator into a real-time interactive world simulator. On the VBench benchmark, LingBot-World achieves a dynamic degree of 0.8857 versus 0.7612 for Yume-1.5, while also improving imaging quality to 0.6683.

BenchmarkBenchmarkLong-Term Memory

AgenticAI-DialogGen: Topic-Guided Conversation Generation for Fine-Tuning and Evaluating Short- and Long-Term Memories of LLMs

Manoj Madushanka Perera, Adnan Mahmood et al.

· 2026

AgenticAI-DialogGen chains ChatPreprocessor, KnowledgeExtractor, TopicAnalyzer, KnowledgeGraphBuilder, PersonaGenerator, DuelingChat Agent, ConversationValidator, ConversationRefiner, QAGeneration, and PostProcessing to turn raw multi-session chats into topic-guided, persona-grounded conversations with explicit short- and long-term memories. On the TGC / KG memory QA benchmark, Mistral-7B fine-tuned within AgenticAI-DialogGen achieves 87.36 F1, compared to GPT-4’s 83.77 F1 in a zero-shot setting on the same task.

Questions about this paper?

Paper: Hierarchical Memory for High-Efficiency Long-Term Reasoning in LLM Agents

Answers use this explainer on Memory Papers.

Checking…