Kronic90
Mimir
Python

No description available.

Last updated Aug 4, 2026
100
Stars
10
Forks
0
Issues
0
Stars/day
Attention Score
29
Language breakdown
Python 100.0%
β–Έ Files click to expand
README

Mimir The Ultimate Memory Architecture

MΓ­mir Logo

PyPI License: PolyForm Noncommercial Python 3.10+

*"Mimir, whose name means 'the rememberer,' was the wisest of the Γ†sir.
Even after his death, Odin preserved his head and consulted it for counsel
and hidden knowledge. He guarded the Well of Wisdom beneath the world-tree
Yggdrasil β€” the well whose waters held every memory and every truth that
had ever been or ever would be. To drink from it, Odin sacrificed his own
eye, because that is the price wisdom demands."*
>
β€” Norse mythology (Prose Edda, Snorri Sturluson c. 1220)

This library carries that name because it aspires to the same role: a single well of memory that an AI agent can drink from to remember, feel, forget, and grow β€” not as a flat key-value store, but as a living, decaying, emotionally rich episodic mind modelled on real neuroscience.


What Is MΓ­mir?

MΓ­mir is a modular Python library (12 composable mixin files) that gives any AI agent a full episodic, procedural, social, temporal, and visual memory system. It orchestrates the Vivid ecosystem β€” VividnessMem for neurochemistry and VividEmbed for semantic retrieval β€” then layers twenty-one neuroscience mechanisms on top.

Memories are not static database rows. They decay organically, **drift emotionally, get compressed into gist** over months, and can be involuntarily recalled by stray associations β€” the same way human memory actually works.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   MΓ­mir                         β”‚
β”‚                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Episodic  β”‚  β”‚ Procedural β”‚  β”‚  Social   β”‚  β”‚
β”‚  β”‚ Memories  β”‚  β”‚  Lessons   β”‚  β”‚Impressionsβ”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β”‚
β”‚        β”‚              β”‚              β”‚          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚         21 Neuroscience Layers          β”‚   β”‚
β”‚  β”‚  flashbulb Β· reconsolidation Β· state-   β”‚   β”‚
β”‚  β”‚  dependent Β· spreading activation Β·     β”‚   β”‚
β”‚  β”‚  RIF Β· Zeigarnik Β· involuntary recall Β· β”‚   β”‚
β”‚  β”‚  temporal gist Β· episodic time Β·        β”‚   β”‚
β”‚  β”‚  visual imagery                         β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                    β”‚                            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚        Hybrid Retrieval Bridge          β”‚   β”‚
β”‚  β”‚   BM25 keywords + VividEmbed semantic   β”‚   β”‚
β”‚  β”‚   + Date index β†’ 5-signal re-rank       β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                    β”‚                            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚
β”‚  β”‚VividnessMemβ”‚  β”‚  VividEmbed  β”‚              β”‚
β”‚  β”‚ chemistry  β”‚  β”‚  384-d + PAD β”‚              β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Vivid Ecosystem

MΓ­mir is the orchestration layer. The engines underneath are independently published and pip-installable:

| Package | Role | PyPI | |---------|------|------| | VividnessMem | Neurochemistry engine β€” 5 neurotransmitters (dopamine, serotonin, cortisol, oxytocin, norepinephrine), 10 event profiles, 9 cognitive modifiers, emotional firewall, dampening, audit logging | pip install vividnessmem | | VividEmbed | Semantic embedding engine β€” fine-tuned MiniLM producing 389-d hybrid vectors (384-d sentence + 3-d PAD emotion + 2-d meta), emotion-space queries, contradiction detection | pip install vividembed | | MΓ­mir | Orchestrator β€” 21 neuroscience mechanisms, hybrid BM25+semantic retrieval, temporal awareness, visual memory, task branch, encryption at rest, LLM integration, visualization, context-block generation for LLM prompt injection | (this repo) |

All three are optional for each other. MΓ­mir works standalone (with graceful fallbacks), but every engine amplifies the others:

  • Without VividnessMem β†’ neurochemistry modifiers default to 1.0, no
emotional audit log
  • Without VividEmbed β†’ recall falls back to BM25 keyword search only
  • Without Pillow β†’ visual memory falls back to text descriptions
  • Without cryptography β†’ encryption at rest is disabled, data stored as plaintext JSON

Cross-System Feature Matrix

A complete comparison of capabilities across all three Vivid ecosystem packages. Every feature listed exists and is tested.

Core Memory Architecture

