This release is a pre-release and may not be stable for production use.
PRME — Portable Relational Memory Engine
Local-first, embeddable memory for LLM-powered applications.
PRME gives agents and chatbots persistent memory through an append-only event log, typed relationships, and hybrid retrieval. It preserves source evidence, tracks changing claims, and packs relevant memories into a configurable token budget. The default backend runs locally in a portable directory; PostgreSQL is available for server deployments.
Current release: v0.15.0. Python 3.11+, synchronous and async clients, HTTP, MCP, and LangChain/LlamaIndex integrations.
Architecture
Four storage layers sit behind a unified memory API:
| Layer | Local implementation | Purpose |
|---|---|---|
| Event store | DuckDB | Immutable source events and durable operation records |
| Graph store | DuckDB tables and recursive CTEs | Typed memories, relationships, temporal validity, confidence, and provenance |
| Vector index | USearch | Semantic similarity search with versioned embeddings |
| Lexical index | Tantivy | BM25 full-text search |
The optional PostgreSQL backend uses PostgreSQL tables, pgvector, and full-text search behind the same API. Both backends default to exact vector search; approximate search is configurable.
Source text → event log → direct storage or LLM extraction → graph + indexes
Query → intent, entity, and time analysis
→ graph, vector, lexical, and recent-memory candidates
→ deterministic scoring and filtering
→ token-bounded context with provenance
- Ingestion:
store()writes a memory directly without an LLM.ingest()extracts entities, facts, and relationships through a configured provider. Deferred ingestion records durable work that can resume after restart. - Memory state: typed nodes carry owner, scope, lifecycle, confidence, validity windows, and source references. Explicit corrections and contradiction operations preserve earlier claims; automatic store-time supersedence is opt-in.
- Retrieval: combines multiple search paths and packs selected evidence into context. Structured assertion-state and aggregation APIs support exact stored claim queries and decimal totals beyond semantic top-k retrieval.
- Default retrieval behavior: candidates are ranked by reciprocal rank
fusion of their semantic and lexical ranks, with a recency boost on
current-state questions and an event-time tie-break. Packing uses balanced
ordering and renders each record as one plain line (the
readercontext format), while the full records stay in the bundle's sections and the retrieval receipt. These defaults changed after v0.12.0; Default retrieval settings lists the earlier values and the environment variables that restore them. - Organizer: maintains promotion, decay, summaries, deduplication, archival,
and index compaction. It runs opportunistically or through
prme organize; recurring schedules use an external timer. Shared stores should passuser_id. - Workspaces:
MemoryWorkspacemanages named local packs or PostgreSQL schemas with identity checks and scoped leases.
A local memory pack is a directory by default, or one file when you opt in:
my_memories/ # directory pack (the default)
├── memory.duckdb
├── vectors.usearch
├── lexical_index/
└── manifest.json # only when encryption is on
memories.prme # single-file pack (opt-in)
Giving MemoryClient a path that ends in .prme, or setting PRME_PACK_PATH,
selects the single-file layout: one DuckDB file holds the event log, the graph,
the vector snapshot and a pack manifest, and the lexical index is rebuilt in
memory when the pack opens. prme migrate copies a directory pack into a new
.prme file, and single-file packs
covers encryption, compaction and how retrieval compares across the layouts.
Search indexes can be regenerated from the durable graph with prme rebuild.
Event time, ingestion time, and validity time remain distinct. The knowledge_at
filter applies an ingestion cutoff to current graph/index state; exact historical
state replay is not currently available.
Current benchmarks
| Benchmark | Correct answers | Answer accuracy |
|---|---|---|
| LongMemEval-S | 453 / 500 | 90.6% |
| LoCoMo, non-adversarial questions | 1,250 / 1,540 | 81.2% |
LongMemEval-S by question type
| Question type | Correct answers | Answer accuracy |
|---|---|---|
| Single-session user | 69 / 70 | 98.6% |
| Single-session assistant | 54 / 56 | 96.4% |
| Knowledge update | 71 / 78 | 91.0% |
| Temporal reasoning | 120 / 133 | 90.2% |
| Single-session preference | 26 / 30 | 86.7% |
| Multi-session | 113 / 133 | 85.0% |
LoCoMo by question type
| Question type | Correct answers | Answer accuracy |
|---|---|---|
| Single-hop | 756 / 841 | 89.9% |
| Temporal | 256 / 321 | 79.8% |
| Multi-hop | 182 / 282 | 64.5% |
| Open-domain | 56 / 96 | 58.3% |
Measured on September 25, 2026 with the v0.13.0 retrieval defaults and a
3,996-token memory-context budget per question, over memory packs built with
store(), which never runs extraction. The defaults adopted on October 6
change what ingest() stores and how repeated text is packed, so they were
measured on a separate track over packs built through ingest(). See
BENCHMARKS.md for both tracks, the method, earlier results
and reproducibility artifacts.
Installation
pip install prme
Optional integrations:
pip install "prme[postgres]" # PostgreSQL backend
pip install "prme[api]" # HTTP API
pip install "prme[mcp]" # MCP server
pip install "prme[langchain]" # LangChain retriever and chat history
pip install "prme[llamaindex]" # LlamaIndex retriever and chat store
Quickstart
from prme import MemoryClient
with MemoryClient("./my_memories") as memory:
memory.store("Alice prefers dark mode in her editors.", user_id="alice")
memory.store("The team decided to use PostgreSQL.", user_id="alice")
response = memory.retrieve("What are Alice's preferences?", user_id="alice")
for result in response.results:
print(f"[{result.composite_score:.3f}] {result.node.content}")
MemoryClient is synchronous; MemoryEngine provides the async API. Direct
storage and retrieval use local embeddings by default and require no LLM API key.
Use ingest() with an OpenAI, Anthropic, or Ollama extraction provider when you
want structured memories extracted from conversation text.
Configure PRME through PRMEConfig, PRME_ environment variables, or a .env
file. Constructor values override the environment, which overrides .env.
The configuration reference lists the
settings and their defaults. To return to the v0.12.0 retrieval defaults, set
PRME_SCORING__FUSION=weighted, PRME_PACKING__CONTEXT_FORMAT=auditable and
PRME_PACKING__MULTIPATH_ORDERING=balanced (the last is the default again and
only makes it explicit; see
Default retrieval settings).
See the integration reference and
examples for configuration and application patterns.
Interfaces and tools
Use the CLI to initialize, inspect, search, and maintain a local pack:
prme init ./my_memories
prme doctor ./my_memories
prme search ./my_memories/memory.duckdb "Alice's preferences" --user-id alice
prme organize ./my_memories/memory.duckdb --user-id alice
prme compact ./my_memories/memory.duckdb
prme migrate ./my_memories ./memories.prme
prme compact rewrites a closed pack file to give back the space DuckDB never
returns, and prme migrate copies a directory pack into a new single-file pack,
leaving the directory in place. Every command that takes memory.duckdb also
takes a .prme file, and prme init ./memories.prme creates one. See the
CLI reference.
For a local assistant, install the MCP extra and run with a fixed owner:
PRME_MCP_USER_ID=alice prme-mcp --db-path ./my_memories
--db-path also accepts a single-file pack, such as ./memories.prme.
The HTTP extra provides a FastAPI service via python -m prme.api, which binds to
127.0.0.1 and refuses a network bind without API credentials (see
Running the Server).
Shared HTTP deployments bind owners to credentials through PRME_API_USER_KEYS;
MCP Streamable HTTP uses its separate PRME_MCP_USER_KEYS setting.
See the HTTP guide and
framework integration guide for application setup.
To browse stored entries and explore their graph connections from a source
checkout, run uv run --extra api python -m web.server and open
http://127.0.0.1:8080. The standalone memory explorer lives in
web/ and includes filters, source evidence, and an interactive relationship map.
Milestones
| Milestone | Delivered |
|---|---|
| Core memory foundation, through v0.9 | Event sourcing, typed graph, hybrid retrieval, organizer jobs, encryption, CLI, evaluation harness, and index rebuilds |
| v0.10 | Deterministic vector search, batched ingestion indexing, and context-budget enforcement |
| v0.11 | Tenant-scoped maintenance, ownership and retrieval-filter fixes, and broader backend CI coverage |
| v0.12 | Durable ingestion and recovery, atomic lifecycle and correction records, scoped workspaces, structured assertion and quantity operations, retrieval receipts, and evaluated ranking profiles |
| v0.13 | Rank fusion with current-state recency, the one-line reader context format and balanced ordering as retrieval defaults; conversation participants with speaker names; refusal of unauthenticated network binds for the HTTP API; an offline evidence gate and paired answer runs for measuring retrieval changes |
| v0.14, current | A claim's own sentences as its text, a named speaker's I, me and my bound to the speaker, and each source text packed once, as ingest() and reader context defaults; repeated extracted claims merged into one current record; a browser memory explorer; benchmark packs built through ingest(), with the evidence gate and a DeepSeek answer track over them |
Experimental reranking (including the cross-encoder rank order), temporal-relation guidance, model-assisted verification, temporal-first query intent, event-time recency for the weighted formula, session context packing, windowed extraction, self-contained fact text and speaker grounding remain opt-in. Detailed changes are in the changelog.
Current work follows epic #77, which acts on the 2026-09-23 benchmark gap audit: a reader-facing context, better ranking, the context budget, and dated facts extracted at write time for multi-hop and list questions. See the roadmap for what has been delivered and what is still open.
Images and video as memory sources are
RFC-0018. Its phase 1 is implemented and
off by default: with vision.enabled set, MemoryClient.observe() and
prme observe turn a photo or a saved video into dated observation events
described by a local vision model, with a thumbnail of each keyframe kept in
the pack for provenance. The benchmark with real recordings is still open.
Documentation
- Developer guides and configuration reference
- Architecture and RFC index
- Integration reference and framework adapters
- Context packing and default retrieval settings and retrieval feedback and learning
- Experimental retrieval policies
- Memory corrections
- Entity profiles and entity identity
- Workspaces and local resource control
- Custom embeddings and typed value bindings
- HTTP API
Development
git clone https://github.com/dwamianm/prism.git
cd prism
uv sync --dev
uv run pytest tests/ -q
PostgreSQL tests require a live database configured through
PRME_TEST_DATABASE_URL. See CONTRIBUTING.md for development
setup, checks, and contribution guidelines.
License
Apache License 2.0 — see LICENSE.
Metadata
Release files for prme 0.16.0a2
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 |
|---|---|---|---|---|
| prme-0.16.0a2.tar.gz | 644.9 kB | With provenance | Details for prme-0.16.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prme-0.16.0a2-py3-none-any.whl | Python 3 | none | any | Details for prme-0.16.0a2-py3-none-any.whl |
Total release size: 1.4 MB
Release files / prme-0.16.0a2.tar.gz
| Download URL | prme-0.16.0a2.tar.gz |
|---|---|
| Size | 644.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20a4fba3e837c9520338c2e8597aeb890af4dca86945f660152fe7520b92325f
|
|
BLAKE2b-256 checksum How to use checksums |
a4e7ab3de04fecbc6cd6518b70b4812bd728e5dd04c8ffb9b6bdff3474fb7565
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logRelease files / prme-0.16.0a2-py3-none-any.whl
| Download URL | prme-0.16.0a2-py3-none-any.whl |
|---|---|
| Size | 749.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d5d11106ecef46842bdfb7cdce2e0e15e2c30bcc636fec2d4239311f547e9bc
|
|
BLAKE2b-256 checksum How to use checksums |
5c54602753f6fc87dd5f78253adf56e0eb52d6e12ebcf92b67136182b32aecff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logSecurity for prme 0.16.0a2
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for prme-0.16.0a2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logA 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.