Instructions to use Invictus-AI/self-evolving-nn with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Invictus-AI/self-evolving-nn with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://Invictus-AI/self-evolving-nn") - Notebooks
- Google Colab
- Kaggle
Kashyap Khakhkhar commited on
Upload PLAN.md with huggingface_hub
Browse files
PLAN.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 𧬠Self-Evolving Neural Network β Project Plan & Status
|
| 2 |
+
|
| 3 |
+
## Current Status: β
Core Complete, GUI Working, Dataset Integrated, π¬ English Training RUNNING
|
| 4 |
+
|
| 5 |
+
### Active Training Runs (Aug 1)
|
| 6 |
+
| Run | Command | Status | Checkpoints |
|
| 7 |
+
|-----|---------|--------|-------------|
|
| 8 |
+
| FABLE numeric regression | `--dataset fable --n-samples 10000 --generations 30 --pop-size 6 --train-epochs 10` | β
RUNNING (PID 22047, 120-min budget) | `evo_checkpoints/` |
|
| 9 |
+
| **English understanding** | `--text-dataset cornell-movie-review-data/rotten_tomatoes --n-samples 3000 --generations 10 --pop-size 4 --train-epochs 5` | π¬ RUNNING (PID 33878, 90-min budget) | `evo_checkpoints_text/` |
|
| 10 |
+
|
| 11 |
+
> β οΈ Note: the newer `huggingface_hub` (β₯1.26) requires **namespaced** dataset ids β use
|
| 12 |
+
> `cornell-movie-review-data/rotten_tomatoes`, NOT bare `rotten_tomatoes` (that errors with `HfUriError`).
|
| 13 |
+
> The FABLE id `Crownelius/Complete-FABLE.5-traces-2M` already has a namespace, so it's unaffected.
|
| 14 |
+
|
| 15 |
+
### π Critical data bug found & fixed (Aug 1)
|
| 16 |
+
The first English run scored **50% (chance) on held-out reviews** despite high training fitness.
|
| 17 |
+
Root cause: `rotten_tomatoes` train split is **sorted by label** (rows 0β4000 all-positive,
|
| 18 |
+
6000+ all-negative). `load_text_dataset` used `split="train[:3000]"` β the model trained on a
|
| 19 |
+
**single class** and learned "always predict positive" (100% on that slice, 50% on balanced test).
|
| 20 |
+
|
| 21 |
+
**Fix:** `load_text_dataset` now loads the full split and draws a **seeded random sample**
|
| 22 |
+
(`np.random.RandomState(42).choice(..., replace=False)`) instead of a head-slice.
|
| 23 |
+
Verified: 3000-sample draw is now 50.0% positive. β οΈ Same hazard applies to any HF dataset
|
| 24 |
+
with sorted labels β never head-slice without checking label distribution.
|
| 25 |
+
|
| 26 |
+
### π§ Evolution-engine upgrades (Aug 1)
|
| 27 |
+
- **Classification fitness is now validation-accuracy based** (`best_val_accΒ² Γ 100 / penalty`)
|
| 28 |
+
instead of `1/val_loss` β loss-only fitness rewarded memorization (the cause of the
|
| 29 |
+
first run's 100% train / 50% test split). Regression fitness unchanged.
|
| 30 |
+
- **LR scheduling**: `ReduceLROnPlateau` (factor 0.5, patience 2) during each eval.
|
| 31 |
+
- **Diversity pressure** (`apply_diversity_pressure`): exact duplicate configs β fitness
|
| 32 |
+
Γ0.5; near-identical-to-best topologies β Γ0.9. The current champion is exempt so
|
| 33 |
+
stagnation tracking and best-genome re-selection stay valid.
|
| 34 |
+
- **`--continue` is text-aware**: `SelfTrainer.continue_evolution` now passes
|
| 35 |
+
`task_type`/`vectorizer`/`embed_dim`/`checkpoint_dir` through, and `run()` only
|
| 36 |
+
initializes a fresh population when none was pre-seeded (fixes the old bug where
|
| 37 |
+
`--continue` clobbered the seeded population and rebuilt a regression engine).
|
| 38 |
+
- **`load_fable_dataset`** also now random-samples (seeded) instead of head-slicing.
|
| 39 |
+
|
| 40 |
+
### π English text path β end-to-end raw-English inference (Aug 1)
|
| 41 |
+
- `save_best_model` now **bakes the fitted TextVectorizer into `best_model.keras`** for
|
| 42 |
+
text runs β the saved model accepts **raw English strings** (no separate tokenizer needed).
|
| 43 |
+
Also saves `best_model_ids.keras` (token-id core) and `vectorizer_config.json`
|
| 44 |
+
(incl. the exact fitted vocab list for token-id parity in eval).
|
| 45 |
+
- `eval_text_model.py` scores the best model on held-out test reviews in 3 auto modes:
|
| 46 |
+
1) serving (raw strings), 2) token-id (reuses saved vocab), 3) rebuild preview.
|
| 47 |
+
- `auto_pipeline.sh` (running): waits for FABLE + TEXT to finish β evals the text run β
|
| 48 |
+
launches scaled-up run `evo_checkpoints_text_v2` (8K samples, vocab 20k, embed 128) β evals it.
|
| 49 |
+
- `check_progress.py`: prints generation-by-generation fitness for both checkpoint dirs.
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
### π§ v3-Gemma strategy (Aug 1) β "extract the GPT of Gemma + self-evolve on FABLE"
|
| 53 |
+
|
| 54 |
+
**Discovery:** FABLE.5-traces-2M's `row_json` contains REAL ENGLISH β it's 229K AI
|
| 55 |
+
coding-session traces with actual user prompts (`message.content`) + completions.
|
| 56 |
+
So a pretrained language model CAN read FABLE β the earlier "FABLE is numeric-only"
|
| 57 |
+
assumption was wrong (only our hand-engineered 10 features were numeric).
|
| 58 |
+
|
| 59 |
+
**New plan (v3, Colab GPU):**
|
| 60 |
+
1. Load `Qwen/Qwen2.5-0.5B-Instruct` (open GPT-class transformer, Apache 2.0, un-gated
|
| 61 |
+
repo, ~1.1 GB FP16 β the "GPT" we borrow English from; frozen, forward-only).
|
| 62 |
+
(Swapped from gemma-3-270m for reliability: no gated terms acceptance needed,
|
| 63 |
+
standard Qwen2 architecture, no `trust_remote_code`, 896-dim hidden state.)
|
| 64 |
+
2. Extract FABLE text (`row_json` β content + completion) β mean-pooled Gemma last
|
| 65 |
+
hidden state = per-row English-understanding embeddings (input_dim β 1152).
|
| 66 |
+
3. Feed embeddings as X into `EvolutionEngine` (task_type=regression, target =
|
| 67 |
+
`log1p(seen_count)`) β the SAME engine as local runs, now on a T4 GPU (10-20Γ faster).
|
| 68 |
+
4. Eval held-out RΒ²/MAE β push `evo_checkpoints_gemma/` back to HF.
|
| 69 |
+
|
| 70 |
+
**Deliverable:** `evo_gemma_fable_colab.ipynb` (18 cells, generated by
|
| 71 |
+
`make_gemma_colab_notebook.py` β run it to regenerate). Prereqs: HF token (only for
|
| 72 |
+
pushing results back; model download is un-gated) + project code pushed to REPO_ID
|
| 73 |
+
via `hf_upload.py`.
|
| 74 |
+
This is the bridge toward a true mini-GPT: attention + generative head come later (v4/v5).
|
| 75 |
+
|
| 76 |
+
### Files Created
|
| 77 |
+
| File | Lines | Description |
|
| 78 |
+
|------|-------|-------------|
|
| 79 |
+
| `self_evolving_model.py` | 996+ | Core evolution engine with genome system, training, checkpointing |
|
| 80 |
+
| `evo_gui.py` | 578+ | Flask web GUI with real-time monitoring, Chart.js fitness plots |
|
| 81 |
+
| `hf_upload.py` | β | Upload model/genome/history + auto-generated model card to Hugging Face |
|
| 82 |
+
| `make_gemma_colab_notebook.py` | β | Generates `evo_gemma_fable_colab.ipynb` (v3-Qwen strategy) |
|
| 83 |
+
| `evo_gemma_fable_colab.ipynb` | β | Colab GPU: Qwen2.5-0.5B embeddings β self-evolved head on FABLE text |
|
| 84 |
+
| `evo_v2_colab.ipynb` | β | Ready-to-run Google Colab notebook (v2/v3 GPU training, scale-up, push-back) |
|
| 85 |
+
| `make_growth_chart.py` | β | Generates `growth_limit.html` β theoretical parameter-growth line chart |
|
| 86 |
+
| `growth_limit.html` | β | Dependency-free SVG chart: max growth 4,216 β 345,352 params (extrap. to 1M @ ~16 layers) |
|
| 87 |
+
| `requirements.txt` | β | Pinned dependencies for laptop/Colab reproducibility |
|
| 88 |
+
| `PLAN.md` | β | This file β project plan and continuation guide |
|
| 89 |
+
|
| 90 |
+
### Checkpoints (from previous test runs)
|
| 91 |
+
| File | Description |
|
| 92 |
+
|------|-------------|
|
| 93 |
+
| `evo_checkpoints/checkpoint.pkl` | Serialized evolution state |
|
| 94 |
+
| `evo_checkpoints/best_model.keras` | Best evolved model |
|
| 95 |
+
| `evo_checkpoints/best_genome.json` | Best genome architecture config |
|
| 96 |
+
| `evo_checkpoints/evolution_history.json` | Fitness history across generations |
|
| 97 |
+
|
| 98 |
+
---
|
| 99 |
+
|
| 100 |
+
## What's Been Built
|
| 101 |
+
|
| 102 |
+
### 1. Genome System (`Genome` class)
|
| 103 |
+
- Neural network architecture encoded as mutable genome
|
| 104 |
+
- Layers, units, activations, dropout, batch norm, learning rate, optimizer
|
| 105 |
+
- **Mutation operators**: add/remove layers, change units, swap activations, perturb LR
|
| 106 |
+
- **Crossover**: layer-by-layer parent mixing with hyperparameter inheritance
|
| 107 |
+
|
| 108 |
+
### 2. Evolution Engine (`EvolutionEngine` class)
|
| 109 |
+
- Population-based evolutionary optimization
|
| 110 |
+
- Elitism selection (top 30% survive)
|
| 111 |
+
- Reproduction via mutation + crossover
|
| 112 |
+
- Automatic checkpointing every generation
|
| 113 |
+
- Stop event for GUI integration (`threading.Event`)
|
| 114 |
+
- Generation callback for real-time GUI updates
|
| 115 |
+
|
| 116 |
+
### 3. Dataset Integration (`DataHandler.load_fable_dataset`)
|
| 117 |
+
- Loads `Crownelius/Complete-FABLE.5-traces-2M` from HuggingFace (228K rows)
|
| 118 |
+
- Extracts 10-dimensional feature vectors from heterogeneous JSON coding traces:
|
| 119 |
+
- Message length, word count, code keyword frequency
|
| 120 |
+
- Completion length, chain-of-thought length
|
| 121 |
+
- Tool use indicators, output complexity
|
| 122 |
+
- Session entropy (deterministic md5 hash)
|
| 123 |
+
- Special character ratio
|
| 124 |
+
- StandardScaler normalization on features
|
| 125 |
+
- Log-normalization on target (seen_count)
|
| 126 |
+
|
| 127 |
+
### 4. Web GUI (`evo_gui.py`)
|
| 128 |
+
- **Flask** server with single-page HTML/JS frontend
|
| 129 |
+
- **Dark theme** with monospace font (GitHub-style)
|
| 130 |
+
- **Chart.js** real-time fitness line chart (best + avg)
|
| 131 |
+
- **Controls**: Start/Stop buttons, parameter inputs
|
| 132 |
+
- **Statistics panel**: generation, fitness, improvement %, population
|
| 133 |
+
- **Genome visualization**: layer chips, architecture display
|
| 134 |
+
- **Population leaderboard**: sorted by fitness with medals
|
| 135 |
+
- **Evolution log**: scrolling text log
|
| 136 |
+
- **API endpoints**:
|
| 137 |
+
- `GET /` β HTML dashboard
|
| 138 |
+
- `GET /api/status` β JSON state
|
| 139 |
+
- `POST /api/start` β Start evolution with params
|
| 140 |
+
- `POST /api/stop` β Stop evolution
|
| 141 |
+
|
| 142 |
+
### 5. Model Building (`ModelEvaluator`)
|
| 143 |
+
- Builds Keras models from genome configs
|
| 144 |
+
- Supports 4 optimizers: Adam, SGD, RMSprop, AdamW
|
| 145 |
+
- 7 activation functions: relu, tanh, sigmoid, elu, selu, swish, linear
|
| 146 |
+
- Batch normalization and dropout support
|
| 147 |
+
- Fitness = 1 / (val_loss Γ complexity_penalty)
|
| 148 |
+
|
| 149 |
+
### 6. Gated Feature Architecture (`top3_features`)
|
| 150 |
+
- Each genome encodes which **3 features** (by index) feed layer 1
|
| 151 |
+
- The remaining features are concatenated into **every layer after the first** (incl. output)
|
| 152 |
+
- Feature selection **evolves** via mutation/crossover (e.g. `top3=[1,3,7]`)
|
| 153 |
+
- Old checkpoints without the field default to `[0,1,2]` (backward compatible)
|
| 154 |
+
|
| 155 |
+
### 7. β Safety Gates (`SafetyGates` class) β the AI CANNOT change these
|
| 156 |
+
- **Hard walls**: max 16 layers, 2048 units/layer, 5M total params β enforced on EVERY
|
| 157 |
+
evaluation via `enforce_genome()` (even corrupt/old checkpoints get clamped)
|
| 158 |
+
- **Failure gates**: NaN/Inf or exploded val_loss β fitness 0; over-param wall β fitness 0
|
| 159 |
+
- **Fitness clamp**: fitness bounded to `[0, 1e9]`
|
| 160 |
+
- **Runtime gates**: `--max-minutes` wall-clock budget; `--stagnation-limit` (default 12 gens
|
| 161 |
+
without improvement β halt) β both trip safely and log to `safety_trips`
|
| 162 |
+
- Safety constants live OUTSIDE the genome (module-level), never checkpointed,
|
| 163 |
+
never mutated by evolution β editing `SafetyGates` requires source-code changes
|
| 164 |
+
|
| 165 |
+
### 8. English understanding β honest status
|
| 166 |
+
- The model does **NOT** understand English. It is a numeric regressor: FABLE traces are
|
| 167 |
+
converted to 10 numbers (message length, word count, code-keyword freq, ...) and it
|
| 168 |
+
predicts a count. There is no language model in this stack.
|
| 169 |
+
- Making it "understand English" requires a different architecture (embedding/text model),
|
| 170 |
+
which is beyond this neuroevolution setup.
|
| 171 |
+
|
| 172 |
+
## Scaling Pipeline (v1 β HF β v2/v3)
|
| 173 |
+
|
| 174 |
+
```
|
| 175 |
+
LOCAL CPU (v1) βββΆ hf_upload.py βββΆ Hugging Face βββΆ evo_v2_colab.ipynb (GPU, bigger caps) βββΆ push back
|
| 176 |
+
small models model card durable backup scale to 512-1024 units / 8-10 layers
|
| 177 |
+
```
|
| 178 |
+
|
| 179 |
+
- **Local (this box):** fast CPU iterations; checkpoints auto-save every generation
|
| 180 |
+
- **HF upload:** `python3 hf_upload.py --repo user/repo --token $HF_TOKEN` (dry-run with `--dry-run`)
|
| 181 |
+
- **Colab v2/v3:** open `evo_v2_colab.ipynb` β Runtime βΈ Run all β paste HF_TOKEN. It pulls the repo,
|
| 182 |
+
continues evolution with `--max-units/--max-layers`, and pushes results back
|
| 183 |
+
- **Laptop:** `pip install -r requirements.txt` then run as normal
|
| 184 |
+
- β οΈ This cloud VM resets ~20 min after session end β push checkpoints to HF early and often
|
| 185 |
+
|
| 186 |
+
### Genome Search Space (scalable)
|
| 187 |
+
- Default: max 6 layers Γ 256 units (~345K params ceiling)
|
| 188 |
+
- `--max-units 512 --max-layers 8` β ~1.1M params ceiling (v2)
|
| 189 |
+
- `--max-units 1024 --max-layers 10` β larger (v3, GPU)
|
| 190 |
+
- See `growth_limit.html` for the theoretical growth line
|
| 191 |
+
- β All of the above are still capped by `SafetyGates` hard walls (16 layers / 2048 units / 5M params)
|
| 192 |
+
|
| 193 |
+
---
|
| 194 |
+
|
| 195 |
+
## Scaling Pipeline (v1 β HF β v2/v3)
|
| 196 |
+
|
| 197 |
+
```
|
| 198 |
+
LOCAL CPU (v1) βββΆ hf_upload.py βββΆ Hugging Face βββΆ evo_v2_colab.ipynb (GPU, bigger caps) βββΆ push back
|
| 199 |
+
small models model card durable backup scale to 512-1024 units / 8-10 layers
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
- **Local (this box):** fast CPU iterations; checkpoints auto-save every generation
|
| 203 |
+
- **HF upload:** `python3 hf_upload.py --repo user/repo --token $HF_TOKEN` (dry-run with `--dry-run`)
|
| 204 |
+
- **Colab v2/v3:** open `evo_v2_colab.ipynb` β Runtime βΈ Run all β paste HF_TOKEN. It pulls the repo,
|
| 205 |
+
continues evolution with `--max-units/--max-layers`, and pushes results back
|
| 206 |
+
- **Laptop:** `pip install -r requirements.txt` then run as normal
|
| 207 |
+
- β οΈ This cloud VM resets ~20 min after session end β push checkpoints to HF early and often
|
| 208 |
+
|
| 209 |
+
### Genome Search Space (scalable)
|
| 210 |
+
- Default: max 6 layers Γ 256 units (~345K params ceiling)
|
| 211 |
+
- `--max-units 512 --max-layers 8` β ~1.1M params ceiling (v2)
|
| 212 |
+
- `--max-units 1024 --max-layers 10` β larger (v3, GPU)
|
| 213 |
+
- See `growth_limit.html` for the theoretical growth line
|
| 214 |
+
|
| 215 |
+
## How to Run
|
| 216 |
+
|
| 217 |
+
### CLI Mode (terminal)
|
| 218 |
+
```bash
|
| 219 |
+
# Quick run with synthetic data
|
| 220 |
+
python3 self_evolving_model.py --generations 20 --pop-size 8
|
| 221 |
+
|
| 222 |
+
# With FABLE dataset
|
| 223 |
+
python3 self_evolving_model.py --dataset fable --n-samples 10000 --generations 30
|
| 224 |
+
|
| 225 |
+
# Continue from previous best
|
| 226 |
+
python3 self_evolving_model.py --continue --generations 50
|
| 227 |
+
```
|
| 228 |
+
|
| 229 |
+
### GUI Mode (web browser)
|
| 230 |
+
```bash
|
| 231 |
+
# Standalone (loads dataset on demand)
|
| 232 |
+
python3 evo_gui.py --port 5000 --n-samples 5000
|
| 233 |
+
|
| 234 |
+
# Via CLI flag (pre-loads dataset)
|
| 235 |
+
python3 self_evolving_model.py --gui --gui-port 5000 --n-samples 5000
|
| 236 |
+
```
|
| 237 |
+
Then open `http://localhost:5000` in browser.
|
| 238 |
+
|
| 239 |
+
---
|
| 240 |
+
|
| 241 |
+
## Verified Working β
|
| 242 |
+
- [x] Genome mutation/crossover
|
| 243 |
+
- [x] Model building from genomes
|
| 244 |
+
- [x] Evolution loop with elitism
|
| 245 |
+
- [x] Checkpoint save/load/resume
|
| 246 |
+
- [x] CLI argument parsing
|
| 247 |
+
- [x] Dataset loading from HuggingFace
|
| 248 |
+
- [x] Feature extraction from JSON traces
|
| 249 |
+
- [x] Flask GUI serving HTML
|
| 250 |
+
- [x] GUI API endpoints (start/stop/status)
|
| 251 |
+
- [x] Background thread evolution
|
| 252 |
+
- [x] Real-time GUI updates via polling
|
| 253 |
+
- [x] Chart.js fitness visualization
|
| 254 |
+
- [x] Population leaderboard
|
| 255 |
+
- [x] Stop signal from GUI β engine
|
| 256 |
+
|
| 257 |
+
---
|
| 258 |
+
|
| 259 |
+
## Next Steps (TODO)
|
| 260 |
+
|
| 261 |
+
### Priority 1: Run Full Training
|
| 262 |
+
```bash
|
| 263 |
+
# Start GUI with full dataset
|
| 264 |
+
python3 evo_gui.py --port 5000 --n-samples 10000
|
| 265 |
+
```
|
| 266 |
+
Then in browser: set Generations=30, Pop=6, Train Epochs=10, click Start.
|
| 267 |
+
|
| 268 |
+
### Priority 2: Potential Improvements
|
| 269 |
+
1. **Streaming dataset loading** β current approach downloads full 228K rows then slices. Use HF streaming for faster loads.
|
| 270 |
+
2. **GPU support** β if CUDA available, use `tf.distribute.MirroredStrategy` for faster training.
|
| 271 |
+
3. **Dataset reload button** in GUI β allow changing sample count without restart.
|
| 272 |
+
4. **Export best model** β add button to download the best evolved model.
|
| 273 |
+
5. **Diversity pressure** β penalize genomes too similar to prevent convergence to local optima.
|
| 274 |
+
6. **Learning rate scheduling** β add cosine annealing or step decay to genome.
|
| 275 |
+
|
| 276 |
+
### Priority 3: Architecture Enhancements
|
| 277 |
+
1. **Multi-objective evolution** β optimize both fitness AND model size.
|
| 278 |
+
2. **Transfer learning** β start from pre-trained model weights.
|
| 279 |
+
3. **Neural Architecture Search (NAS)** β add skip connections, attention layers.
|
| 280 |
+
4. **Distributed evolution** β run populations across multiple machines.
|
| 281 |
+
|
| 282 |
+
---
|
| 283 |
+
|
| 284 |
+
## Architecture Diagram
|
| 285 |
+
|
| 286 |
+
```
|
| 287 |
+
βββββββββββββββοΏ½οΏ½οΏ½βββββββββββββββββββββββββββββββββββββββ
|
| 288 |
+
β evo_gui.py β
|
| 289 |
+
β ββββββββββββ ββββββββββββ ββββββββββββββββββββ β
|
| 290 |
+
β β Flask β β Chart.jsβ β HTML Dashboard β β
|
| 291 |
+
β β Routes ββββ Live UI ββββ Controls/Stats β β
|
| 292 |
+
β ββββββ¬ββββββ ββββββββββββ ββββββββββββββββββββ β
|
| 293 |
+
β β /api/start β
|
| 294 |
+
β βΌ β
|
| 295 |
+
β ββββββββββββββββββββββββββββββββββββββββββββ β
|
| 296 |
+
β β Background Thread β β
|
| 297 |
+
β β βββββββββββββββ ββββββββββββββββββββ β β
|
| 298 |
+
β β β DataHandler β β EvolutionEngine β β β
|
| 299 |
+
β β β (HF Dataset)ββββ (Population) β β β
|
| 300 |
+
β β βββββββββββββββ ββββββββββ¬ββββββββββ β β
|
| 301 |
+
β β β callback β β
|
| 302 |
+
β β βΌ β β
|
| 303 |
+
β β βββββββββββββββββββββββββββββββββββββββ β β
|
| 304 |
+
β β β ModelEvaluator β β β
|
| 305 |
+
β β β Genome β Keras Model β Fitness β β β
|
| 306 |
+
β β βββββββββββββββββββββββββββββββββββββββ β β
|
| 307 |
+
β ββββββββββββββββββββββββββββββββββββββββββββ β
|
| 308 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 309 |
+
β
|
| 310 |
+
βΌ
|
| 311 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 312 |
+
β self_evolving_model.py β
|
| 313 |
+
β ββββββββββββ βββββββββββββ βββββββββββββββββββ β
|
| 314 |
+
β β Genome β β Data β β Evolution β β
|
| 315 |
+
β β (config) β β Handler β β Engine β β
|
| 316 |
+
β ββββββββββββ βββββββββββββ βββββββββββββββββββ β
|
| 317 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 318 |
+
```
|
| 319 |
+
|
| 320 |
+
---
|
| 321 |
+
|
| 322 |
+
## Dependencies
|
| 323 |
+
- Python 3.12+
|
| 324 |
+
- TensorFlow 2.21.0
|
| 325 |
+
- NumPy 2.4.6
|
| 326 |
+
- Flask 3.1.3
|
| 327 |
+
- datasets 5.0.1 (HuggingFace)
|
| 328 |
+
- huggingface_hub 1.26.0
|
| 329 |
+
|
| 330 |
+
All installed and verified working.
|