Skip to main content

🧠 SoulMemory

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

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
  • 🛡️ Protects critical memories from ever being forgotten

✨ Features

Feature Description
remember() Store memories with auto importance detection
recall() Semantic search (understands meaning, not just keywords)
recall_by_emotion() Retrieve memories tagged with a specific emotion
get_associated() Retrieve memories linked to a given memory
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/YOUR_USERNAME/soulmemory.git
cd soulmemory
pip install -e .

🚀 Quick Start

from soulmemory import SoulMemory

# Initialize
mem = SoulMemory("my_memory.db")

# Store memories (importance auto-detected)
mem.remember("My girlfriend proposed to me today!")
mem.remember("Had a sandwich for lunch")

# 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:

# No need to specify importance - it's detected
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

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

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

mem.remember("My dog passed away")
# → emotion: "sadness"

# Recall memories by emotion
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)

# See what's connected to a memory
results = mem.recall("gym")
linked = mem.get_associated(results[0]["id"])

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

The Forgetting Curve

Memories fade over time, just like human memory:

# Run the forgetting process
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

📚 API Reference

remember(content, importance=None, level=None, emotion=None, auto_detect=True)

Store a new memory.

mem.remember("First date with Ana at the coffee shop")

recall(query, limit=5)

Search for relevant memories.

results = mem.recall("what do I know about Ana?")

recall_by_emotion(emotion, limit=10)

Retrieve memories tagged with a specific emotion ('joy', 'sadness', 'anger', 'fear', 'surprise', 'disgust', 'neutral').

joy_memories = mem.recall_by_emotion('joy')

get_associated(memory_id, limit=5)

Retrieve memories associated with a given memory.

linked = mem.get_associated(memory_id)

associate(memory_id_a, memory_id_b, strength=1.0)

Manually link two memories together.

mem.associate(id_a, id_b)

decay(decay_rate=0.85, threshold=0.2)

Run the forgetting process.

forgotten_count = mem.decay()

consolidate(min_age_days=7, similarity_threshold=0.75)

Compress old, similar memories.

consolidated = mem.consolidate()

stats()

Get memory statistics.

print(mem.stats())
# → {'total_memories': 42, 'by_level': {'critical': 3, ...}}

🛠️ 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

🗺️ Roadmap

  • Core memory storage
  • Semantic search
  • Importance auto-detection
  • Decay (forgetting)
  • Consolidation
  • Emotional tagging
  • Memory associations
  • Multi-user support

🤝 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.3.0.tar.gz (19.5 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.3.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for soulmemory-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5da1474f565a535c0d4ae1c306dedfbf6cef24e4858305377502eac39f3d35c9
MD5 19344b6a3301cef6e097bf746e90d02a
BLAKE2b-256 c20fadc4c3e7031a75b1f436b4f5998e4ee7f787c7ef4395cae4898c3102b00c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: soulmemory-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b83b0fbcbf6f8ba6dcded3c99ebca97a9785b90fd9528b43a51289cde4fc43
MD5 06604c77d31b069af11a8a7038a49eda
BLAKE2b-256 7fe4568d6a33b83345c9265a22d715715baa990fcafa612a43fb7ffd9b67388a

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