Skip to main content
QUICK REVIEW

[Paper Review] MemGPT: Towards LLMs as Operating Systems

Charles Packer, Sarah Wooders|arXiv (Cornell University)|Oct 12, 2023
Topic ModelingComputer Science34 citations
TL;DR

MemGPT introduces an OS-inspired memory hierarchy to extend the effective context of fixed-context LLMs by paging data between main context and external storage, improving long-document analysis and multi-session conversations.

ABSTRACT

Large language models (LLMs) have revolutionized AI, but are constrained by limited context windows, hindering their utility in tasks like extended conversations and document analysis. To enable using context beyond limited context windows, we propose virtual context management, a technique drawing inspiration from hierarchical memory systems in traditional operating systems that provide the appearance of large memory resources through data movement between fast and slow memory. Using this technique, we introduce MemGPT (Memory-GPT), a system that intelligently manages different memory tiers in order to effectively provide extended context within the LLM's limited context window, and utilizes interrupts to manage control flow between itself and the user. We evaluate our OS-inspired design in two domains where the limited context windows of modern LLMs severely handicaps their performance: document analysis, where MemGPT is able to analyze large documents that far exceed the underlying LLM's context window, and multi-session chat, where MemGPT can create conversational agents that remember, reflect, and evolve dynamically through long-term interactions with their users. We release MemGPT code and data for our experiments at https://memgpt.ai.

Motivation & Objective

  • Address the context-window limitations of fixed-context LLMs in long conversations and long documents.
  • Proposal of a virtual context management system inspired by operating system memory hierarchies.
  • Enable reading/writing external data sources via LLM function calls to manage memory.
  • Demonstrate improved performance in document analysis and conversational agents over baselines.
  • Release code and datasets to facilitate future long-context research.

Proposed method

  • Define a two-tier memory hierarchy: main context (prompt tokens) and external context (archival storage).
  • Introduce an LLM OS with function calls to move data between memory tiers and manage memory automatically.
  • Implement a queue manager that handles memory pressure, evictions, and recursive summaries for overflow control.
  • Enable function chaining for multi-step retrieval and iterative memory updates within inference loops.
  • Use a system prompt with memory hierarchy instructions and a function schema to guide memory access by the LLM.
  • Evaluate MemGPT on long-document QA and multi-session conversational tasks using augmentations of MSC and a document QA benchmark.
Figure 1: MemGPT (left) writes data to persistent memory after it receives a system alert about limited context space.
Figure 1: MemGPT (left) writes data to persistent memory after it receives a system alert about limited context space.

Experimental results

Research questions

  • RQ1Can MemGPT sustain coherence and engagement in long-running conversations by exploiting external memory beyond the LLM's context window?
  • RQ2Does the OS-inspired memory hierarchy improve performance on long document QA and multi-hop retrieval tasks compared to fixed-context baselines?
  • RQ3How effective is paginated recall and memory eviction in maintaining relevant context for inference?
  • RQ4Can MemGPT support multi-hop information retrieval across multiple data sources (nested KV retrieval) beyond native context size?

Key findings

  • MemGPT outperforms fixed-context baselines in deep memory retrieval for multi-session chats across underlying models (e.g., GPT-4 Turbo: MemGPT 93.4% vs baseline 35.3%).
  • In conversation opener tasks, MemGPT-based openers match or exceed human-openers across several models, showing enhanced engagement.
  • Document QA with MemGPT scales beyond the fixed context window and outperforms truncation-based baselines, particularly with GPT-4 variants.
  • MemGPT enables multi-hop, nested key-value retrieval where fixed-context models degrade quickly as nesting increases, demonstrating robust memory-based reasoning.
  • The approach maintains consistency and coherence over long sessions by leveraging a persistent memory backlog rather than lossy summarization of history.
Figure 2: MemGPT (left) can search out-of-context data to bring relevant information into the current context window.
Figure 2: MemGPT (left) can search out-of-context data to bring relevant information into the current context window.

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.