Skip to main content

mindlayer

PyPI version CI License: MIT Python 3.9+

Open-source, model-agnostic memory layer for LLMs.

Drop mindlayer into any LLM application to give it persistent, structured memory — no API key required, no infrastructure to run, no vendor lock-in.

import mindlayer

with mindlayer.MemCore() as mem:
    mem.add("My name is Alice. I prefer dark mode and I work in Python.")
    results = mem.search("programming preferences")
    for r in results:
        print(r.content)

Why mindlayer?

Most LLM apps lose context between sessions. Vector databases are heavy to set up. Existing memory libraries tie you to a specific LLM or cloud service.

mindlayer is:

  • Zero config — SQLite storage, works out of the box
  • Model agnostic — plug in any LLM or use the built-in Gemma extractor
  • Pure library — no daemon, no background process, no ports
  • Open source — MIT licensed, runs fully offline

Installation

pip install mindlayer-ai

With semantic vector search (downloads ~130MB embedding model on first use):

pip install "mindlayer-ai[vector]"

With LLM-powered extraction (downloads Gemma ~800MB on first use):

pip install "mindlayer-ai[llm]"

Architecture

mindlayer uses a 3-layer memory model inspired by human cognition:

Layer Description Promoted when
Working Short-term, recent facts accessed 3+ times
Episodic Mid-term, frequently used facts accessed 10+ times
Semantic Long-term, core knowledge stays permanently

5 core primitives

Primitive What it does
Ingestion Extracts discrete facts from raw text
Consolidation Promotes memories across layers
Decay Reduces scores on idle memories, prunes stale ones
Retrieval Fetches relevant memories, boosts access count
Conflict resolution Deduplicates near-duplicate memories

Usage

Default (rule-based extractor, no LLM needed)

import mindlayer

mem = mindlayer.MemCore()
mem.add("I am a Python developer. I love open source.")
results = mem.search("developer")

With semantic vector search (best recall)

# pip install "mindlayer[vector]"
mem = mindlayer.MemCore(use_vector=True)
mem.add("I prefer concise explanations and dislike verbose output.")
results = mem.search("communication style")  # matches semantically, not just by keyword

With Gemma LLM extractor (best quality)

mem = mindlayer.MemCore(use_llm=True)
# Downloads gemma-3-1b-it-Q4_K_M.gguf (~800MB) on first run
mem.add("Long conversation text with lots of context...")

Bring your own LLM extractor

from mindlayer.extractors.base import BaseExtractor

class MyExtractor(BaseExtractor):
    def extract(self, text: str) -> list[str]:
        # call OpenAI, Anthropic, Ollama, anything
        return ["fact 1", "fact 2"]

mem = mindlayer.MemCore(extractor=MyExtractor())

Custom storage backend

from mindlayer.storage.base import BaseStorage

class PostgresStorage(BaseStorage):
    # implement the interface
    ...

mem = mindlayer.MemCore(storage=PostgresStorage())

Memory maintenance

mem.consolidate()   # promote memories based on access patterns
mem.decay()         # decay and prune stale memories

Roadmap

  • Vector similarity search (FAISS / sqlite-vec)
  • Async support
  • PostgreSQL storage backend
  • LLM-based conflict resolution
  • REST API server mode
  • JavaScript / TypeScript port

Contributing

Contributions are welcome. Please open an issue before submitting large PRs.

git clone https://github.com/Genious07/mindlayer
cd mindlayer
pip install -e ".[dev,vector]"
pytest

License

MIT

Metadata

Release files for mindlayer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mindlayer 0.1.0
File Size Uploaded Provenance Actions
mindlayer-0.1.0.tar.gz 14.0 kB Without provenance Details for mindlayer-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mindlayer 0.1.0
File Interpreter ABI Platform Actions
mindlayer-0.1.0-py3-none-any.whl Python 3 none any Details for mindlayer-0.1.0-py3-none-any.whl

Total release size: 28.9 kB

Release files / mindlayer-0.1.0.tar.gz

Download URL mindlayer-0.1.0.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
76659490b605275628e8507439c68ebd0820df8a5ca5be25c2ae7f9e41266a38
BLAKE2b-256 checksum
How to use checksums
2601a17bd1ff92bf2541386bb4b4c484eaca9fc1b21ab99eff7849f0ddac0359
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / mindlayer-0.1.0-py3-none-any.whl

Download URL mindlayer-0.1.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a8d3d0af7ca9630b9afb64bbaa5916ff50747d58bce872788bf9fdcb3d00a91
BLAKE2b-256 checksum
How to use checksums
86ddd98f65d681f8b3ca57c052e2bb735dd6e963e7514e6a888b021b1fa7b6ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for mindlayer 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page