Biologically-inspired dynamic memory layer for RAG and multi-agent systems
Project description
PrismResonance
Biologically-inspired dynamic memory layer for RAG and multi-agent systems.
PrismResonance converts static text embeddings into complex-valued wavepackets
(z = A · e^{iφ}) so that retrieval is executed as wave interference rather than
geometric distance search. Chunks that share the active system frequency experience
constructive interference and surface instantly; out-of-phase chunks are muted by
destructive interference — no re-embedding, no coordinate mutation.
Why
| Problem with standard RAG | PrismResonance answer |
|---|---|
| Static embeddings are blind to runtime state | Phase angle φ carries live operational context |
| Surfacing related chunks requires expensive re-ranking | Wave interference is a single ONNX MatMul pass |
| Context window bloat → hallucination | Phase Coherence Shield hard-drops low-resonance chunks |
| Memory has no notion of recency or relatedness | Most-Recent and Most-Related indices + sleep cycle |
Installation
pip install prismresonance # core: numpy, onnx, onnxruntime
No torch dependency. The ONNX graph is compiled with pure onnx.helper.
Quick start
import numpy as np
from prismresonance import PrismResonance
from prismresonance.frequency import FrequencyFamily as FF
# Create (compiles ONNX graph on first run, persists to state_path)
prism = PrismResonance.create(
embedding_dim=384,
onnx_path="resonance_engine.onnx",
state_path="resonance_state.db",
)
# Ingest a chunk (your encoder produces the amplitude vector)
amplitude = np.random.randn(384).astype(np.float32)
amplitude /= np.linalg.norm(amplitude)
prism.ingest("chunk_001", amplitude, FF.EMERGENCY)
# Query
results = prism.query(
query_amplitude=amplitude,
query_phase=FF.EMERGENCY,
candidate_ids=["chunk_001"],
candidate_amplitudes=np.stack([amplitude]),
flat=True, # skip group scan for small corpora
)
for r in results:
print(r.chunk_id, r.score)
# Consolidate (run in background or on idle)
prism.sleep()
# Persist
prism.save()
prism.shutdown()
Frequency families
Six named phase bands with π/6 separation:
| Family | φ (radians) | Intended use |
|---|---|---|
NEUTRAL |
0 | Background / default |
NORMAL |
π/6 | Standard operational |
ALERT |
π/3 | Elevated attention |
EMERGENCY |
π/2 | Critical exceptions |
RECOVERY |
2π/3 | Recovery loops |
ARCHIVE |
π | Long-term cold storage |
Architecture
Raw chunk ──► Semantic anchor (amplitude A, immutable)
──► Resonance classifier (phase φ, dynamic)
│
▼
┌──────────────────────┐
│ ResonanceRegistry │ ← RAM sidecar (never touches source DB)
│ · Phase registry │
│ · Most-Recent index │
│ · Most-Related index│
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ ONNX wave engine │ ← compiled once, frozen forever
│ MatMul + Add │
│ Coherence Shield │
└──────────────────────┘
│
▼
Resonant chunk IDs
The source database is strictly read-only. All mutable state lives in the sidecar registry (RAM) and is flushed to a SQLite file during the sleep cycle.
Sleep cycle
prism.sleep() # blocking fast-sleep (runs all 4 passes)
Four passes:
- Temporal decay — fades chunks not accessed recently
- Synaptic alignment — pulls heavily co-activated chunks into the same frequency family
- Group vector recomputation — rebuilds group centroids
- Group merge — collapses very similar groups
For background operation pass auto_sleep=True to PrismResonance.create().
Source adapters
Read your existing vector store without touching it:
from prismresonance.adapters.prismrag import PgvectorSourceAdapter, ChromaSourceAdapter
# pgvector (psycopg2 or psycopg3)
adapter = PgvectorSourceAdapter(dsn="postgresql://...", table="embeddings")
# ChromaDB
adapter = ChromaSourceAdapter(collection=client.get_collection("my_col"))
Development
pip install -e ".[dev]"
python -m pytest tests/ -v
License
MIT — see LICENSE.
© 2026 Amin Parva, Insight IT Solutions LLC
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prismresonance-0.3.0.tar.gz.
File metadata
- Download URL: prismresonance-0.3.0.tar.gz
- Upload date:
- Size: 47.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70226d8507c930e5d0959aaf8f6a5c484707c3c157f96beb09b4075c0f4211d6
|
|
| MD5 |
d338b0c26561d0ef731a1815fcf55b33
|
|
| BLAKE2b-256 |
204f8ff53322b2b840a16281868bc19f7849bc512f82ac3139374e0e5e4b0e48
|
File details
Details for the file prismresonance-0.3.0-py3-none-any.whl.
File metadata
- Download URL: prismresonance-0.3.0-py3-none-any.whl
- Upload date:
- Size: 36.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef778d9878a86693602cea85ecba836510842dd10c91f6ecb7e70a9879ab64c2
|
|
| MD5 |
0b0d67f1a55a1c3339f9abbeba900215
|
|
| BLAKE2b-256 |
3042431ef4c7c13f8ab56635b5c2d416955600782974de63b6fedab0f127cbb4
|