Most LLM applications treat conversation history as a flat log. Feed the entire transcript into the context window, hope the model figures out what matters. SelMem, an open-source Rust project from researcher jbsalles, takes a different approach: give the model a sculpted past, not a complete one. The system selectively forgets, embellishes, and reconstructs memories so that two instances of the same LLM can develop genuinely different continuations from identical starting material.
Why a Log of Facts Is Not Memory
The core observation behind SelMem is simple but underappreciated. An unmodified stack of facts maximizes coverage, not deviation. More evidence produces the same average path through possibility space. If you want two LLM instances to behave differently -- to have something resembling personality -- you need to cut away at the record, not accumulate it.
Human memory works this way. You do not remember every detail of every day. You remember fragments, some of which get embellished, some of which fade, and some of which anchor themselves permanently. The story you tell about your past is a reconstruction, not a recording. SelMem implements this process for LLMs, not as a prompt trick, but as a first-class architectural decision.
How SelMem Sculpts the Past
The system maintains two separate stores. A "lived narrative" holds the processed memories that the model actually sees during inference. A "sealed archive" holds the raw, unmodified record of events. The model never has access to the archive. This separation is the foundation of the entire design.
When a new experience arrives, it goes through an encoding pipeline: intake, scoring, embedding, affect labeling (automatic lexical sentiment in French and English), identity painting, and a gating step. Living axioms -- the model's accumulated traits, beliefs, and motifs -- influence how the new experience gets encoded before it even enters the narrative. The next experience is already colored by the past.
Recall works differently from standard retrieval. When the model "remembers" something, it reconstructs meaning under the influence of current mood. A cherished memory gets embellished. A recalled disgust amplifies. A neglected disgust extinguishes. The same event can shift valence depending on the entity's emotional state at the time of recall. This is not a bug. It is the point.
Over time, nearby episodes fuse into what the project calls "myth." Heavy anchors -- events with high emotional weight -- resist merging. The identity layer builds upward: two traces become a motif, three or more become a belief, and aligned beliefs crystallize into a trait. The lineage of each trait is preserved, so the system can trace how a belief evolved into a defining characteristic.
Sleep Cycles and Memory Consolidation
SelMem includes a "sleep" phase that performs weather, rewrite, merge, and extinction operations on the narrative store. This is modeled loosely on how human sleep consolidates memory -- not by storing more, but by reorganizing, strengthening some connections and weakening others. The sleep cycle is what allows the narrative to diverge over time rather than growing monotonically.
After sleep, two instances that started from identical corpora are no longer the same. They have different motifs, different beliefs, different traits. Their fingerprints diverge. The project includes a singularity distance function that measures how far two profiles have drifted, using a fingerprint built from founders, traits, and contradictions.
Rust, Zero Crates, and the Memory Vault
SelMem is written in Rust 1.75 with zero external Cargo crates. Persistence uses the system's libsqlite3, accessed through prepared statements and BEGIN IMMEDIATE transactions. For systems without the SQLite development package, the project includes a linker workaround that symlinks the system library.
The memory organ lives entirely in RAM as a MemoryStore. On save, it dumps to disk; on open, it reloads. The LLM never interacts with the persistence layer directly. This "vault" design keeps the hot path fast and the storage format decoupled from the memory logic.
Two persistence backends are supported: SQLite for systems with libsqlite3 available, and a flat file format (.selmem) for everything else. Both use the same Snapshot structure containing profile, mood, and store state. Event IDs follow a {prefix}_{pid}_{n} format with counters raised on load for both backends. Dropped events leave no archive, and orphaned records are pruned during sleep and SQLite loads.
Serving and Using the Memory
The binary (selmemd) exposes an HTTP API with endpoints for encoding (/live), recall (/remember), embodied response (/speak), and the combined live-plus-reply (/turn). The /turn endpoint serializes on the organ with one writer, while /health and / do not acquire the memory lock. Authentication uses Bearer tokens in the Authorization header.
Two profiles are bundled as demonstrations: Claire (tender) and Silas (austere). These are not characters but sensitivities. After running sleep cycles on the same corpus, they develop distinct identities. The API supports configuration through environment variables or command-line flags, with support for OpenAI-compatible endpoints and local Ollama instances.
The system can operate without an external embedding endpoint. When none is available, it falls back to a RuleNarrator using hashed vectors. The organ still runs. This makes SelMem deployable in constrained environments where embedding APIs are not practical.
Not RAG, Not a Vector Database, Not a System Prompt
The project is explicit about what it is not. It is not retrieval-augmented generation. It is not a vector database. It is not a personality injected into a system prompt. It is an executive-autobiographical loop around a next-token transducer. The distinction matters because it changes the fundamental question from "what context should I retrieve?" to "what kind of past should this entity have?"
SelMem is still exploratory. The parameters are documented but not fitted. The architecture is unusual and may not suit every use case. But for teams working on long-lived conversational agents, persistent AI assistants, or research into LLM identity and personality, it represents a concrete implementation of ideas that most projects only discuss in abstract terms.