Character Memory
AI Characters that live, remember and forget
Unlike other memory systems, Character Memory is not created for perfect recall, but to recall like a human, make bonds with users and keep track of the character's lifetime.
Like humans, in CharacterMemory, memories are recalled based on how emotionally impactful an episode was, in which location the character is, how recent is the memory and how often he recalls it.
Quick Start
Character Memory is both a library for developers and a ready-to-integrate tool for third party applications It provides a:
- pip package, used by developers to integrate the library
- MCP server, to integrate tools to read and edit memory into Agents
- API to query and save memory
- A Web Interface to create characters, view memories and chat with them
General Idea
Character Memory provides the following built-in memory systems (which can be enabled/disabled):
- Character Info: documents about the base character's lore, preferences and general information. Allows for lore consistency.
- Dialogue Examples: documents about examples of conversations between the character and other characters, used to copy it conversation style
- Fact Memory: save facts like "User is an engineer"
- Episodes Memory: save episodes like "I talked with the user about quantum physics"
- User directives: instructions given by the user that recall when needed, for example "When I ask you to do X, do Y". Mainly used for agent/assistant-like characters.
- Conversation Events: just saves conversations with the user. Recall on this memory is only done when necessary
- Emotions: keep track of current character's base emotions and emotions towards a user specifically
- World: keep track of the character's location, routines, sleep, hunger and energy
- Calendar: keep track of events
- User Summary: a rolling summary of the user
- Recall is usually done via Embeddings (Similarity) + BM25 (Lexical) search on all the memories, but also considering emotions, recency and other parameters. Some memories are made to stay regardless.
- Every 5 or 10 turns (user-defined), an LLM extraction process begins, which, considering already existing context, adds entries for all of the memories that need it.
- New extracted memories are compared to old memories, and a deduplication process begins if too similar memories or conflicting memories are detected.
Knowledge Graph Retrieval
Knowledge Graph Retrieval provides an aggregation of retrieval-based memories and connects them in order to provide a more advanced retrieval. There are multiple node types:
- Self node: maps the character itself, central and main node of the graph.
- Person node: maps person and their relationship with them, activates when a person is metioned or the character is talking to that person
- Episode node: maps episodes
- Fact node: maps facts
- Location node: maps locations, activates automatically when the character is in that location, or the location is mentioned
- Entity Node: maps entities, special objects or things in the conversation
Depending on the nodes they connect, edges can map the emotions about an event, relationship with other poeple, two events that get recalled together, the importance and how recent an event is.
At the end,
- People with strong bonds are more likely to be recalled
- Episodes that cause strong emotions, or that caused similar emotions to current are more likely to be recalled
- Episodes that are related to a common entity are more likely to be recalled
- Episodes that happened in the same location the character currently is, are more likely to be recalled
The knowledge graph requires one additional LLM call after every extraction. (And tens of LLM calls to ingest existing memories)
PostgreSQL and pgvector
Optional production storage is available with pip install 'charactermemory[postgres]'.
Set storage.backend: postgres and retrieval.backend: postgres to store conversations,
memories, and hybrid search indexes in PostgreSQL. SQLite + FAISS remain the defaults.
See setup, configuration, recovery, and concurrency measurements
and the local Compose example.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file charactermemory-0.1.0.tar.gz.
File metadata
- Download URL: charactermemory-0.1.0.tar.gz
- Upload date:
- Size: 535.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf29f39f743e49b4b0f925aa7b35fa54f1fa68f8cfd08160894137efb11c958c
|
|
| MD5 |
58ddb2c5f1f01b3dd1f5f18831e61346
|
|
| BLAKE2b-256 |
89a7b80f6a905469f5b0e1cdf000b492f7088d5a87c1bd3f9b6437fed521614a
|
File details
Details for the file charactermemory-0.1.0-py3-none-any.whl.
File metadata
- Download URL: charactermemory-0.1.0-py3-none-any.whl
- Upload date:
- Size: 524.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ecbd101e89909d8244945c49af54c7294d1a3c7b6e6108f17c58b040bf528af
|
|
| MD5 |
b232d386d1e5238c2a8cbae65a5ea8f2
|
|
| BLAKE2b-256 |
b08c0bf8930f9f68aeae4e5e2456349830d9d9fa16252628d4c043e727e78286
|