Skip to content

lexasub/somnolent_llm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SomnolentLLM

An LLM that sleeps, gets tired, and is born β€” a biologically inspired architecture for continual learning.

Python 3.9+ PyTorch


🌟 Concept

SomnolentLLM is an experimental system that treats an LLM as a living organism with its own rhythms:

  • πŸ’€ Sleep β€” NREM/REM/Deep Sleep cycles for knowledge consolidation
  • 😴 Fatigue β€” homeostatic monitoring for automatic learning regulation
  • 🧬 Embryogenesis β€” "birthing" a model from the knowledge of parent models
  • 🌐 Online Feeding β€” an embryo that grows on your data via HTTP API

Hypothesis: biologically inspired mechanisms make continual LLM learning more stable and efficient.

πŸ“– Detailed Concept β†’


πŸš€ Quick Start

Installation

pip install -e ".[dev]"

Training the Model

somnolent-train --model_path <model> --data_path <data>

Embryogenesis (Model Birth)

somnolent-birth --config config.qwen35.yaml

HTTP Server with Live Embryo

# Prenatal phase (feeding)
python3 server.py --mode embryonic --port 8080

# Feeding text
curl -X POST http://localhost:8080/embryo/feed \
  -d '{"text": "Hello world", "source": "ambient"}'

# After saturation β†’ birth β†’ inference
python3 server.py --mode inference --port 8000

πŸ“š Documentation

Document Description
CONCEPT πŸ†• Project Idea β€” what and why
ARCHITECTURE Detailed component architecture
EMBRYOGENESIS Model birth process
LORA LoRA initialization methods
MATH Mathematics behind the algorithms

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   SomnolentLLM                          β”‚
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Sleep Engine β”‚  β”‚   Fatigue    β”‚  β”‚   Manifold    β”‚ β”‚
β”‚  β”‚ NREM/REM/DS  β”‚  β”‚   Monitor    β”‚  β”‚ Accumulator   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  Episodic    β”‚  β”‚    DMN       β”‚  β”‚  LoRA Adapter β”‚ β”‚
β”‚  β”‚  Buffer      β”‚  β”‚  Generator   β”‚  β”‚  (trainable)   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

Component Role
SleepEngine FSM of sleep cycles (NREM β†’ REM β†’ Deep Sleep)
FatigueMonitor Homeostatic sleep pressure
ManifoldAccumulator Geometrically correct gradients
EpisodicBuffer Activation storage with LRU eviction
DMNGenerator "Dream" generation in REM phase
LoRA Adapter Low-rank adaptation (target layers only)

🧬 Embryogenesis

Status: βœ… COMPLETED SUCCESSFULLY

Results:

  • Perplexity: 9.62 (baseline: 9.69) β€” quality preserved
  • Generation: coherent text
  • OOM errors: 0

Birth Process

  1. Genetic phase β€” SVD initialization of LoRA from parent models
  2. Synthesis phase β€” generation of synthetic memories
  3. Awakening β€” first sleep cycle, wake up
# Check embryo
python3 debug/quick_sanity_check.py --adapter ./output/born_adapter_v5.pt
python3 debug/evaluate_embryo.py --adapter ./output/born_adapter_v5.pt

πŸ€– Base Model: Qwen3.5

We use Qwen3.5-2B with a hybrid architecture:

  • linear_attention (18 layers) β€” frozen, fast
  • full_attention (6 layers) β€” trained via LoRA

A balance between speed and quality during training.


🎯 Use Cases

1. Continual Learning on Data Streams

Data β†’ Model β†’ Fatigue β†’ Sleep β†’ Improved Model

2. Birth of a Specialized Model

Parent Model A + Parent Model B β†’ Embryogenesis β†’ Birth β†’ Fine-tuning

3. Online Embryo Feeding

HTTP API β†’ Embryo β†’ Saturation β†’ Birth β†’ Inference

πŸ“ Project Structure

somnolent_llm/
β”œβ”€β”€ core/           # Core: sleep, fatigue, birth
β”œβ”€β”€ adapters/       # LoRA adapters for Qwen3.5
β”œβ”€β”€ memory/         # Episodic memory and dream generators
β”œβ”€β”€ utils/          # Configuration, utilities
β”œβ”€β”€ examples/       # Usage examples
β”œβ”€β”€ docs/           # Documentation
β”œβ”€β”€ scripts/        # Embryo feeding scripts
└── client/         # HTTP API clients

βš™οΈ Requirements

  • Python 3.9+
  • PyTorch 2.0+
  • Transformers 4.35+
  • CUDA 11.8+ (for GPU training)

πŸ“Š Project Status

βœ… Embryogenesis completed β€” model was born successfully
⏸️ Project on pause β€” code works, but development is suspended


πŸ“œ Project History

This project was started on March 15, 2026. Over the following weeks it was actively developed with sleep mechanics, fatigue monitoring, and embryogenesis features. The codebase represents a snapshot of the system at the point when development was paused.


🀝 Contact

GitHub Issues for questions and discussions

About

No description, website, or topics provided.

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors