'Dynamic Persona MoE RAG: Building a Memory-Driven Synthetic Intelligence with [post] deterministic
A comprehensive guide to building a memory-driven synthetic intelligence
Introduction
What I am building with this blog system is not a publishing pipeline in the conventional sense, but a continuously evolving synthetic intelligence that treats writing itself as a form of memory. The archive of markdown files is not merely content to be rendered, indexed, or searched. It is the long-term memory substrate of the system, a historical record of thought that can be reasoned over, recomposed, and transformed as new information arrives. Each post becomes both an artifact and a structural element in a larger cognitive system whose primary purpose is synthesis rather than retrieval.
Short-Term Memory: The Mutable Persona State
Short-term memory is implemented as a mutable persona state file that captures the current configuration of personality weights. These weights represent traits, priorities, tone, and behavioral tendencies that are fixed in the present moment but continuously adjustable in response to new events. Any incoming stimulus, whether user input, system signals, or external data, can trigger updates to these weights through arbitrary update functions. These functions may be heuristic, learned, or reinforcement-driven, allowing the persona to shift gradually rather than reset between interactions. In this way, short-term memory acts as a living state vector that reflects the chatbot's immediate context and recent history.
The short-term persona is grounded in a knowledge graph derived from source documents, structured data, or predefined schemas. These graphs may be generated dynamically or partially pre-constructed with constraints and parameters that define allowable structures. Instead of modifying system prompts directly, higher-level queries can be issued to adjust the persona weights themselves, effectively changing how the system interprets and composes context. Long-form documents in the knowledge base can be treated as time-indexed personas, capturing snapshots of perspective that evolve as new information arrives. This enables the system to reason not only over content, but over how its interpretive stance has changed across time.
A central goal of this architecture is the generation of new personas as first-class artifacts. As interactions accumulate and new data is ingested, the system synthesizes updated or entirely new persona configurations. These personas are persisted within a file or graph-based structure, allowing them to be recalled, compared, or analyzed longitudinally. Time series data associated with persona evolution can be surfaced to the user interface as reports, visualizations, or signals that influence other backend processes. Reinforcement learning signals and continuous analysis of incoming data streams, such as user input or RSS feeds, drive the selective strengthening, weakening, or branching of these personas.
The persona's primary operational role is to function as a lens through which the final language model inference is executed. This lens encodes the variables, constraints, and stylistic parameters that shape generation. By abstracting these variables away from any single model provider, the system can supply a consistent set of inputs to different LLMs, achieving a degree of deterministic behavior across inference engines. While outputs will never be perfectly identical, the persona ensures that the same conceptual and stylistic biases are applied regardless of provider. In more advanced implementations, this lens also includes parameters governing agentic behavior, such as planning depth, tool usage preferences, or context assembly strategies.
As architectures scale beyond simple vector-based retrieval augmented generation, the persona lens expands to include instructions for composing context from heterogeneous sources. These may include symbolic reasoning outputs, structured database queries, procedural memories, or dynamically generated subgraphs. The persona therefore not only influences generation, but actively shapes how context is assembled before inference. It becomes a coordinating structure that mediates between memory, reasoning, and language.
Long-Term Memory: The Temporal Knowledge Graph
Long-term memory is realized through the continuous ingestion of data into a persistent knowledge graph. This graph accumulates information over time and encodes relationships between entities, events, concepts, and prior interactions. From the current state of this graph, a persona lens can be derived dynamically, reflecting the system's accumulated experience rather than its immediate conversational state. The knowledge graph is composed of subgraphs that correspond to specific usage contexts, queries, or temporal windows, allowing the system to reason over both structure and recency.
These subgraphs may be constructed on demand at query time or incrementally maintained as structured representations that evolve with continued use. Nodes and relationships gain or lose salience based on how frequently and how recently they are accessed. Time series information is therefore intrinsic to the graph, enabling decay functions, reinforcement effects, and temporal heuristics. The persona lens generated from long-term memory is informed by this temporal structure, weighting recent and relevant knowledge more heavily while still retaining access to deeper historical context. In this way, long-term memory provides continuity and identity, while short-term memory provides adaptability and situational awareness, both unified through the evolving persona framework.
Core Abstractions
Persona as a State Vector
A persona at a given moment in time can be described as a collection of interpretable trait keys, where each key has an associated numeric weight that changes over time. Each key represents a specific behavioral or stylistic dimension such as tone, epistemic stance, verbosity, or abstraction level. The full persona is therefore the complete set of these key-weight pairs at that moment. The set of keys is fixed across the system, while the weights evolve as the system interacts with new data and events.
This representation is not prompt text. It is a structured control surface that governs how context is assembled and how generation is shaped.
Short-Term Memory as a State Transition System
Short-term memory can be understood as a process that transforms the current persona into a new persona in response to an event. The persona at the next moment in time is produced by applying an update function to the current persona and the triggering event. The event may be a user message, a retrieved document, or an internal system signal.
In a typical update rule, each persona weight at the next moment is computed as a combination of its previous value and a contribution derived from the event. A decay factor controls how much of the old value is retained, while an event influence factor controls how strongly the event pushes the weight in a new direction. This ensures smooth adaptation rather than abrupt shifts.
```python class PersonaState: def __init__(self, weights: dict[str, float]): self.weights = weights
def update(self, event_features: dict[str, float], alpha=0.9, beta=0.1): for k, delta in event_features.items(): self.weights[k] = alpha * self.weights.get(k, 0.0) + beta * delta ```
This is your short-term memory: volatile, contextual, and continuously rewritten.
Long-Term Memory as a Temporal Knowledge Graph
#### Knowledge Graph Definition
Long-term memory is represented as a directed, labeled graph with time-aware metadata. The graph consists of a set of nodes, a set of edges connecting those nodes, and a timing function that assigns timestamps and decay-related metadata to edges.
Nodes represent entities such as documents, concepts, users, or personas. Edges represent labeled relationships between those entities. Each node and edge stores semantic embeddings, symbolic attributes, and usage statistics that