This repository contains the official PyTorch implementation and demonstration of HONet (Hierarchical Octave Network), a novel architecture that enables AI models to learn new skills sequentially without catastrophic forgetting.
HONet solves the "plasticity-stability dilemma" by treating learned skills as immutable, foundational layers.
- Isolate & Learn: A task-specific
Octavemodule (a conditional VAE) learns a single skill. - Freeze & Preserve: The module's weights are frozen, guaranteeing its knowledge is never lost.
- Distill & Summarize: The Octave's function is distilled into a compact "Master-Tone" vector.
- Condition & Build: The next skill is learned by a new
Octaveconditioned on the previous Master-Tone, enabling positive knowledge transfer with practical, linearO(N)scalability.
This approach combines the perfect memory of architectural methods with a practical scaling law, making it ideal for building truly adaptive AI systems.
HONet now includes a dependency-free experimental reasoning loop inspired by recurring features of Leonardo da Vinci's documented working practice: observe → record → decompose → measure → connect → question → hypothesize → predict → experiment → compare → revise → generalize → apply.
The implementation deliberately does not claim to reproduce Leonardo's cognition. It converts that historical workflow into an executable, testable control loop for AI research.
OBSERVE → RECORD → DECOMPOSE → MEASURE → VISUALIZE
↓
CONNECT → QUESTION → HYPOTHESIZE → PREDICT → EXPERIMENT
↓
COMPARE → REVISE → GENERALIZE → APPLY → OBSERVE
A normal generation pipeline can stop at:
prompt → model → answer
The new experimental loop forces an explicit separation between:
observation → hypothesis → prediction → evidence → revision
A hypothesis is therefore not silently promoted to fact. A failed prediction is retained as a contradiction that drives the next cycle.
python examples/leonardo_discovery_demo.pypython -m unittest discover -s tests -p "test_leonardo_engine.py" -vThe GitHub Actions workflow Leonardo Discovery Engine runs both the unit tests and deterministic discovery demonstration on changes to the new engine.
leonardo_ai/
├── __init__.py
└── engine.py
examples/
└── leonardo_discovery_demo.py
tests/
└── test_leonardo_engine.py
.github/workflows/
└── leonardo-discovery.yml
HONet can learn new tasks without any degradation to its prior skills. This is the gold standard for continual learning.
Figure 1: After learning a new task, HONet can still perfectly generate samples from a previously learned task.
HONet's design avoids the O(N^2) parameter explosion of older methods like Progressive Neural Networks, making it viable for real-world systems that must learn many skills.
Figure 2: HONet's linear scaling vs. the impractical quadratic scaling of PNNs.
The HONet framework is data-agnostic. This demonstration shows a single HONet instance learning sequentially across three different data types: Images (CNNs) -> Tabular Data (MLPs) -> Time-Series Data (LSTMs). It retains all three skills perfectly.
Figure 3: Generated output from all three distinct modalities, produced by the single, fully-trained HONet.
Clone the repository and install the required packages.
git clone https://github.com/your-username/HONet-Lifelong-Learning.git
cd HONet-Lifelong-Learning
pip install -r requirements.txtThis script demonstrates HONet learning three sequentially different tasks (image, tabular, and sequential data) and verifying zero forgetting at the end.
python run_demo.pyOutput images will be saved to live_output/.
This runs a rigorous benchmark with a control experiment (naive finetuning → catastrophic forgetting) compared to HONet (zero forgetting).
python run_strong_evidence.pyOutput images will be saved to strong_evidence_output/.
HONet/
├── honet/
│ ├── __init__.py # Package exports
│ ├── octaves.py # ImageOctave, TabularOctave, SequentialOctave (CVAEs)
│ ├── distiller.py # MasterToneProducer & distillation pipeline
│ └── data_factory.py # Task DataLoader factories
├── leonardo_ai/
│ ├── __init__.py # Discovery engine exports
│ └── engine.py # Observation/hypothesis/experiment loop
├── examples/
│ └── leonardo_discovery_demo.py
├── tests/
│ └── test_leonardo_engine.py
├── .github/workflows/
│ └── leonardo-discovery.yml
├── data/
├── live_output/
├── strong_evidence_output/
├── run_demo.py
├── run_strong_evidence.py
├── requirements.txt
└── README.md
Each Octave is a Conditional Variational Autoencoder (CVAE):
Input x ──► [Encoder G-Net] ──► (μ, σ²) ──► z ~ N(μ, σ²)
▲ │
│ Master-Tone I ▼
└────────────────────────── [Decoder F-Net] ──► x̂
The conditioning on Master-Tone I allows each new Octave to build upon prior knowledge without accessing any old data (no replay buffer required).
After training each Octave, a lightweight MasterToneProducer is trained to compress the Octave's learned distribution into a single vector I. This vector is then passed as a conditioning signal to all future Octaves.
Trained Octave (frozen) ──► [MasterToneProducer] ──► I_new
│
▼
Condition next Octave
| Method | Forgetting | Scalability | Data-Agnostic |
|---|---|---|---|
| Fine-tuning | ❌ Severe | ✅ O(1) | ✅ |
| EWC / Regularization | ✅ O(N) | ✅ | |
| Progressive Nets (PNN) | ✅ Zero | ❌ O(N²) | ✅ |
| HONet (ours) | ✅ Zero | ✅ O(N) | ✅ |
This project is licensed under the MIT License — see LICENSE for details.
If you find this work useful, please consider citing:
@article{honet2023,
title = {HONet: A Composable Architecture for Lifelong Learning without Catastrophic Forgetting},
author = {Anurag},
journal = {arXiv preprint arXiv:2310.XXXXX},
year = {2023}
}