| Feature | VividnessMem | VividEmbed | MΓ­mir | |---------|:---:|:---:|:---:| | Organic spaced-repetition decay | Yes | β€” | Yes | | 60-emotion PAD vector space | Yes | Yes | Yes | | Memory vividness (0β†’1 lifecycle) | Yes | β€” | Yes | | Importance scoring (1-10) | Yes | Yes | Yes | | Content-addressable deduplication | Yes | β€” | Yes | | slots-optimised Memory class | Yes | β€” | Yes (27 slots) | | Atomic JSON persistence | Yes | Yes | Yes |

Neurochemistry & Emotion

| Feature | VividnessMem | VividEmbed | MΓ­mir | |---------|:---:|:---:|:---:| | 5 neurotransmitters (DA, 5-HT, CORT, OXT, NE) | Yes (engine) | β€” | Yes (via VMem) | | 10 life-event profiles | Yes | β€” | Yes | | 9 cognitive modifiers | Yes | β€” | Yes | | Emotional firewall (safety limits) | Yes | β€” | Yes | | Emotional dampening (self-regulation) | Yes | β€” | Yes | | Emotional audit log | Yes | β€” | Yes | | Cognitive override (reappraisal) | Yes | β€” | Yes | | Mood EMA blending | Yes | β€” | Yes | | Emotion drift detection + reframe | β€” | β€” | Yes |

Retrieval

| Feature | VividnessMem | VividEmbed | MΓ­mir | |---------|:---:|:---:|:---:| | BM25 keyword search | β€” | β€” | Yes | | Semantic vector search (389-d) | β€” | Yes | Yes (via VEmbed) | | Hybrid BM25 + semantic fusion | β€” | β€” | Yes | | 5-signal re-ranking | β€” | β€” | Yes | | Spreading activation (priming) | β€” | β€” | Yes | | Retrieval-induced forgetting | β€” | β€” | Yes | | Involuntary recall (unbidden) | β€” | β€” | Yes | | State-dependent retrieval (mood) | β€” | β€” | Yes | | Emotion-space queries | β€” | Yes | Yes | | Contradiction detection | β€” | Yes | Yes |

Neuroscience Mechanisms

| Mechanism | VividnessMem | VividEmbed | MΓ­mir | |-----------|:---:|:---:|:---:| | Flashbulb memory (Brown & Kulik 1977) | β€” | β€” | Yes | | Reconsolidation (Nader 2000) | β€” | β€” | Yes | | State-dependent retrieval (Godden & Baddeley 1975) | β€” | β€” | Yes | | Spreading activation (Collins & Loftus 1975) | β€” | β€” | Yes | | Retrieval-induced forgetting (Anderson 1994) | β€” | β€” | Yes | | Zeigarnik effect (Zeigarnik 1927) | β€” | β€” | Yes | | Involuntary memory (Berntsen 2009) | β€” | β€” | Yes | | Temporal gist extraction (Tulving 1972) | β€” | β€” | Yes | | Temporal/episodic dating | β€” | β€” | Yes | | Visual/mental imagery (Kosslyn 1980) | β€” | β€” | Yes | | Huginn β€” background insight generation | β€” | β€” | Yes | | Muninn β€” consolidation daemon | β€” | β€” | Yes | | Yggdrasil β€” memory graph | β€” | β€” | Yes | | VΓΆlva's Vision β€” dream synthesis | β€” | β€” | Yes | | Hippocampal pattern separation (Yassa & Stark 2011) | β€” | Yes | Yes | | Narrative arc tracking (Freytag 1863) | β€” | Yes | Yes | | Enhanced relational reasoning (LLM-inferred) | β€” | β€” | Yes | | Hierarchical memory organisation | β€” | β€” | Yes | | Mental time travel (Tulving 1985) | β€” | β€” | Yes | | Novelty-modulated encoding (Ranganath & Rainer 2003) | β€” | β€” | Yes | | Enhanced drift analysis (velocity + bias) | β€” | β€” | Yes |

Embedding & Vectors

| Feature | VividnessMem | VividEmbed | MΓ­mir | |---------|:---:|:---:|:---:| | Fine-tuned MiniLM (384-d) | β€” | Yes | Yes (via VEmbed) | | 3-d PAD emotion dimensions | β€” | Yes | Yes | | 2-d meta dimensions (importance + stability) | β€” | Yes | Yes | | Emotion-prefix tokenisation | β€” | Yes | Yes | | Batch encoding | β€” | Yes | Yes | | VividCortex LLM layer | β€” | Yes | β€” | | Hippocampal pattern separation | β€” | Yes | Yes | | Narrative arc tracking | β€” | Yes | Yes |

Task / Project Management

