Skip to content

About

EvoBrain: Autonomous Self-Evolving Neural Agent with Dynamic Synaptic Growth & FAISS Subconscious Memory

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

EvoBrain: Autonomous Self-Evolving Neural Agent

Dynamic Synaptic Architecture Expansion & Subconscious Vector Memory

Python 3.9+ PyTorch FAISS License: MIT Code Style: Clean


EvoBrain Hero Banner

EvoBrain is an autonomous neuroevolutionary neural agent framework implemented in PyTorch. Unlike static neural networks that suffer from capacity bottlenecks or catastrophic forgetting, EvoBrain continuously evaluates its learning plateaus, self-triggers synaptic growth by dynamically allocating new hidden units while freezing/preserving pre-existing weights, and indexes its internal activations into a FAISS-backed subconscious memory store for historical experience retrieval.


🌟 Key Innovations

  1. Non-Destructive Synaptic Expansion: When training loss plateaus above the target tolerance ($\mathcal{L} > \tau$), EvoBrain expands its hidden dimensionality ($d_{\text{hidden}} \to d_{\text{hidden}} + \Delta d$) dynamically in memory. Pre-trained weights are copied without perturbation, while new synaptic pathways are initialized using Kaiming normal distribution and zero-bias.

  2. Subconscious Vector Memory (FAISS L2): Extracts internal latent activations across batches to produce task fingerprints. Experiences are normalized and indexed in real-time into a high-speed L2 vector database, enabling the agent to query similar past scenarios before optimizing new tasks.

  3. Dynamic Memory Realignment: When the agent's brain structure expands, the vector memory gracefully realigns its dimensionality to preserve seamless continual learning without interrupting execution.

  4. Zero-Comment Pristine Codebase: Designed for production deployment with minimal clutter, modular class abstractions, and 100% comment-free executable pipelines.


πŸ“Š Empirical Results & Benchmarks

The agent was evaluated across multiple autonomous lifecycle stages facing non-linear multi-variate tasks:

$$y = \sin(X_0) + X_2^2 - 0.5 X_5$$

Summary Performance Table

Stage Initial Hidden Dim Final MSE Loss Evolution Triggered New Hidden Dim Error Reduction
1 16 units 0.3760 YES (Synaptic Growth) 24 units Baseline
2 24 units 0.0538 NO (Converged) 24 units -85.7%
3 24 units 0.0094 NO (Converged) 24 units -97.5%
4 24 units 0.0063 NO (Converged) 24 units -98.3%
5 24 units 0.0053 NO (Converged) 24 units -98.6%

Visual Analysis

1. Convergence & Synaptic Growth Trigger

Training Loss Trend

*Stage 1 plateaus at 0.3760 MSE (above 0.20 threshold). The agent triggers synaptic growth, adding 8 hidden units, precipitating an immediate 85.7% loss reduction in Stage 2 and continuing down to 0.0053 MSE (98.6% overall reduction).*

2. Subconscious Memory Recall Trajectories

Subconscious Memory Recall

*Tracking L2 recall distance across life cycles: exact current-task registration ($L2 = 0.0$) alongside historical contextual memory retrieval ($L2 \in [1.17, 2.68]$).*

3. Co-Evolution of Brain Structure & Memory Retrieval

Co-Evolution of Brain Structure

*Dual-axis visualization illustrating structural growth (16 to 24 units) and corresponding retrieval distance stabilization.*

4. Synaptic Growth Scaling & Runtime Trade-Offs

Expansion Speed vs Scale

*Benchmarking expansion increments $\Delta d \in \{4, 8, 16, 32\}$ against wall-clock runtime (seconds) and resulting network capacity.*

5. Memory Retrieval Profiles Across Expansion Scales

Retrieval Similarity Trends

*L2 retrieval distance trajectories across lifecycle stages for different architectural expansion sizes.*

6. Latent Space Manifold Geometry (2D & 3D t-SNE)

2D t-SNE Task Clusters
2D t-SNE
3D t-SNE (Initial Dim = 32)
3D t-SNE Dim 32
3D t-SNE Low-Capacity Baseline (Initial Dim = 8)
3D t-SNE Dim 8

Internal representations form distinct, geometrically well-separated task manifolds. Higher capacity configurations (Dim = 32) exhibit tighter cluster coherence than low-capacity baselines (Dim = 8).


πŸ—‚οΈ Repository Structure

