Working with Memory

Memory Types

With Zep's Chat History features you can ensure that your assistant's responses are always relevant to the conversation.

The Zep Memory API provides a high-level interface for persisting and retrieving memory artifacts such as Messages, Sessions, Facts, and Summaries.

The Memory API is Session-specific, opinionated, and offers a number of Memory Types designed for different memory retrieval use cases.

Looking for more control over what artifacts are returned or retrieval of artifacts from across multiple Sessions? Explore using Zep’s Search API

Selecting your Memory Type

Zep offers three memory types for retrieving artifacts from a Session: Perpetual Memory, Summary Retriever Memory, and Message Window Buffer Memory.

Review the Memory Get API documentation for additional arguments and options.

1memory = await client.memory.get(
2 session_id,
3 memory_type="perpetual" # perpetual, summary_retriever, or message_window
4)

Perpetual Memory

Perpetual Memory is Zep’s default memory type and it returns a combination of Facts, a Summary, and the most recent messages in a conversation.

The number of most recent messages can be configured via the last_n call argument. The Summary returned is the most recent summary created prior to the Nth most recent message. The default value of N is 6.

Perpetual Memory+
{Relevant Facts}Facts relevant to the current conversation.
{Prior Summary}The most recent summary created prior to the oldest message below.
{Messages}The most recent N messages in the chat history.

We’ve found that including the combination of Facts, a Summary, and recent messages in a prompt provides both factual context and nuance to the LLM and is a good starting point for many Assistant applications.

Perpetual Memory

Summary Retriever Memory

Summary Retriever Memory returns past Summaries relevant to the current conversation. It does this by running a semantic similarity search over past Summaries within a Session, reranking them, and returning the most relevant ones.

Since summaries are generated regularly and may be similar to one another, we rerank the returned summaries using MMR, a technique to increase the diversity of the returned results.

Alongside similar summaries, Zep also returns the most recent N messages in the chat history and the most recent summary created prior to the oldest message returned. These artifacts offer a rich context for your Assistant, particularly where nuance of the past conversation is important.

Summary Retriever Memory+
{Relevant Summaries}The most relevant summaries from the chat history.
{Prior Summary}The most recent summary created prior to the oldest message below.
{Messages}The most recent N messages in the chat history.

Message Window Buffer Memory

Message Window Buffer Memory is Zep’s simplest memory type and it returns the most recent N messages from the current conversation and the Summary generated prior to the oldest message returned.

Message Window Buffer Memory+
{Prior Summary}The most recent summary created prior to the oldest message below.
{Messages}The most recent N messages in the chat history.