MemGPT
Try out our MemGPT chatbot on Discord!
LlamaIndex!
📄 You can also talk to docs - for example ask about
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
You can see the full list of available commands when you enter /
into the message box.
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 dependencies:
pip install -r requirements.txt
Add your OpenAI API key to your environment:
export OPENAI_API_KEY=YOUR_API_KEY
To run MemGPT for as a conversation agent in CLI mode, simply run main.py
:
python3 main.py
To create a new starter user or starter persona (that MemGPT gets initialized with), create a new .txt
file in /memgpt/humans/examples or /memgpt/personas/examples, then use the --persona
or --human
flag when running main.py
. For example:
# assuming you created a new file /memgpt/humans/examples/me.txt
python main.py --human me.txt
main.py
flags
--persona
load a specific persona file
--human
load a specific human file
--first
allows you to send the first message in the chat (by default, MemGPT will send the first message)
--debug
enables debugging output
--archival_storage_faiss_path=<ARCHIVAL_STORAGE_FAISS_PATH>
load in document database (backed by FAISS index)
--archival_storage_files="<ARCHIVAL_STORAGE_FILES_GLOB>"
pre-load files into archival memory
--archival_storage_sqldb=<SQLDB_PATH>
load in SQL database
Interactive CLI commands
While using MemGPT via the CLI you can run various commands:
/exit
exit the CLI
/save
save a checkpoint of the current agent/conversation state
/load
load a saved checkpoint
/dump
view the current message log (see the contents of main context)
/memory
print the current contents of agent memory
/pop
undo the last message in the conversation
/heartbeat
send a heartbeat system message to the agent
/memorywarning
send a memory warning system message to the agent
Example applications
Use MemGPT to talk to your Database!
MemGPT's archival memory let's you load your database and talk to it! To motivate this use-case, we have included a toy example.
Consider the test.db
already included in the repository.
id | name | age |
---|---|---|
1 | Alice | 30 |
2 | Bob | 25 |
3 | Charlie | 35 |
To talk to this database, run:
python main.py --archival_storage_sqldb=memgpt/personas/examples/sqldb/test.db
And then you can input the path to your database, and your query.
Please enter the path to the database. test.db
...
Enter your message: How old is Bob?
...
🤖 Bob is 25 years old.
Loading local files into archival memory
MemGPT enables you to chat with your data locally -- this example gives the workflow for loading documents into MemGPT's archival memory.
To run our example where you can search over the SEC 10-K filings of Uber, Lyft, and Airbnb,
-
Download the .txt files from Hugging Face and place them in
memgpt/personas/examples/preload_archival
. -
In the root
MemGPT
directory, runpython3 main.py --archival_storage_files="memgpt/personas/examples/preload_archival/*.txt" --persona=memgpt_doc --human=basic
If you would like to load your own local files into MemGPT's archival memory, run the command above but replace --archival_storage_files="memgpt/personas/examples/preload_archival/*.txt"
with your own file glob expression (enclosed in quotes).
Talking to LlamaIndex API Docs
MemGPT also enables you to chat with docs -- try running this example to talk to the LlamaIndex API docs!
-
a. Download LlamaIndex API docs and FAISS index from Hugging Face.
# Make sure you have git-lfs installed (https://git-lfs.com) git lfs install git clone https://huggingface.co/datasets/MemGPT/llamaindex-api-docs mv llamaindex-api-docs
-- OR --
b. Build the index:
- Build
llama_index
API docs withmake text
. Instructions here. Copy over the generated_build/text
folder tomemgpt/personas/docqa
. - Generate embeddings and FAISS index.
cd memgpt/personas/docqa python3 scrape_docs.py python3 generate_embeddings_for_docs.py all_docs.jsonl python3 build_index.py --embedding_files all_docs.embeddings.jsonl --output_index_file all_docs.index
- Build
-
In the root
MemGPT
directory, runpython3 main.py --archival_storage_faiss_path=<ARCHIVAL_STORAGE_FAISS_PATH> --persona=memgpt_doc --human=basic
where
ARCHIVAL_STORAGE_FAISS_PATH
is the directory whereall_docs.jsonl
andall_docs.index
are located. If you downloaded from Hugging Face, it will bememgpt/personas/docqa/llamaindex-api-docs
. If you built the index yourself, it will bememgpt/personas/docqa
.
Support
- By default MemGPT will use
gpt-4
, so your API key will requiregpt-4
API access.
If you have any further questions, or have anything to share, we are excited to hear your feedback!
- For issues and feature requests, please open a GitHub issue.
Datasets
Datasets used in our paper can be downloaded at Hugging Face.