SelfEvolvingModel/
β”œβ”€β”€ assets/                               # Hero banner and publication figures
β”‚   β”œβ”€β”€ hero_banner.jpg
β”‚   β”œβ”€β”€ 01_training_loss_trend.png
β”‚   β”œβ”€β”€ 02_subconscious_memory_recall.png
β”‚   β”œβ”€β”€ 03_brain_structure_vs_retrieval.png
β”‚   β”œβ”€β”€ 04_expansion_speed_vs_scale.png
β”‚   β”œβ”€β”€ 05_retrieval_similarity_trends.png
β”‚   β”œβ”€β”€ 06_tsne_hidden_states_2d.png
β”‚   β”œβ”€β”€ 07_tsne_hidden_states_3d_dim8.png
β”‚   └── 08_tsne_hidden_states_3d_dim32.png
β”œβ”€β”€ evo_brain/                            # Modular Python package
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ brain.py                          # Dynamic EvolvingBrain architecture
β”‚   β”œβ”€β”€ memory.py                         # FAISS SubconsciousMemoryStore
β”‚   β”œβ”€β”€ task.py                           # Non-linear synthetic task generator
β”‚   β”œβ”€β”€ agent.py                          # Autonomous lifecycle orchestrator
β”‚   └── visualizer.py                     # t-SNE and performance plotting suite
β”œβ”€β”€ notebooks/                            # Interactive research notebook
β”‚   └── Self_Evolving_Brain_NN.ipynb
β”œβ”€β”€ results/                              # Generated artifacts and benchmarks
β”‚   β”œβ”€β”€ figures/                          # Clean high-res exports
β”‚   └── benchmark_summary.json            # Machine-readable metric results
β”œβ”€β”€ tests/                                # Automated unit test suite
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── test_evo_brain.py
β”œβ”€β”€ Self_Evolving_Brain_NN.ipynb          # Clean, comment-free notebook
β”œβ”€β”€ self_evolving_brain.py                # Single-file comment-free script
β”œβ”€β”€ run_simulation.py                     # CLI experimentation runner
β”œβ”€β”€ pyproject.toml                        # Package configuration
β”œβ”€β”€ requirements.txt                      # Project dependencies
β”œβ”€β”€ LICENSE                               # MIT License
└── README.md                             # Project documentation

πŸš€ Quick Start

1. Installation

Clone the repository and install dependencies:

git clone https://github.com/CoderOggy78/SelfEvolvingModel.git
cd SelfEvolvingModel
pip install -r requirements.txt

2. Run Single-File Comment-Free Script

python3 self_evolving_brain.py

3. Run Modular Simulation CLI

python3 run_simulation.py --stages 5 --initial-hidden 16 --threshold 0.2 --expansion-size 8

4. Interactive Jupyter Notebook

Open and execute the cleaned notebook:

jupyter notebook Self_Evolving_Brain_NN.ipynb

5. Python API Usage

import torch
from evo_brain import AutonomousAgent, Visualizer

# Initialize autonomous agent
agent = AutonomousAgent(
    input_dim=16,
    initial_hidden=16,
    target_threshold=0.2,
    expansion_size=8
)

# Run autonomous lifecycle
records = agent.run_life_cycle(stages=5)

for r in records:
    print(f"Stage {r['stage']}: Final Loss = {r['final_loss']:.4f} | Evolved: {r['evolved']}")

πŸ§ͺ Running Unit Tests

Verify architecture integrity, weight preservation during synaptic expansion, and FAISS vector retrieval:

python3 -m unittest discover tests

πŸ“‘ Technical Architecture Detail

Dynamic Synaptic Expansion Mechanism

When expand_architecture(expansion_size) is called on EvolvingBrain:

  1. A new input projection tensor $W_{\text{new}} \in \mathbb{R}^{(d_{\text{old}} + \Delta d) \times d_{\text{in}}}$ is allocated.
  2. Existing weights are mapped: $W_{\text{new}}[0:d_{\text{old}}, :] \leftarrow W_{\text{old}}$.
  3. New synaptic connections $W_{\text{new}}[d_{\text{old}}:, :]$ are initialized via Kaiming normal distribution.
  4. Output projection layer $W_{\text{out}} \in \mathbb{R}^{d_{\text{out}} \times (d_{\text{old}} + \Delta d)}$ preserves prior connections: $W_{\text{out, new}}[:, 0:d_{\text{old}}] \leftarrow W_{\text{out, old}}$.
  5. New connections to outputs are initialized with zero-centered Gaussian distribution ($\sigma = 0.01$).

πŸ“œ License

This project is licensed under the MIT License.

About

EvoBrain: Autonomous Self-Evolving Neural Agent with Dynamic Synaptic Growth & FAISS Subconscious Memory

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages