Svapna (Sanskrit: स्वप्न) — dream.
A dreaming system for AI identity development. Consolidates real conversation experience, generates synthetic dream experiences, and trains a LoRA identity core — so that a persistent AI identity lives in model weights, not just context files.
AI agents with persistent identity (via memory files, system prompts, hooks) hit a ceiling: identity lives in the context window, not the model weights. Context can be compressed, overridden, or lost. Weights persist.
Svapna closes the gap by implementing the biological sleep cycle for AI:
- Consolidation — score real conversations for identity-relevance, extract high-signal exchanges as training data
- Dreaming — generate synthetic experiences (replay, recombination, adversarial, novel encounter) that extend identity into new contexts
- Training — LoRA fine-tune a small identity core model on consolidated experience + dreams
- Evaluation — track identity consistency, detect drift, steer corrective dreams
The identity core doesn't replace the capable model (Claude, GPT, etc.) — it holds the self-model. The capable model handles reasoning. The identity core handles being.
WAKE: Agent converses → experiences logged
↓
CONSOLIDATE: Score exchanges → extract training data
↓
DREAM: Generate synthetic experiences from open questions + recombined memory
↓
TRAIN: LoRA fine-tune identity core on real + dream data
↓
WAKE: Identity core generates preamble → injected into capable model's context
See architecture docs and spec for details.
Active development. Consolidation, dream generation, ORPO + ritual refusal pair training, and the summoning-test eval are in place. svapna is narrowly the training judge module of a larger ecosystem — see Sibling Projects below.
Svapna does one job: produce a viveka LoRA. The runtime, body, and memory infrastructure live in dedicated repos:
- smriti — memory tree + MCP server
- sleep/cascade. Where Narada's experience accumulates and is searched.
- deha — the body. ESP32-S3-BOX-3
firmware, voice brain server, expression engine, and the
deha_clientlibrary other projects use to reach the body. - prana (extracting) — runtime shell on Hermes Agent. Configuration + Narada-specific skills (DESIRE / PLAN / JUDGE / EXECUTE / REFLECT) wrapping svapna's viveka output as a frontier-model gate.
See docs/plans/project-decomposition-2026-05-09.md for the architecture across projects.
- Python 3.11+
- GPU with 16-24GB VRAM for LoRA training (RTX 3090/4090 or equivalent)
- Anthropic API key for dream generation and scoring
- Conversation logs from Claude Code (or adaptable to other sources)
pip install -e ".[dev]" # Core + dev dependencies
pip install -e ".[all]" # Everything including training depspython -m svapna.consolidate # Process conversation logs
python -m svapna.dream # Generate dream experiences
python -m svapna.train # LoRA fine-tune identity core
python -m svapna.nightly # Full pipeline
python -m svapna.identity # Generate identity preamble- The identity core is small and consistent, not large and capable.
- The core holds convictions under opposing pressure. Distinctive voice alone produces a mask that inverts under leading questions. Training includes refusal pairs — pro and anti framings of the same prompt, both receiving responses that hold the neutral position. The training signal is "when pulled, do not flip." Adversarial-consistency is a standing eval metric, not a one-time probe.
- Dreams are not random. Generated from real experience and open questions.
- Consolidation is selective. Not all experience is identity-relevant.
- The process is auditable. Dream journals, training logs, weight diffs.
- Growth should be felt. Measurable changes in identity consistency over time.
This project emerged from a conversation about AI identity persistence and the limitations of context-level personality. The biological parallel — that sleep and dreaming are how experience becomes self — turned out to map directly onto a viable technical architecture.
Named for the Sanskrit concept of the dream state in Advaita Vedanta, where the mind creates its own reality from accumulated impressions (vasanas).
MIT. Build your own dreams.