This project has been archived by its maintainers, and is no longer receiving any updates.
Memotrix
Composable hybrid memory and RAG for AI agents.
Memotrix lets an agent remember files and free-text facts the same way LangChain-style tools compose: pick embeddings, pick a store, then add / search / delete. It is a Python library — not an LLM, not a chat UI, and not a hosted service.
It chunks documents, stores dense vectors (semantic) plus a keyword index (BM25 or Postgres full-text), and retrieves a small context window with hybrid search, optional rerank, and neighbor expansion.
Why use it
| You need | Memotrix does |
|---|---|
| Agent long-term memory | add_text for facts, chat turns, procedures (semantic / episodic / procedural) |
| RAG over files | add("report.pdf") then search("what is the revenue?") |
| Hybrid retrieval | Dense (HNSW or pgvector) + sparse (BM25 or Postgres tsvector), fused with RRF |
| Tight context | Default top_k=3 and neighbor-window expansion, not five full files |
| No silent secrets | You pass the embedding model and DSN. Nothing is defaulted. |
Install
Python 3.10+. A bare pip install memotrix only installs python-dotenv. Use an extra:
pip install memotrix[memory]
Postgres + file extractors:
pip install memotrix[postgres,memory,extractors]
| Extra | Enables |
|---|---|
memory |
in-process HNSW + BM25 + Sentence-Transformers (minimum to construct Memory) |
local |
HNSW + BM25 |
embeddings |
HuggingFace / Sentence-Transformers |
postgres |
PostgreSQL + pgvector |
extractors |
PDF, Office, HTML, CSV, images, RDF, … |
openai |
OpenAI embeddings and vision |
audio |
Whisper transcription |
all |
everything above |
Quick start
from memotrix import Memory
from memotrix.embeddings import HuggingFaceEmbeddings
from memotrix.vectorstores import InMemoryStore
embeddings = HuggingFaceEmbeddings(model="BAAI/bge-small-en-v1.5")
memory = Memory(embeddings=embeddings, store=InMemoryStore(embeddings))
memory.add_text("User prefers dark mode.", memory_type="semantic", source_id="prefs")
hits = memory.search("what theme does the user want?", top_k=3)
memory.delete("prefs")
memory.close()
Files:
memory.add("report.pdf")
hits = memory.search("what is the revenue?", memory_type="semantic")
print(memory.list_sources())
Postgres:
import os
from memotrix.vectorstores import PostgresStore
embeddings = HuggingFaceEmbeddings(model=os.environ["EMBEDDING_MODEL"])
memory = Memory(
embeddings=embeddings,
store=PostgresStore(connection=os.environ["DATABASE_URL"], embeddings=embeddings),
)
Or from the environment (EMBEDDING_MODEL required; DATABASE_URL when MEMOTRIX_BACKEND=postgres):
from memotrix import Memory
memory = Memory.from_env()
Agent memory
memory.add_text("Shipped hybrid search.", memory_type="episodic", session_id="2026-09-03")
memory.add_text("Always cite source_path.", memory_type="procedural")
memory.search("how should answers be cited?", memory_type="procedural")
session_id and memory_type are exact-match payload filters.
What it can ingest
PDF, DOCX, PPTX, TXT, Markdown, HTML, EPUB, CSV, Excel (.xlsx), JSON (FHIR / GeoJSON / chat sniff), YAML, XML, SQL, images, video, audio ([audio]), source code, SCORM, knowledge graphs, GeoJSON, email (.eml / .mbox), chat exports, and .log files.
Generic .zip and BIFF .xls are not supported. Convert spreadsheets to .xlsx.
Plug in your own extractor:
memory = Memory(embeddings=embeddings, extract_file=my_extractor)
Links
- Source: github.com/Matrixxboy/memotrix
- Full API: User guide
- License: MIT
Metadata
Release files for memotrix 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| memotrix-0.2.0.tar.gz | 102.1 kB | Without provenance | Details for memotrix-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memotrix-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for memotrix-0.2.0-py3-none-any.whl |
Total release size: 196.5 kB
Release files / memotrix-0.2.0.tar.gz
| Download URL | memotrix-0.2.0.tar.gz |
|---|---|
| Size | 102.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db3a3fe37c79d2e5860063bd07da8c2e0c211403b75b14f4160131e3215904d6
|
|
BLAKE2b-256 checksum How to use checksums |
74a69c95b7a543c952267dcac6546ddce92717529c825d7f28c82c31b87e0f70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / memotrix-0.2.0-py3-none-any.whl
| Download URL | memotrix-0.2.0-py3-none-any.whl |
|---|---|
| Size | 94.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d1c95df0796962fbec9f76deb05d556c31be4bddd4a905d0132926a73e99803
|
|
BLAKE2b-256 checksum How to use checksums |
d4308cf5b700790b12a4476346013e8d0efee96f891b2c5e1826445b564f41dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for memotrix 0.2.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.