Skip to main content

Teaching LLMs memory management for unbounded context

Project description

MemGPT logo

MemGPT allows you to build LLM agents with self-editing memory

Try out our MemGPT chatbot on Discord!

You can now run MemGPT with open/local LLMs and AutoGen!

Discord arxiv 2310.08560 Documentation

🤖 Create perpetual chatbots with self-editing memory!


MemGPT demo video

🗃️ Chat with your data - talk to your local files or SQL database!

MemGPT demo video for sql search

Quick setup

Join Discord and message the MemGPT bot (in the #memgpt channel). Then run the following commands (messaged to "MemGPT Bot"):

  • /profile (to create your profile)
  • /key (to enter your OpenAI key)
  • /create (to create a MemGPT chatbot)

Make sure your privacy settings on this server are open so that MemGPT Bot can DM you:
MemGPT → Privacy Settings → Direct Messages set to ON

set DMs settings on MemGPT server to be open in MemGPT so that MemGPT Bot can message you

You can see the full list of available commands when you enter / into the message box.

MemGPT Bot slash commands

What is MemGPT?

Memory-GPT (or MemGPT in short) is a system that intelligently manages different memory tiers in LLMs in order to effectively provide extended context within the LLM's limited context window. For example, MemGPT knows when to push critical information to a vector database and when to retrieve it later in the chat, enabling perpetual conversations. Learn more about MemGPT in our paper.

Running MemGPT locally

Install MemGPT:

pip install -U pymemgpt

Now, you can run MemGPT and start chatting with a MemGPT agent with:

memgpt run

If you're running MemGPT for the first time, you'll see two quickstart options:

  1. OpenAI: select this if you'd like to run MemGPT with OpenAI models like GPT-4 (requires an OpenAI API key)
  2. MemGPT Free Endpoint: select this if you'd like to try MemGPT on a top open LLM for free (currently variants of Mixtral 8x7b!)

Neither of these options require you to have an LLM running on your own machine. If you'd like to run MemGPT with your custom LLM setup (or on OpenAI Azure), select Other to proceed to the advanced setup.

Advanced setup

You can reconfigure MemGPT's default settings by running:

memgpt configure

In-chat commands

You can run the following commands in the MemGPT CLI prompt while chatting with an agent:

  • /exit: Exit the CLI
  • /attach: Attach a loaded data source to the agent
  • /save: Save a checkpoint of the current agent/conversation state
  • /dump: View the current message log (see the contents of main context)
  • /dump <count>: View the last messages (all if is omitted)
  • /memory: Print the current contents of agent memory
  • /pop: Undo the last message in the conversation
  • /pop <count>: Undo the last messages in the conversation. It defaults to 3, which usually is one turn around in the conversation
  • /retry: Pops the last answer and tries to get another one
  • /rethink <text>: Will replace the inner dialog of the last assistant message with the <text> to help shaping the conversation
  • /rewrite: Will replace the last assistant answer with the given text to correct or force the answer
  • /heartbeat: Send a heartbeat system message to the agent
  • /memorywarning: Send a memory warning system message to the agent

Once you exit the CLI with /exit, you can resume chatting with the same agent by specifying the agent name in memgpt run --agent <NAME>.

Documentation

See full documentation at: https://memgpt.readme.io

Installing from source

To install MemGPT from source, start by cloning the repo:

git clone git@github.com:cpacker/MemGPT.git

Then navigate to the main MemGPT directory, and do:

pip install -e .

Now, you should be able to run memgpt from the command-line using the downloaded source code.

If you are having dependency issues using pip install -e ., we recommend you install the package using Poetry (see below). Installing MemGPT from source using Poetry will ensure that you are using exact package versions that have been tested for the production build.

Installing from source (using Poetry)

First, install Poetry using the official instructions here.

Then, you can install MemGPT from source with:

git clone git@github.com:cpacker/MemGPT.git
poetry shell
poetry install

Python integration (for developers)

The fastest way to integrate MemGPT with your own Python projects is through the MemGPT client:

from memgpt import create_client

# Connect to the server as a user
client = create_client()

# Create an agent
agent_info = client.create_agent(
  name="my_agent",
  persona="You are a friendly agent.",
  human="Bob is a friendly human."
)

# Send a message to the agent
messages = client.user_message(agent_id=agent_info.id, message="Hello, agent!")

What open LLMs work well with MemGPT?

When using MemGPT with open LLMs (such as those downloaded from HuggingFace), the performance of MemGPT will be highly dependent on the LLM's function calling ability.

You can find a list of LLMs/models that are known to work well with MemGPT on the #model-chat channel on Discord, as well as on this spreadsheet.

Benchmarking an LLM on MemGPT (memgpt benchmark command)

To evaluate the performance of a model on MemGPT, simply configure the appropriate model settings using memgpt configure, and then initiate the benchmark via memgpt benchmark. The duration will vary depending on your hardware. This will run through a predefined set of prompts through multiple iterations to test the function calling capabilities of a model.

You can help track what LLMs work well with MemGPT by contributing your benchmark results via this form, which will be used to update the spreadsheet.

Support

For issues and feature requests, please open a GitHub issue or message us on our #support channel on Discord.

Datasets

Datasets used in our paper can be downloaded at Hugging Face.

Legal notices

By using MemGPT and related MemGPT services (such as the MemGPT endpoint or hosted service), you agree to our privacy policy and terms of service.

Roadmap

You can view (and comment on!) the MemGPT developer roadmap on GitHub: https://github.com/cpacker/MemGPT/issues/1200.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file pymemgpt_nightly-0.3.12.dev20240426103955.tar.gz.

File metadata

File hashes

Hashes for pymemgpt_nightly-0.3.12.dev20240426103955.tar.gz
Algorithm Hash digest
SHA256 3fff3671ed194b07e5b8a50092d9b40fbf72a1f5621f45a94486ad9d25f4a142
MD5 0bc19537617d58c3a87efca7ace1db99
BLAKE2b-256 d36201f7f345c14b15773dac231f696fbd7bb11233e8a4b9d5ccff4b768e3658

See more details on using hashes here.

File details

Details for the file pymemgpt_nightly-0.3.12.dev20240426103955-py3-none-any.whl.

File metadata

File hashes

Hashes for pymemgpt_nightly-0.3.12.dev20240426103955-py3-none-any.whl
Algorithm Hash digest
SHA256 dbaa0e7f7e69636f84f630c99d70e19ec4f93150b39a3991df5f4c2b978e2a7b
MD5 2c5e5786c43660860f9ed824a4de63fd
BLAKE2b-256 1e0cb77379a9c4981857ea22e3aefb90451c3e164cb2ea8f3f6d469d49d2936c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page