Skip to main content

🧠 SoulMemory

A memory system for AI companions that mimics human memory: remembers, recalls, forgets, consolidates, feels, connects, and reflects.

PyPI version Python License


🎯 Why SoulMemory?

Most AI chatbots have no memory. Every conversation starts from zero. SoulMemory gives your AI a persistent, human-like memory that:

  • Remembers important events (and auto-detects what's important)
  • 🔍 Recalls relevant memories using semantic search
  • Forgets trivial things naturally over time
  • 🗜️ Consolidates old memories to save space
  • 🔗 Links related memories automatically
  • 😊 Feels emotions (auto-detected, in English and Spanish)
  • 👥 Isolates memories per user (multi-user ready)
  • 🪞 Reflects the user's personality (key people, topics, mood)
  • 💾 Backs up everything to JSON
  • 🛡️ Protects critical memories from ever being forgotten

✨ Features

Feature Description
remember() Store memories with auto importance, emotion & associations
recall() Semantic search (understands meaning, not just keywords)
recall_by_emotion() Retrieve memories tagged with a specific emotion
recall_by_tag() Retrieve memories with a custom tag
about() Retrieve all memories mentioning a person or thing
recall_between() Retrieve memories within a date range
timeline() Chronological view of memories
get_associated() Retrieve memories linked to a given memory
associate() Manually link two memories together
reflect() Personality summary: dominant emotion, key people, topics
export_json() Backup all memories, tags and links to JSON
import_json() Restore a JSON backup
dream() Nightly maintenance: forget + consolidate
emotional_timeline() Dominant emotion per week
user() Isolated memory space per user
decay() Natural forgetting based on time and usage
consolidate() Compress similar old memories into summaries
stats() Memory statistics and insights

📦 Installation

pip install soulmemory

Or install from source:

git clone https://github.com/Romazea/soulmemory.git
cd soulmemory
pip install -e .

🚀 Quick Start

from soulmemory import SoulMemory

# Initialize (multilingual=True for true Spanish understanding)
mem = SoulMemory("my_memory.db")

# Store memories (importance, emotion & associations auto-detected)
mem.remember("My girlfriend proposed to me today!")
mem.remember("Had a sandwich for lunch")
mem.remember("¡Estoy muy feliz y emocionado!")  # Spanish works too!

# Search semantically
results = mem.recall("romantic news")
for r in results:
    print(r['content'])  # → "My girlfriend proposed to me today!"

# Clean up
mem.close()

🧩 Core Concepts

Memory Levels

Level Behavior Example
critical Never forgotten "My mother passed away"
important Fades slowly "Got a promotion at work"
normal Standard decay "Meeting with the team"
trivial Fades quickly "It's cloudy today"

Auto Importance Detection

SoulMemory automatically detects how important a memory is:

mem.remember("My girlfriend proposed to me!")
# → importance: 0.95, level: critical

mem.remember("It's raining outside")
# → importance: 0.35, level: trivial

Emotional Tagging (English + Spanish)

SoulMemory detects the emotion of each memory (six basic emotions + neutral):

mem.remember("We won the championship!")
# → emotion: "joy"

mem.remember("Mi perro murió ayer, estoy triste")
# → emotion: "sadness"

happy_memories = mem.recall_by_emotion("joy")

Memory Associations

Like the human brain, SoulMemory automatically links related memories:

mem.remember("Went to the gym in the morning")
mem.remember("Worked out at the gym today")
# → automatically linked (similar meaning)

results = mem.recall("gym")
linked = mem.get_associated(results[0]["id"])

# Or link memories manually
mem.associate(id_a, id_b)

Custom Tags

mem.remember("Luna is sick", tags=["mascotas", "ana"])

mem.recall_by_tag("mascotas")
mem.get_tags(memory_id)  # → ["mascotas", "ana"]

People & Time

mem.about("Ana")                               # everything about Ana
mem.recall_between("2026-08-01", "2026-08-10") # date range (inclusive)
mem.timeline(limit=10)                         # most recent first

Multi-User Support

Each user gets a fully isolated memory space:

roman = mem.user("roman")
ana = mem.user("ana")

roman.remember("My girlfriend proposed to me!")
ana.recall("romantic news")  # → only Ana's memories (no leaks)

mem.list_users()       # → ['ana', 'roman']
mem.delete_user("ana") # GDPR-style full deletion

Personality Reflection 🪞

A human-readable summary of who the user is:

mem.reflect()
# → {'memory_count': 42, 'dominant_emotion': 'joy',
#    'key_people': ['Ana'], 'top_tags': ['mascotas'],
#    'critical_memories': 3, 'summary': 'A life in ...'}

JSON Backups 💾

Your memories, safe forever:

mem.export_json("backup.json")  # memories + tags + links
mem.import_json("backup.json")  # restores everything

Multilingual Semantic Search 🌍

The default model (all-MiniLM-L6-v2) is English-optimized. For true Spanish understanding:

mem = SoulMemory("my.db", multilingual=True)
# → uses paraphrase-multilingual-MiniLM-L12-v2

mem.recall("la chica del café")  # understands Spanish for real

Warning: don't mix different embedding models in the same database.

The Forgetting Curve

Memories fade over time, just like human memory:

forgotten = mem.decay(decay_rate=0.85, threshold=0.2)
print(f"Forgot {forgotten} memories")

The formula:

score = importance × (decay_rate ^ days_since_access) + (access_count × 0.05)
  • More days without access → lower score
  • More times accessed → stays "alive"
  • Score below threshold → memory is forgotten
  • critical memories → never decay

Dreaming 😴

Run the nightly maintenance of the brain in one call:

result = mem.dream()
# → {'forgotten': 2, 'consolidated': 3}

Emotional Timeline

See the dominant emotion per week:

mem.emotional_timeline(weeks=4)
# → [{'week': 0, 'label': 'this week', 'dominant_emotion': 'joy', ...}]

📚 API Reference

SoulMemory(db_path="soulmemory.db", embedding_model=None, multilingual=False)

Create a memory instance. multilingual=True switches to a multilingual embedding model.

remember(content, importance=None, level=None, emotion=None, tags=None, auto_detect=True, auto_associate=True, user_id="default")

Store a new memory.

recall(query, limit=5, user_id="default")

Search for relevant memories.

recall_by_emotion(emotion, limit=10, user_id="default")

Retrieve memories tagged with a specific emotion.

recall_by_tag(tag, limit=10, user_id="default")

Retrieve memories with a specific custom tag.

about(name, limit=10, user_id="default")

Retrieve all memories that mention a person or thing.

recall_between(start, end, limit=50, user_id="default")

Retrieve memories created between two dates (inclusive).

timeline(limit=20, user_id="default")

Retrieve memories in chronological order (most recent first).

get_tags(memory_id)

Get the custom tags attached to a memory.

associate(memory_id_a, memory_id_b, strength=1.0)

Manually link two memories together.

get_associated(memory_id, limit=5)

Retrieve memories associated with a given memory.

reflect(user_id=None)

Generate a personality summary of the user.

export_json(path="soulmemory_backup.json", user_id=None)

Export all memories (with tags and links) to a JSON backup.

import_json(path)

Restore memories from a JSON backup.

decay(decay_rate=0.85, threshold=0.2, user_id=None)

Run the forgetting process.

consolidate(min_age_days=7, similarity_threshold=0.75, user_id=None)

Compress old, similar memories.

dream(user_id=None)

Run decay + consolidation together.

forget(memory_id)

Delete a specific memory by ID.

stats(user_id=None)

Get memory statistics.

emotional_timeline(weeks=4, user_id=None)

Dominant emotion per week (week 0 = current week).

user(user_id)

Get an isolated memory space for a specific user.

list_users() / delete_user(user_id)

Manage users and GDPR-style deletion.

🎬 Examples

The examples/ folder contains runnable demos:

python examples/quickstart.py         # Basic usage (Spanish)
python examples/test_decay.py         # The forgetting system
python examples/test_full.py          # Full feature test
python examples/demo_emotions.py      # Emotional tagging (EN + ES)
python examples/demo_associations.py  # Memory associations
python examples/demo_multiuser.py     # Multi-user isolation
python examples/demo_multilingual.py  # Multilingual semantic search (ES)
python examples/demo_companion.py     # Full AI companion simulation

🛠️ Use Cases

  • 🤖 AI Companions that remember your life
  • 💬 Chatbots with long-term memory
  • 🎮 Game NPCs that remember player interactions
  • 📔 Personal AI journals that evolve over time
  • 🏢 Multi-tenant services with isolated memory per user

🗺️ Roadmap

  • Core memory storage
  • Semantic search
  • Importance auto-detection
  • Decay (forgetting)
  • Consolidation
  • Emotional tagging (English + Spanish)
  • Memory associations
  • Multi-user support
  • Custom tags
  • Temporal recall & timelines
  • Personality reflection (reflect())
  • JSON backups
  • Multilingual embeddings
  • v1.0.0 stability hardening

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments


Made with ❤️ for the AI community

If you find this useful, please ⭐ star the repository!

Download files

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

Source Distribution

soulmemory-0.5.1.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

soulmemory-0.5.1-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file soulmemory-0.5.1.tar.gz.

File metadata

  • Download URL: soulmemory-0.5.1.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for soulmemory-0.5.1.tar.gz
Algorithm Hash digest
SHA256 8b2b30b903588ae0894da2d63bc83624d96886c3801a8dc8c026a2e418df4e60
MD5 89f408d99e6b63113ea2d612491cdb7e
BLAKE2b-256 3bc879f3a0c186277f9480fe4c0d4218beb495c60c0f796042411d17bcd5f79c

See more details on using hashes here.

File details

Details for the file soulmemory-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: soulmemory-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.3

File hashes

Hashes for soulmemory-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c56643589f73b0af92fba2dc953e9fc652566074bf3fa1c157327d7a9c20aa76
MD5 80a3cf5975aa0204fdb2b39e745695b4
BLAKE2b-256 dfd82531be82cdf4a75da43e74c0e38fc6f818ebbc05b3b15918b0b4612d93a0

See more details on using hashes here.

Supported by

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