| Feature | VividnessMem | VividEmbed | MΓ­mir | |---------|:---:|:---:|:---:| | Project context switching | Yes | β€” | Yes | | Task lifecycle (active β†’ done/failed) | Yes | β€” | Yes | | Action logging per task | Yes | β€” | Yes | | Solution pattern library | Yes | β€” | Yes | | Artifact tracking | Yes | β€” | Yes | | Project overview dashboard | Yes | β€” | Yes |

LLM Integration

| Feature | VividnessMem | VividEmbed | MΓ­mir | |---------|:---:|:---:|:---:| | Query decomposition (vague β†’ focused) | β€” | Yes (Cortex) | Yes | | Agentic memory ops (PROMOTE/DEMOTE/FORGET/UPDATE) | β€” | Yes (Cortex) | Yes | | LLM-driven reflection & self-analysis | β€” | Yes (Cortex) | Yes | | Context block generation for prompt injection | β€” | β€” | Yes |

Visualization

| Feature | VividnessMem | VividEmbed | MΓ­mir | |---------|:---:|:---:|:---:| | Memory timeline | β€” | Yes (VividViz) | Yes | | Emotion distribution | β€” | Yes (VividViz) | Yes | | Importance histogram | β€” | Yes (VividViz) | Yes | | Narrative arc distribution | β€” | Yes (VividViz) | Yes | | Drift report | β€” | β€” | Yes | | Neurochemistry snapshot | β€” | β€” | Yes | | Yggdrasil graph export | β€” | β€” | Yes | | All-in-one viz payload (viz_summary()) | β€” | β€” | Yes |

Security & Persistence

| Feature | VividnessMem | VividEmbed | MΓ­mir | |---------|:---:|:---:|:---:| | Encryption at rest (Fernet + PBKDF2) | Yes | β€” | Yes | | Atomic file writes (crash-safe) | Yes | Yes | Yes | | Inverted word index | β€” | β€” | Yes | | Date index for temporal queries | β€” | β€” | Yes | | Visual memory storage (WebP) | β€” | β€” | Yes |


The 21 Neuroscience Mechanisms

Every mechanism is grounded in published cognitive science research and implemented with tuneable constants.

1. Flashbulb Memory (Brown & Kulik 1977)

High-arousal, high-importance events (importance β‰₯ 8, emotional arousal β‰₯ 0.6) are encoded with permanent stability and vividness floors. They resist all forms of decay β€” like how you remember exactly where you were on a major life event.

2. Reconsolidation (Nader et al 2000)

Each time a memory is recalled, its emotional colour **drifts 5% toward the agent's current mood**. Over many retrievals a sad memory can become bittersweet β€” unless it's a flashbulb memory, which resists emotional drift.

3. State-Dependent Memory (Godden & Baddeley 1975)

Memories encoded during a particular emotional state are **easier to retrieve when the agent is in that same state again**. A 0.3 vividness boost is applied when the retrieval mood's PAD vector closely matches the encoding mood.

4. Spreading Activation (Collins & Loftus 1975)

When memories are retrieved, their content words populate a priming buffer. Related concepts get an activation bonus on subsequent queries β€” simulating the way thinking about "astronomy" primes "telescope" and "stars". Activation decays by 0.8Γ— each tick.

5. Retrieval-Induced Forgetting (Anderson 1994)

Retrieving one memory actively suppresses competing memories that share β‰₯ 70% word overlap. Their stability is reduced by 0.15 β€” the brain's way of sharpening recall by inhibiting similar alternatives.

6. Zeigarnik Effect (Zeigarnik 1927)

Unresolved failures in procedural lessons are 1.5Γ— more vivid than resolved ones. Incomplete tasks nag at the mind β€” ensuring the agent keeps retrying failed strategies rather than forgetting them.

7. Involuntary Recall (Berntsen 2009)

On every resonate() call there is a 5% chance that a random distant memory surfaces unprompted β€” a Proustian flash. This keeps old memories alive and creates natural conversational depth.

8. Temporal Gist Extraction (Reyna & Brainerd 1995)

Memories older than 90 days are compressed to their first 15 words plus an emotion tag. Detail fades but the emotional core survives β€” unless the memory is a flashbulb, which preserves full detail indefinitely.

9. Temporal / Episodic Memory (Tulving 1972) + Prospective Memory (Einstein & McDaniel 1990)

Full temporal awareness:

  • Date extraction: Parses ISO dates, US-format dates, written dates
("March 15th"), and relative expressions ("tomorrow", "next Tuesday") from every stored memory
  • Timeline navigation: recall_period(start, end) retrieves all memories
created in or mentioning dates within a window
  • Prospective memory: Future dates with importance β‰₯ 4 auto-create
