Skip to main content

A graph-based memory vault for LLMs with intelligent retrieval

Project description

Mnemo Vault ๐Ÿง 

PyPI version Python Version License Code style: ruff pre-commit

A graph-based memory vault for LLMs with intelligent retrieval. Mnemo Vault provides a powerful solution to the LLM memory problem by combining knowledge graphs, hybrid retrieval, and semantic search.

โœจ Features

  • Graph-Based Memory: Navigate knowledge using bidirectional wikilinks and backlinks
  • Hybrid Retrieval: Combines keyword matching, graph traversal, and optional vector embeddings
  • Markdown-Native: Human-readable markdown files with YAML frontmatter
  • Memory Types: Support for episodic, semantic, procedural, and fact-based memories
  • Smart Indexing: Efficient caching system that only re-indexes changed files
  • CLI & Python API: Use via command line or integrate into your Python applications
  • Multiple LLM Providers: Works with Ollama, Claude, and OpenAI
  • Context Compression: Intelligent token budgeting for optimal context windows
  • Salience Scoring: Memory importance ranking for better retrieval

๐Ÿš€ Quick Start

Installation

pip install mnemo-vault

Install with optional dependencies:

# For OpenAI support
pip install mnemo-vault[openai]

# For Anthropic Claude support
pip install mnemo-vault[anthropic]

# For Ollama support
pip install mnemo-vault[ollama]

# For embedding support
pip install mnemo-vault[embeddings]

# Install everything
pip install mnemo-vault[all]

Python Usage

from mnemo import MemoryKernel, MemoryType

# Initialize the kernel attached to your vault path
kernel = MemoryKernel("~/my-vault")

# Ingest all notes in the vault
stats = kernel.ingest()
print(f"Indexed {stats['indexed']} memories.")

# Programmatically add a new memory
kernel.remember(
    title="Meeting Note",
    content="Decided to use BFS graph traversal for retrieval.",
    memory_type=MemoryType.EPISODIC,
    tags=["design", "retrieval"]
)

# Retrieve context for an LLM query
context = kernel.context_window(
    query="how does retrieval work?",
    tags=["retrieval"],
    depth=2,
    top_k=8
)

print(context)

๐ŸŽฏ CLI Usage

Mnemo comes with a powerful CLI for managing your vault and chatting with it.

Ingest

Index your markdown files into the graph database:

mnemo --vault ~/my-vault ingest

Force re-indexing all files:

mnemo --vault ~/my-vault ingest --force

Remember

Quickly add a memory from the command line:

mnemo --vault ~/my-vault remember \
    --title "Team Sync" \
    --content "Discussed Q3 goals." \
    --tags planning q3

Context Window

Generate context for a query:

mnemo --vault ~/my-vault context \
    --query "What did we decide about the database?" \
    --tags architecture \
    --depth 2 \
    --top-k 5

Ask (Interactive Chat)

Start an interactive chat session with your vault context:

mnemo --vault ~/my-vault ask --chat --provider ollama --model llama3

Or ask a single question:

mnemo --vault ~/my-vault ask \
    --query "Summarize our design decisions" \
    --provider claude \
    --model claude-3-5-sonnet-20240620

Diagnostics

Check your environment and connection to LLM providers:

mnemo --vault ~/my-vault doctor

๐Ÿ“– Core Concepts

Memory Types

Mnemo-Vault supports different types of memories inspired by cognitive science:

  • Episodic: Personal experiences and events (e.g., meeting notes)
  • Semantic: Facts and general knowledge (e.g., documentation)
  • Procedural: How-to knowledge and processes (e.g., tutorials)
  • Fact: Discrete factual information (e.g., configuration values)

Graph Traversal

The library uses BFS (Breadth-First Search) to traverse your knowledge graph:

# Retrieve nodes with depth=2 (2 hops from seed nodes)
nodes = kernel.retrieve_nodes(
    query="graph algorithms",
    depth=2,  # Traverse up to 2 levels deep
    top_k=10  # Return top 10 relevant memories
)

Salience Scoring

Each memory has a salience score (0.0-1.0) that represents its importance:

---
title: "Critical Architecture Decision"
salience: 0.9
memory_type: semantic
---

We decided to use PostgreSQL for better ACID guarantees...

๐Ÿ—๏ธ Project Structure

Mnemo-Vault/
โ”œโ”€โ”€ mnemo/              # Main package
โ”‚   โ”œโ”€โ”€ core/           # Core functionality
โ”‚   โ”‚   โ”œโ”€โ”€ kernel.py   # Memory kernel
โ”‚   โ”‚   โ”œโ”€โ”€ graph.py    # Graph implementation
โ”‚   โ”‚   โ”œโ”€โ”€ retriever.py # Hybrid retrieval
โ”‚   โ”‚   โ”œโ”€โ”€ indexer.py  # File indexing
โ”‚   โ”‚   โ””โ”€โ”€ parser.py   # Markdown parsing
โ”‚   โ”œโ”€โ”€ adapters/       # LLM and embedding adapters
โ”‚   โ”‚   โ”œโ”€โ”€ embeddings/ # Embedding providers
โ”‚   โ”‚   โ”œโ”€โ”€ frameworks/ # Framework integrations
โ”‚   โ”‚   โ””โ”€โ”€ llm/        # LLM providers
โ”‚   โ”œโ”€โ”€ storage/        # Storage and caching
โ”‚   โ””โ”€โ”€ cli.py          # CLI implementation
โ”œโ”€โ”€ tests/              # Test suite
โ””โ”€โ”€ examples/           # Example usage

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

  1. Clone the repository:

    git clone https://github.com/Indhar01/Mnemo-Vault.git
    cd Mnemo-Vault
    
  2. Install in development mode:

    pip install -e ".[all,dev]"
    
  3. Install pre-commit hooks:

    pre-commit install
    
  4. Run tests:

    pytest
    

๐Ÿ“š Documentation

๐Ÿ”’ Security

See our Security Policy for reporting vulnerabilities.

๐Ÿ“„ License

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

๐ŸŒŸ Acknowledgments

Inspired by the need for better memory management in LLM applications. Built with:

  • Graph-based knowledge representation
  • Hybrid retrieval strategies
  • Cognitive science principles

๐Ÿ“ฌ Contact & Support

๐Ÿšฆ Status

This project is in active development. While the core functionality is stable, the API may change in minor versions until we reach v1.0.0.


Made with โค๏ธ for better LLM memory management

Project details


Download files

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

Source Distribution

mnemo_vault-0.0.1.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

mnemo_vault-0.0.1-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file mnemo_vault-0.0.1.tar.gz.

File metadata

  • Download URL: mnemo_vault-0.0.1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for mnemo_vault-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a8d1ffdb4dd4d73e8bd7f101debafd692a243dc3fc057817271970a3a2f07fb0
MD5 23754fc9aaf0608d3acef539c1382175
BLAKE2b-256 1becfbda7c902a9f662c05743870b933bc794b1381cc0308b8d3cc0acba473d8

See more details on using hashes here.

File details

Details for the file mnemo_vault-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mnemo_vault-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for mnemo_vault-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e0d39f887af70046a1901e5dbc330a8bdba637b108da7d6c49d80e3993281ab
MD5 3d77334659d251ed6ec818a646fa4034
BLAKE2b-256 a7efcd641b0c6423502ef0e4c50f55ff1da0a05145ea910d4fed31e9180177cc

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