learning-brain 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.4
2
+ Name: learning_brain
3
+ Version: 1.0.0
4
+ Summary: A self-learning neural network that grows new neurons
5
+ Home-page: https://github.com/learningbrain/learning-brain
6
+ Author: Learning Brain Team
7
+ Author-email: Learning Brain Team <team@learningbrain.dev>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/learningbrain/learning-brain
10
+ Project-URL: Issues, https://github.com/learningbrain/learning-brain/issues
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: numpy>=1.20.0
17
+ Requires-Dist: torch>=2.0.0
18
+ Requires-Dist: transformers>=4.30.0
19
+ Dynamic: author
20
+ Dynamic: home-page
21
+ Dynamic: requires-python
22
+
23
+ # 🧠 Learning Brain
24
+
25
+ > A self-learning neural network that grows new neurons! Like GGUF, but dynamic.
26
+
27
+ **Learning Brain** is a Python package that provides neurogenesis and continuous learning for AI models. It's like GGUF, but instead of being static, it grows new neurons when it learns!
28
+
29
+ This package includes the **SELSC Engine v2** - the same engine used in the HuggingFace model:
30
+ https://huggingface.co/Specialgfhdhdh/learning-qwen
31
+
32
+ ## ✨ Features
33
+
34
+ - 🧬 **Neurogenesis** - Automatically grows new neurons when confused
35
+ - 🧠 **STDP Learning** - Spike-Timing-Dependent Plasticity for realistic neural learning
36
+ - 💊 **Dopamine System** - Reward-modulated learning rate
37
+ - 💾 **Persistent State** - Save/load learned brain states to `.brain` files
38
+ - 🔄 **Model Agnostic** - Works with any base model (Qwen, Llama, etc.)
39
+ - 📦 **pip Installable** - Easy to install and use
40
+
41
+ ## 🧬 SELSC Engine v2
42
+
43
+ The package includes the **SELSC Engine v2** - the evolved brain from your HuggingFace model!
44
+
45
+ Features:
46
+ - Neurogenesis (grows new neurons when error > threshold)
47
+ - Dopamine-modulated STDP learning
48
+ - Surprise detection for adaptive learning
49
+ - Same architecture as https://huggingface.co/Specialgfhdhdh/learning-qwen
50
+
51
+ ## 🚀 Installation
52
+
53
+ ```bash
54
+ # From PyPI (when published)
55
+ pip install learning-brain
56
+
57
+ # From source
58
+ pip install .
59
+ ```
60
+
61
+ ## 📖 Usage
62
+
63
+ ### Python API
64
+
65
+ ```python
66
+ from learning_brain import Brain
67
+
68
+ # Create a new learning brain for a model
69
+ brain = Brain("qwen")
70
+
71
+ # Teach it something
72
+ result = brain.learn("The sky is blue and the grass is green")
73
+ print(result)
74
+ # {'tokens': 9, 'active_neurons': 100, 'neuron_grown': False, 'interactions': 1}
75
+
76
+ # Save the learned brain
77
+ brain.save()
78
+
79
+ # Check brain info
80
+ print(brain.info)
81
+ # {'model': 'qwen', 'path': 'qwen.brain', 'active_neurons': 100, ...}
82
+
83
+ # Later, load the brain
84
+ brain = Brain.load("qwen.brain")
85
+ ```
86
+
87
+ ### CLI
88
+
89
+ ```bash
90
+ # Run interactive session
91
+ python -m learning_brain run qwen
92
+
93
+ # Create a new brain
94
+ python -m learning_brain create mymodel
95
+
96
+ # Run demo
97
+ python -m learning_brain demo
98
+ ```
99
+
100
+ ### Interactive Session
101
+
102
+ ```bash
103
+ $ python -m learning_brain run qwen
104
+ ==================================================
105
+ 🧠 Learning Brain - qwen
106
+ ==================================================
107
+ Info: {'model': 'qwen', 'path': 'qwen.brain', 'active_neurons': 100, ...}
108
+
109
+ Commands:
110
+ save - Save and exit
111
+ info - Show brain info
112
+ quit - Exit without saving
113
+ --------------------------------------------------
114
+
115
+ > teach me about artificial intelligence
116
+ Learned: 4 tokens
117
+ Active neurons: 100
118
+
119
+ > machine learning is fascinating
120
+ Learned: 4 tokens
121
+ Active neurons: 100
122
+ 🧬 NEW NEURON GROWN!
123
+
124
+ > save
125
+ 💾 Brain saved: qwen.brain
126
+ Goodbye!
127
+ ```
128
+
129
+ ## 🧬 How It Works
130
+
131
+ ### Neurogenesis
132
+
133
+ The brain automatically grows new neurons when it encounters high error (confusion). This is similar to how real brains work - when a neuron is "confused" (high error), the brain activates a dormant neuron to help process the new information.
134
+
135
+ ### STDP Learning
136
+
137
+ Spike-Timing-Dependent Plasticity (STDP) is a learning rule where:
138
+ - If neuron A fires *before* neuron B → connection A→B strengthens (Long-Term Potentiation)
139
+ - If neuron A fires *after* neuron B → connection A→B weakens (Long-Term Depression)
140
+
141
+ This creates realistic, Hebbian-style learning.
142
+
143
+ ### File Format
144
+
145
+ The `.brain` file contains:
146
+ - Neural network weights
147
+ - Active neuron mask
148
+ - Vocabulary
149
+ - Learning history
150
+ - Cumulative error traces
151
+
152
+ This is like GGUF but supports runtime learning and neurogenesis!
153
+
154
+ ## ⚙️ Configuration
155
+
156
+ ```python
157
+ brain = Brain(
158
+ model_name="qwen",
159
+ vocab_size=10000, # Max vocabulary size
160
+ max_neurons=10000, # Max neurons
161
+ initial_neurons=100, # Starting neurons
162
+ lr_stdp=0.001, # Learning rate
163
+ tau_stdp=20.0, # STDP time constant
164
+ error_threshold=0.8, # Error threshold for neurogenesis
165
+ )
166
+ ```
167
+
168
+ ## 📁 Project Structure
169
+
170
+ ```
171
+ learning_brain_pkg/
172
+ ├── learning_brain/
173
+ │ ├── __init__.py # Main package (EvolvedChat, Brain, SELSC_Engine)
174
+ │ └── selsc_engine.py # SELSC Engine v2
175
+ ├── setup.py # pip setup script
176
+ ├── README.md # This file
177
+ └── LICENSE # MIT License
178
+ ```
179
+
180
+ ## 💾 .neuro File Format
181
+
182
+ The `.neuro` file contains both the Qwen model weights AND the SELSC brain:
183
+
184
+ ```python
185
+ from learning_brain import EvolvedChat
186
+
187
+ # Create and chat
188
+ chat = EvolvedChat(model="Qwen/Qwen2.5-0.5B-Instruct", brain_path="mybrain.brain")
189
+ chat.chat("Hello!")
190
+
191
+ # Save EVERYTHING to .neuro file
192
+ chat.save("my_ai.neuro") # Includes Qwen + SELSC brain!
193
+
194
+ # Later, load and chat immediately
195
+ chat = EvolvedChat.load_neuro("my_ai.neuro")
196
+ chat.chat("What did I teach you?")
197
+ ```
198
+
199
+ ## 🤝 Contributing
200
+
201
+ Contributions welcome! Please open an issue or PR.
202
+
203
+ ## 📝 License
204
+
205
+ MIT License - feel free to use!
206
+
207
+ ---
208
+
209
+ Made with 🧬 by the Learning Brain Team
@@ -0,0 +1,187 @@
1
+ # 🧠 Learning Brain
2
+
3
+ > A self-learning neural network that grows new neurons! Like GGUF, but dynamic.
4
+
5
+ **Learning Brain** is a Python package that provides neurogenesis and continuous learning for AI models. It's like GGUF, but instead of being static, it grows new neurons when it learns!
6
+
7
+ This package includes the **SELSC Engine v2** - the same engine used in the HuggingFace model:
8
+ https://huggingface.co/Specialgfhdhdh/learning-qwen
9
+
10
+ ## ✨ Features
11
+
12
+ - 🧬 **Neurogenesis** - Automatically grows new neurons when confused
13
+ - 🧠 **STDP Learning** - Spike-Timing-Dependent Plasticity for realistic neural learning
14
+ - 💊 **Dopamine System** - Reward-modulated learning rate
15
+ - 💾 **Persistent State** - Save/load learned brain states to `.brain` files
16
+ - 🔄 **Model Agnostic** - Works with any base model (Qwen, Llama, etc.)
17
+ - 📦 **pip Installable** - Easy to install and use
18
+
19
+ ## 🧬 SELSC Engine v2
20
+
21
+ The package includes the **SELSC Engine v2** - the evolved brain from your HuggingFace model!
22
+
23
+ Features:
24
+ - Neurogenesis (grows new neurons when error > threshold)
25
+ - Dopamine-modulated STDP learning
26
+ - Surprise detection for adaptive learning
27
+ - Same architecture as https://huggingface.co/Specialgfhdhdh/learning-qwen
28
+
29
+ ## 🚀 Installation
30
+
31
+ ```bash
32
+ # From PyPI (when published)
33
+ pip install learning-brain
34
+
35
+ # From source
36
+ pip install .
37
+ ```
38
+
39
+ ## 📖 Usage
40
+
41
+ ### Python API
42
+
43
+ ```python
44
+ from learning_brain import Brain
45
+
46
+ # Create a new learning brain for a model
47
+ brain = Brain("qwen")
48
+
49
+ # Teach it something
50
+ result = brain.learn("The sky is blue and the grass is green")
51
+ print(result)
52
+ # {'tokens': 9, 'active_neurons': 100, 'neuron_grown': False, 'interactions': 1}
53
+
54
+ # Save the learned brain
55
+ brain.save()
56
+
57
+ # Check brain info
58
+ print(brain.info)
59
+ # {'model': 'qwen', 'path': 'qwen.brain', 'active_neurons': 100, ...}
60
+
61
+ # Later, load the brain
62
+ brain = Brain.load("qwen.brain")
63
+ ```
64
+
65
+ ### CLI
66
+
67
+ ```bash
68
+ # Run interactive session
69
+ python -m learning_brain run qwen
70
+
71
+ # Create a new brain
72
+ python -m learning_brain create mymodel
73
+
74
+ # Run demo
75
+ python -m learning_brain demo
76
+ ```
77
+
78
+ ### Interactive Session
79
+
80
+ ```bash
81
+ $ python -m learning_brain run qwen
82
+ ==================================================
83
+ 🧠 Learning Brain - qwen
84
+ ==================================================
85
+ Info: {'model': 'qwen', 'path': 'qwen.brain', 'active_neurons': 100, ...}
86
+
87
+ Commands:
88
+ save - Save and exit
89
+ info - Show brain info
90
+ quit - Exit without saving
91
+ --------------------------------------------------
92
+
93
+ > teach me about artificial intelligence
94
+ Learned: 4 tokens
95
+ Active neurons: 100
96
+
97
+ > machine learning is fascinating
98
+ Learned: 4 tokens
99
+ Active neurons: 100
100
+ 🧬 NEW NEURON GROWN!
101
+
102
+ > save
103
+ 💾 Brain saved: qwen.brain
104
+ Goodbye!
105
+ ```
106
+
107
+ ## 🧬 How It Works
108
+
109
+ ### Neurogenesis
110
+
111
+ The brain automatically grows new neurons when it encounters high error (confusion). This is similar to how real brains work - when a neuron is "confused" (high error), the brain activates a dormant neuron to help process the new information.
112
+
113
+ ### STDP Learning
114
+
115
+ Spike-Timing-Dependent Plasticity (STDP) is a learning rule where:
116
+ - If neuron A fires *before* neuron B → connection A→B strengthens (Long-Term Potentiation)
117
+ - If neuron A fires *after* neuron B → connection A→B weakens (Long-Term Depression)
118
+
119
+ This creates realistic, Hebbian-style learning.
120
+
121
+ ### File Format
122
+
123
+ The `.brain` file contains:
124
+ - Neural network weights
125
+ - Active neuron mask
126
+ - Vocabulary
127
+ - Learning history
128
+ - Cumulative error traces
129
+
130
+ This is like GGUF but supports runtime learning and neurogenesis!
131
+
132
+ ## ⚙️ Configuration
133
+
134
+ ```python
135
+ brain = Brain(
136
+ model_name="qwen",
137
+ vocab_size=10000, # Max vocabulary size
138
+ max_neurons=10000, # Max neurons
139
+ initial_neurons=100, # Starting neurons
140
+ lr_stdp=0.001, # Learning rate
141
+ tau_stdp=20.0, # STDP time constant
142
+ error_threshold=0.8, # Error threshold for neurogenesis
143
+ )
144
+ ```
145
+
146
+ ## 📁 Project Structure
147
+
148
+ ```
149
+ learning_brain_pkg/
150
+ ├── learning_brain/
151
+ │ ├── __init__.py # Main package (EvolvedChat, Brain, SELSC_Engine)
152
+ │ └── selsc_engine.py # SELSC Engine v2
153
+ ├── setup.py # pip setup script
154
+ ├── README.md # This file
155
+ └── LICENSE # MIT License
156
+ ```
157
+
158
+ ## 💾 .neuro File Format
159
+
160
+ The `.neuro` file contains both the Qwen model weights AND the SELSC brain:
161
+
162
+ ```python
163
+ from learning_brain import EvolvedChat
164
+
165
+ # Create and chat
166
+ chat = EvolvedChat(model="Qwen/Qwen2.5-0.5B-Instruct", brain_path="mybrain.brain")
167
+ chat.chat("Hello!")
168
+
169
+ # Save EVERYTHING to .neuro file
170
+ chat.save("my_ai.neuro") # Includes Qwen + SELSC brain!
171
+
172
+ # Later, load and chat immediately
173
+ chat = EvolvedChat.load_neuro("my_ai.neuro")
174
+ chat.chat("What did I teach you?")
175
+ ```
176
+
177
+ ## 🤝 Contributing
178
+
179
+ Contributions welcome! Please open an issue or PR.
180
+
181
+ ## 📝 License
182
+
183
+ MIT License - feel free to use!
184
+
185
+ ---
186
+
187
+ Made with 🧬 by the Learning Brain Team