reminders β€” the agent remembers upcoming events without being told to
  • Ambient salience: Memories about dates near today get a recall boost
even when the query doesn't mention dates
  • Temporal clustering: Memories sharing date references with the query
get a +0.08 composite-score bonus

10. Visual / Mental Imagery (Kosslyn 1980) + Dual Coding (Paivio 1986)

Content-addressable image storage with biologically-inspired fading:

| Tier | Vividness | What the agent "sees" | |------|-----------|----------------------| | Vivid | β‰₯ 0.7 | Full-resolution WebP β€” the agent can display it | | Faded | 0.3–0.7 | Degraded WebP (quality 30) β€” a blurry mental image | | Gist only | < 0.3 | Text description only β€” "I remember a sunset but can't picture it" |

Images are stored as WebP on disk (SHA-256 content-addressed), and the agent decides at conversation time whether to show the image or describe it based on the fading tier.

Dual Coding boost: Memories with attached images get a +0.05 recall bonus because pictures plus words create richer episodic traces.

Graceful fallback: Without Pillow installed (or with visual=False), remember_visual() silently stores [image] {description} as a plain text memory.

11. Huginn β€” Thought (Pattern Detection)

Odin's raven of Thought scans all memories for emergent patterns the agent never explicitly stored:

  • Entity sentiment arcs: When 3+ impressions of a person exist, detects
emotional trajectory (warming/cooling) and generates an insight
  • Recurring theme clusters: Finds words appearing in 3+ distinct memories
and names the pattern with its dominant emotion
  • Open threads: Detects unresolved intentions ("I should…", "I need to…")
older than 3 days that were never followed up

