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
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")

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?")

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.2.0.tar.gz (17.3 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.2.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for soulmemory-0.2.0.tar.gz
Algorithm Hash digest
SHA256 41ea8420d3c8f424cc26be77bab09597c413b1953af73939720791d80c781600
MD5 f1b581ada570e572302bcaf896fd86f4
BLAKE2b-256 89b9257127eba2dc91fa9db77cc362d81b1b2bd4c0b888868f725f3cf61a18f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: soulmemory-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d742a50bee5d6001e3ac6424302c80bacece35006f6e85d1dc5e03a180377438
MD5 f64bcc2f993adc9c95b50654e15d52ed
BLAKE2b-256 1caf30782b67f1766a908bc4a07fc8527d9a57155cf4cfc55f528fcec29313e1

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