Skip to main content
QUICK REVIEW

[Paper Review] Think-in-Memory: Recalling and Post-thinking Enable LLMs with Long-Term Memory

Lei Liu, Xiaoyan Yang|arXiv (Cornell University)|Nov 15, 2023
Topic ModelingComputer Science5 citations
TL;DR

This paper proposes Think-in-Memory (TiM), a novel LLM-agnostic external memory mechanism that enables long-term memory by storing and evolving thoughts through recall and post-thinking. By eliminating repeated reasoning over history, TiM improves response consistency and performance in long conversations, achieving up to 97.3% top-10 retrieval accuracy and reducing retrieval time by 0.1ms compared to baselines.

ABSTRACT

Memory-augmented Large Language Models (LLMs) have demonstrated remarkable performance in long-term human-machine interactions, which basically relies on iterative recalling and reasoning of history to generate high-quality responses. However, such repeated recall-reason steps easily produce biased thoughts, extit{i.e.}, inconsistent reasoning results when recalling the same history for different questions. On the contrary, humans can keep thoughts in the memory and recall them without repeated reasoning. Motivated by this human capability, we propose a novel memory mechanism called TiM (Think-in-Memory) that enables LLMs to maintain an evolved memory for storing historical thoughts along the conversation stream. The TiM framework consists of two crucial stages: (1) before generating a response, a LLM agent recalls relevant thoughts from memory, and (2) after generating a response, the LLM agent post-thinks and incorporates both historical and new thoughts to update the memory. Thus, TiM can eliminate the issue of repeated reasoning by saving the post-thinking thoughts as the history. Besides, we formulate the basic principles to organize the thoughts in memory based on the well-established operations, ( extit{i.e.}, insert, forget, and merge operations), allowing for dynamic updates and evolution of the thoughts. Furthermore, we introduce Locality-Sensitive Hashing into TiM to achieve efficient retrieval for the long-term conversations. We conduct qualitative and quantitative experiments on real-world and simulated dialogues covering a wide range of topics, demonstrating that equipping existing LLMs with TiM significantly enhances their performance in generating responses for long-term interactions.

Motivation & Objective

  • Address the issue of inconsistent reasoning in memory-augmented LLMs due to repeated recall of the same history.
  • Enable LLMs to maintain an evolved memory of historical thoughts to avoid redundant reasoning.
  • Design a memory mechanism that is agnostic to LLM architecture and supports dynamic memory updates.
  • Improve long-term response quality and coherence in real-world and simulated dialogues.
  • Introduce efficient retrieval via Locality-Sensitive Hashing for scalable long-context conversations.

Proposed method

  • Introduce a two-stage process: (1) recall relevant thoughts from memory before response generation, and (2) post-think and update memory after generation.
  • Store and evolve thoughts in memory using three core operations: insert, forget, and merge to enable dynamic memory evolution.
  • Apply Locality-Sensitive Hashing (LSH) to accelerate retrieval of relevant thoughts in long-term memory.
  • Organize thoughts in memory based on well-established principles to ensure consistency and scalability.
  • Integrate TiM with existing LLMs without architectural modifications, enabling LLM-agnostic deployment.
  • Use embedding-based similarity matching for retrieval, optimized via LSH to reduce computational cost.

Experimental results

Research questions

  • RQ1Can a memory mechanism that stores and evolves thoughts reduce reasoning inconsistency in LLMs during long conversations?
  • RQ2How does post-thinking after response generation improve memory quality and response consistency?
  • RQ3To what extent can TiM enhance response correctness and contextual coherence in real-world medical and multi-domain dialogues?
  • RQ4How efficient is TiM’s retrieval mechanism compared to standard pairwise similarity computation?
  • RQ5Does TiM outperform baseline memory mechanisms across diverse domains, including Chinese and English dialogues?

Key findings

  • TiM significantly improves response correctness and contextual coherence across all evaluated datasets, including KdConv (film, music, travel) and RMD (realistic patient-doctor conversations).
  • On the KdConv dataset, TiM achieves top-10 retrieval accuracy of 97.3%, demonstrating high effectiveness in retrieving relevant historical thoughts.
  • TiM reduces retrieval time by approximately 0.1ms per query compared to baseline pairwise similarity computation, showing improved efficiency.
  • The performance gain of TiM is more pronounced in Chinese dialogues than in English, suggesting potential language-specific advantages.
  • In real-world medical applications, TiM-enabled agents avoid forgetting critical symptoms, leading to more accurate and comprehensive diagnoses.
  • Qualitative results show that TiM helps LLMs produce more human-like, consistent, and contextually coherent responses by mimicking human memory workflows.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.