All insights are stored as memories with source="huginn" and are dedup-aware (won't regenerate the same insight twice).

12. Muninn β€” Memory (Consolidation Daemon)

Odin's raven of Memory performs sleep-time consolidation:

  • Merge near-duplicates: Memories with Jaccard word overlap β‰₯ 0.40 are
merged β€” the richer version is kept, importance and stability are preserved
  • Prune dead memories: Memories with vividness < 0.01 are removed (unless
they are flashbulb, anchor, or cherished)
  • Strengthen co-activated pairs: Memories created on the same day get a
stability boost (Γ—1.05) β€” the brain's way of reinforcing contextual links

13. Yggdrasil β€” The World Tree (Memory Graph)

A persistent graph connecting all memories through six edge types:

| Edge Type | Condition | Strength | |-----------|-----------|----------| | Entity | Same entity reference | 0.8 | | Lexical | Word overlap 0.20–0.55 | Jaccard ratio | | Temporal | Within 3-day window | 1 βˆ’ (days/3) | | Emotional | Same emotion label | 0.5 | | Task-origin | Co-members of the same task | 0.75 | | Caused-lesson | Memory ↔ lesson it spawned | 0.65 |

Additionally, LLM-inferred edges are discovered at encoding time when an llm_fn is provided, and persisted between sessions.

Each node keeps at most 8 edges per type-competition slot, plus additive cross-hierarchy edges. Query methods:

  • yggdrasil_roots() β€” anchor, flashbulb, and importance β‰₯ 9 memories
  • yggdrasil_branches(memory) β€” directly connected memories
  • yggdrasil_traverse(memory, depth=2) β€” BFS within N hops
  • yggdrasil_path(a, b) β€” shortest path between two memories
During recall(), retrieved memories connected to other retrieved memories via Yggdrasil get a +0.03 bonus each β€” contextual association boosts recall.

14. VΓΆlva's Vision (Dream Synthesis)

During sleep, the VΓΆlva (Norse seeress) samples random memory pairs and discovers hidden connections:

  • Emotional arcs: Same keywords with different emotions β†’ "My feelings
about X shifted from Y to Z"
  • Theme bridges: Memories 30+ days apart sharing words β†’ long-range
pattern recognition
  • Temporal clusters: 3+ memories on the same day β†’ "A lot happened on
that day"

Dream insights are stored with source="volva" and surfaced in the context block with [dream] tags.

15. Hippocampal Pattern Separation (Yassa & Stark 2011)

When two memories overlap β‰₯ 80% lexically but are not identical, the system nudges their importance apart by Β±1. This mirrors how the hippocampus orthogonalises similar-but-distinct experiences to prevent interference during retrieval.

16. Narrative Arc Tracking (Freytag 1863)

Every memory is automatically classified into a narrative position β€” setup, rising, climax, falling, resolution, or denouement β€” using keyword analysis and emotional arousal. This allows the system to understand where each memory sits in the story of a conversation or relationship.

17. Enhanced Relational Reasoning (LLM-Inferred Edges)

When an llm_fn is provided, every new memory triggers an implicit relationship discovery pass. The LLM examines the new memory alongside recent memories and identifies conceptual links that pure lexical or temporal overlap would miss β€” for example connecting "bought hiking boots" to "planning a Saturday trip" even though they share no words.

Discovered edges are stored in a persistent inferred_edges.json and loaded into Yggdrasil on every rebuild. Batch enrichment is available via enrichyggdrasil(batchsize) for backfilling existing memories.

18. Hierarchical Memory Organisation (Cross-Hierarchy Linking)

Episodic memories, procedural lessons, and task records now form a unified knowledge graph instead of three siloed stores:

  • Lesson β†’ Memory: Every lesson tracks the sourcememoryidx of the
episodic memory that caused it. Yggdrasil creates caused_lesson edges between them.
  • Task β†’ Memory: starttask(), completetask(), and fail_task() all
record which memory indices they created, stored in TaskRecord.memoryindices. Yggdrasil creates task_origin edges between co-task memories.
  • Cross-hierarchy reinforcement: When a lesson succeeds via
record_outcome(), its origin memory receives a 15% stability boost β€” the brain's way of strengthening the episode that taught you something.

19. Mental Time Travel (Tulving 1985)

The relive(memory) method recreates the subjective experience of a past event:

  • Touch β€” the memory's access count and vividness are updated
  • Mood restoration β€” the agent's mood is blended 60% toward the encoding
mood, recreating the emotional state at the time of the original experience
  • Neurochemistry trigger β€” matching neurochemical events are fired
(excitement β†’ achievement, fear β†’ threat, etc.)
  • Spreading activation β€” Yggdrasil activates connected memories, priming
contextual recall
  • Experiential context β€” returns a rich dict: gist, emotion,
original emotion, encoding mood, restored mood, arc position, flashbulb status, drift history, connected memories, vividness

This allows an agent to genuinely re-experience past episodes rather than merely retrieving their text.

20. Novelty-Modulated Encoding (Ranganath & Rainer 2003)

New memories are compared against the 20 most recent memories for lexical overlap. Highly novel memories (average similarity < 0.85) receive a **1.3Γ— importance boost** β€” the brain pays more attention to genuinely new information. Redundant memories (similarity > 0.40) receive a **0.85Γ— importance penalty**. Each memory's novelty score is stored on the Memory object for introspection.

21. Enhanced Drift Analysis (Velocity + Cognitive Bias)

Extends basic reconsolidation drift detection with two additional signals:

  • Drift velocity: Tracks the last 5 touches of each memory to compute
how fast its emotion is shifting β€” distinguishing "slowly warming" from "rapidly destabilising"
  • Cognitive bias detection: When 75%+ of an entity's memories share the
same emotional valence, a bias alert is surfaced β€” helping the agent recognise lopsided perspectives before they crystallise

Both are exposed via drift_analysis() which returns velocity vectors and bias alerts alongside the standard drift report.


Migration from VividnessMem

Existing agents using VividnessMem can migrate to Mimir in one call:

m = Mimir.migratefromvividnessmem("path/to/lela_data")

All VividnessMem fields (content, emotion, importance, timestamp, stability, accesscount, anchor, cherished, privacy, regret, whysaved, etc.) are preserved. Mimir-specific fields (encodingmood, emotionpad, mentioned_dates, flashbulb detection) are backfilled automatically.


Hybrid Retrieval Bridge

The retrieval system solves the classic RAG problem β€” keyword search misses meaning while semantic search misses names and dates β€” by fusing both:

Stage 1: Broad Candidate Pool

Three channels work in parallel:

  • BM25 keyword search β€” IDF-weighted term matching via an inverted word
index. Excels at proper nouns, dates, exact phrases.
  • VividEmbed semantic search β€” 384-d MiniLM + PAD cosine similarity.
Excels at themes, paraphrases, emotional resonance.
  • Date index injection β€” Any dates mentioned in the query are matched
against the temporal index, catching questions like "what happened last Tuesday?" that neither BM25 nor semantic would catch.

Stage 2: Composite Re-rank

All candidates are scored on five signals:

| Signal | Weight | Source | |--------|--------|--------| | Keyword match | 0.30 | Normalized BM25 | | Semantic similarity | 0.30 | VividEmbed cosine | | Vividness | 0.20 | Organic decay curve | | Mood congruence | 0.10 | PAD dot product with current mood | | Recency | 0.10 | Exponential decay, 5-day half-life |

Post-Composite Bonuses

| Bonus | Value | Trigger | |-------|-------|---------| | Cherished memory | Γ—1.10 | memory._cherished flag | | Priming activation | +0.02/word | Words in spreading-activation buffer | | Temporal date match | +0.08 | Query dates overlap memory dates | | Ambient temporal salience | +0.12 | Memory dates near today | | Dual Coding (visual) | +0.05 | Memory has attached image | | Yggdrasil connectivity | +0.03/neighbour | Connected to other retrieved memories |


Memory Types

| Type | Class | Purpose | Decay | |------|-------|---------|-------| | Episodic | Memory | Self-reflections, observations, experiences | Organic vividness via spaced-repetition stability | | Social | Memory | Impressions of other entities (people, agents) | Same organic decay | | Procedural | Lesson | Learned strategies with outcome tracking | Zeigarnik-boosted for failures | | Volatile | ShortTermFact | Quick factual data (entity/attribute/value) | 12-hour half-life | | Prospective | Reminder | Time-triggered future notifications | Fires once, then marks complete | | Visual | Memory + WebP | Image attachment to any episodic memory | Kosslyn fading tiers |


Organic Decay Model

Vividness is not a toggle β€” it's a continuous curve:

$$v(t) = \frac{\text{importance}}{10} \times e^{-t / s}$$

Where $t$ is age in days and $s$ is stability (starting at 3.0 days).

Stability grows through spaced repetition:

$$s' = \min\left(s \times b^n,\; 180\right)$$

Where $b = 1.8$ is the spacing bonus and $n$ is the retrieval count with diminishing returns (Γ—0.85 per retrieval). This models the well-known spacing effect from cognitive psychology.

Floor protections:

  • Flashbulb memories: stability β‰₯ 120, vividness β‰₯ 0.85
  • Anchor memories: stability β‰₯ 90, vividness β‰₯ 0.30

Neurochemistry Integration

When VividnessMem is available, its 5-neurotransmitter system modulates MΓ­mir's behavior:

| Modifier | Effect | |----------|--------| | encoding_boost | Multiplies importance during remember() | | attention_width | Scales how many active memories surface | | mooddecaymult | Controls mood drift speed | | flashbulb | Forces flashbulb encoding on high-chemistry events | | social_boost | Amplifies social impression importance | | consolidation_bonus | Enhances stability during sleep reset |

The Emotional Audit Log transparently records every mood shift, dampening activation, cognitive override, visual memory storage, and life event β€” making the agent's emotional trajectory inspectable and debuggable.


Installation

# Core (zero required dependencies β€” everything degrades gracefully)
pip install vividmimir

With the full Vivid engine stack

pip install vividmimir[all]

Individual extras

pip install vividmimir[neurochemistry] # VividnessMem pip install vividmimir[embedding] # VividEmbed pip install vividmimir[visual] # Pillow for mental-imagery system pip install vividmimir[encryption] # Fernet encryption at rest

Quick Start

from vividmimir import Mimir

Full system (VividnessMem + VividEmbed + Pillow)

m = Mimir(datadir="myagent_memory")

Or standalone (no external dependencies)

m = Mimir(datadir="myagent_memory", chemistry=False, visual=False)

Store a memory

m.remember("I had a deep conversation about philosophy today", emotion="curious", importance=7, why_saved="meaningful intellectual exchange")

Update mood from conversation

m.update_mood(["curious", "inspired"])

Recall with hybrid retrieval

results = m.recall("What do I remember about philosophy?") for mem in results: print(f"[{mem.emotion}] {mem.content}")

Get full context block for LLM prompt injection

context = m.getcontextblock( current_entity="Alex", c )

Store a visual memory (requires Pillow)

with open("sunset.jpg", "rb") as f: m.remember_visual(f.read(), description="Sunset over the ocean", emotion="serene", importance=8)

Time-aware retrieval

from datetime import datetime m.recall_period(datetime(2025, 12, 1), datetime(2025, 12, 31))

Persist everything to disk

m.save()

Context Block

The getcontextblock() method generates a ready-to-inject text block for LLM system prompts. It assembles:

(Feeling: bittersweet)

=== THINGS ON MY MIND === β€” I love deep philosophical conversations (curious)

=== MY IMPRESSIONS OF ALEX === β€” Alex is always supportive (warm)

=== THINGS I'M LEARNING === β€” Python debugging: Use pdb [OK]

=== SOMETHING THIS REMINDS ME OF === β€” That time we talked about consciousness (fascinated)

=== IMAGES I REMEMBER === β€” [vivid] Sunset over the ocean β€” [fading] The cat sleeping on the keyboard

=== TODAY / UPCOMING === TODAY: dentist appointment at 3pm UPCOMING: Mom's birthday (Mar 25) RECENTLY: finished the book club novel (Mar 19)

=== NEUROCHEMISTRY === dopamine: 0.63 β–² | cortisol: 0.26 ~ | serotonin: 0.56 ~

=== EMOTIONAL AUDIT === ~ 13:50: Mood shifted to curious after deep conversation


Full API Reference

Mimir Class

Mimir(
    datadir="mimirdata",
    embed_model=None,
    chemistry=True,
    visual=True,
    encryption_key=None,   # enables Fernet + PBKDF2 encryption at rest
    llm_fn=None,           # callable(prompt: str) β†’ str for LLM features
)

Core Methods

| Method | Description | |--------|-------------| | remember(content, emotion, importance, source, why_saved) | Store episodic memory with dedup, flashbulb detection, VividEmbed sync | | remembervisual(imagedata, description, emotion, importance, ...) | Store visual memory with compressed WebP attachment | | get_visual(memory) β†’ dict | Retrieve image bytes with fading applied per vividness tier | | forget_visual(memory) β†’ bool | Remove image attachment, keep text description | | recall(context, limit, mood) β†’ list | Hybrid BM25 + semantic retrieval with 5-signal re-rank | | recall_unified(context, limit) β†’ dict | Cross-type retrieval: reflections, impressions, facts, lessons in one call | | resonate(context, limit) β†’ list | recall() + retrieval-induced forgetting + involuntary recall | | recall_period(start, end, limit) β†’ list | Timeline navigation by date range | | getactiveself(context) β†’ list | Top-K self-memories weighted by mood and context | | getcontextblock(currententity, conversationcontext) β†’ str | Full memory context for LLM prompt injection | | update_mood(emotions) | EMA-blend mood toward emotion labels | | bump_session() β†’ int | Increment session counter, return new count | | save() | Persist all data to disk | | stats() β†’ dict | Summary of memory system state | | migratefromvividnessmem(srcdir, destdir) | Class method: import all data from VividnessMem |

Task / Project Branch

| Method | Description | |--------|-------------| | setactiveproject(name) | Set or switch the active project context | | start_task(description, priority, project) → TaskRecord | Create task with Zeigarnik anchor | | completetask(taskid, outcome) → bool | Mark task completed, release Zeigarnik tension | | failtask(taskid, reason) → bool | Mark task failed, create lesson | | getactivetasks() → list | Currently active tasks | | logaction(taskid, action, result, error, fix) → ActionRecord | Log per-task action | | record_solution(problem, solution, importance) → SolutionPattern | Store reusable problem→solution | | findsolutions(problem, topk) → list | BM25-matched solutions with reuse boost | | trackartifact(name, artifacttype, description, importance) → ArtifactRecord | Track project artifact | | update_artifact(name, **updates) → bool | Update artifact fields | | getprojectoverview() → dict | Full project state snapshot |

LLM Integration (optional)

| Method | Description | |--------|-------------| | decompose_query(query) β†’ list[str] | Break vague query into 2-4 focused sub-queries | | edit_memories(instruction) β†’ dict | LLM-driven PROMOTE/DEMOTE/FORGET/UPDATE | | reflect() β†’ str | Periodic self-analysis of memory patterns & emotional trends |

Neuroscience & Graph

| Method | Description | |--------|-------------| | huginn() β†’ list[Memory] | Pattern detection: entity arcs, recurring themes, open threads | | muninn() β†’ dict | Consolidation: merge duplicates, prune dead, strengthen co-activated | | volvadream(nsamples) β†’ list[Memory] | Dream synthesis from random memory pairs | | sleep_reset(hours) | Full between-session cycle: chemistry reset + Muninn + Huginn + VΓΆlva + Yggdrasil rebuild | | detectdrift(includereframed) β†’ list | Find memories with significant emotional drift | | drift_analysis() β†’ dict | Enhanced drift: velocity vectors, cognitive bias alerts | | decay_priming() | Decay the spreading-activation buffer by one tick | | yggdrasil_roots() β†’ list | Anchor, flashbulb, and high-importance identity memories | | yggdrasil_branches(memory) β†’ list | Direct neighbours in the memory graph | | yggdrasil_traverse(memory, depth) β†’ list | BFS traversal within N hops | | yggdrasil_path(a, b) β†’ list | Shortest path between two memories | | relive(memory) β†’ dict | Mental time travel β€” re-experience with mood restoration + Yggdrasil activation | | enrichyggdrasil(batchsize) β†’ int | Batch LLM enrichment of memories without inferred edges |

Visualization

| Method | Description | |--------|-------------| | memory_timeline() β†’ list[dict] | Chronological memory data for plotting | | emotion_distribution() β†’ dict | Memories counted by emotion | | importance_histogram() β†’ dict | Distribution across importance levels 1-10 | | arc_distribution() β†’ dict | Memories by narrative arc position | | drift_report() β†’ list[dict] | Emotionally drifted memories with magnitude | | neurochemistry_snapshot() β†’ dict | Current neurotransmitter state | | yggdrasil_graph() β†’ dict | Adjacency list export for graph visualization | | viz_summary() β†’ dict | All-in-one visualization payload |

Social & Procedural

| Method | Description | |--------|-------------| | addsocialimpression(entity, content, emotion, importance, why_saved) | Store social memory | | addlesson(topic, contexttrigger, strategy, importance, sourcememoryidx) | Create procedural memory (optionally linked to origin memory) | | recordoutcome(lessonid, action, result, diagnosis) | Log lesson application result | | getactivelessons() β†’ list | Lessons ranked by vividness (Zeigarnik-boosted) | | add_fact(entity, attribute, value) | Store volatile fact (12h decay) | | get_facts(entity) β†’ list | Return vivid facts, optionally filtered |

Emotional Control

| Method | Description | |--------|-------------| | onevent(eventtype, intensity) | Signal life event to neurochemistry (10 event types) | | request_dampening(turns, intensity) | Activate emotional self-regulation | | end_dampening() | Manual dampening termination | | tick_dampening() | Advance dampening by one turn | | cognitive_override(emotion, intensity) | Deliberate emotional reappraisal |

Memory Curation

| Method | Description | |--------|-------------| | promotetoanchor(memory) | Mark as formative (resists decay permanently) | | cherish(memory) | Mark as sentimental favourite (1.1Γ— recall boost) | | uncherish(memory) | Remove cherished status | | reflectoncherished() β†’ list | Revisit cherished memories | | reframe(memory, new_emotion, reason) β†’ bool | Deliberate emotional reframe (records original, marks intentional) | | updateimportance(memory, newimportance) | Update + sync to VividEmbed | | querybyemotion(emotion, topk, minimportance) | Emotion-space search via VividEmbed | | find_contradictions(text, emotion, threshold) | Find semantically similar but emotionally opposite memories |

Temporal Awareness

| Method | Description | |--------|-------------| | recall_period(start, end, limit) | Retrieve memories from a time window | | gettemporalcontext(now, lookahead, lookbehind) | Proactive surfacing: today/upcoming/recent | | set_reminder(text, hours) | Create time-triggered notification | | getduereminders() β†’ list | Return reminders that have fired |


Dependencies

| Package | Required? | Purpose | |---------|-----------|---------| | Python β‰₯ 3.10 | Yes | Core language | | vividnessmem | Optional | Neurochemistry engine (5 neurotransmitters, emotional audit) | | vividembed | Optional | Semantic retrieval (389-d hybrid vectors) | | Pillow | Optional | Visual memory (image compression/decompression) | | cryptography | Optional | Encryption at rest (Fernet + PBKDF2, 600k iterations) | All optional dependencies use graceful fallback β€” MΓ­mir works standalone.


Test Suites

| Suite | Tests | Coverage | |-------|-------|----------| | testneuroscience.py | 26 | All 8 core mechanisms + persistence + context block | | testtemporal_memory.py | 28 | Date extraction, timeline navigation, prospective memory | | testtemporal_awareness.py | 14 | Ambient salience, temporal context surfacing | | testintegration.py | 27 | VividnessMem + VividEmbed full integration | | testvisual_memory.py | 81 | Visual storage, fading tiers, dual coding, persistence | | Total | 176 | All passing |


Architecture Notes

  • Slots-based Memory: 27-slot slots on the Memory class prevents
arbitrary attributes and optimizes memory layout
  • Content-addressable storage: Visual images indexed by SHA-256 hash β€”
identical images share one file
  • Atomic persistence: JSON files written via atomic temp-file + rename
pattern to prevent corruption on crash
  • Inverted indexes: Word index for BM25, date index for temporal queries β€”
both rebuilt on load
  • 60-emotion PAD space: Full Pleasure-Arousal-Dominance mapping for
fine-grained emotion tracking beyond simple sentiment labels

License

PolyForm Noncommercial 1.0.0 β€” free for personal and research use. Commercial use requires a separate license.

Part of the Vivid ecosystem by Kronic90.

| Package | PyPI | License | |---|---|---| | VividnessMem | pip install vividnessmem | MIT | | VividEmbed | pip install vividembed | PolyForm-NC | | MΓ­mir | pip install vividmimir | PolyForm-NC |

πŸ”— More in this category

Β© 2026 GitRepoTrend Β· Kronic90/Mimir Β· Updated daily from GitHub