@sparkleideas/ruv-swarm 1.0.18-patch.1
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.
- package/README.md +1565 -0
- package/bin/ruv-swarm-clean.js +1872 -0
- package/bin/ruv-swarm-memory.js +119 -0
- package/bin/ruv-swarm-secure-heartbeat.js +1549 -0
- package/bin/ruv-swarm-secure.js +1689 -0
- package/package.json +221 -0
- package/src/agent.ts +342 -0
- package/src/benchmark.js +267 -0
- package/src/claude-flow-enhanced.js +839 -0
- package/src/claude-integration/advanced-commands.js +561 -0
- package/src/claude-integration/core.js +112 -0
- package/src/claude-integration/docs.js +1548 -0
- package/src/claude-integration/env-template.js +39 -0
- package/src/claude-integration/index.js +209 -0
- package/src/claude-integration/remote.js +408 -0
- package/src/cli-diagnostics.js +364 -0
- package/src/cognitive-pattern-evolution.js +1317 -0
- package/src/daa-cognition.js +977 -0
- package/src/daa-service.d.ts +298 -0
- package/src/daa-service.js +1116 -0
- package/src/diagnostics.js +533 -0
- package/src/errors.js +528 -0
- package/src/github-coordinator/README.md +193 -0
- package/src/github-coordinator/claude-hooks.js +162 -0
- package/src/github-coordinator/gh-cli-coordinator.js +260 -0
- package/src/hooks/cli.js +82 -0
- package/src/hooks/index.js +1900 -0
- package/src/index-enhanced.d.ts +371 -0
- package/src/index-enhanced.js +734 -0
- package/src/index.d.ts +287 -0
- package/src/index.js +405 -0
- package/src/index.ts +457 -0
- package/src/logger.js +182 -0
- package/src/logging-config.js +179 -0
- package/src/mcp-daa-tools.js +735 -0
- package/src/mcp-tools-benchmarks.js +328 -0
- package/src/mcp-tools-enhanced.js +2863 -0
- package/src/memory-config.js +42 -0
- package/src/meta-learning-framework.js +1359 -0
- package/src/neural-agent.js +830 -0
- package/src/neural-coordination-protocol.js +1363 -0
- package/src/neural-models/README.md +118 -0
- package/src/neural-models/autoencoder.js +543 -0
- package/src/neural-models/base.js +269 -0
- package/src/neural-models/cnn.js +497 -0
- package/src/neural-models/gnn.js +447 -0
- package/src/neural-models/gru.js +536 -0
- package/src/neural-models/index.js +273 -0
- package/src/neural-models/lstm.js +551 -0
- package/src/neural-models/neural-presets-complete.js +1306 -0
- package/src/neural-models/presets/graph.js +392 -0
- package/src/neural-models/presets/index.js +279 -0
- package/src/neural-models/presets/nlp.js +328 -0
- package/src/neural-models/presets/timeseries.js +368 -0
- package/src/neural-models/presets/vision.js +387 -0
- package/src/neural-models/resnet.js +534 -0
- package/src/neural-models/transformer.js +515 -0
- package/src/neural-models/vae.js +489 -0
- package/src/neural-network-manager.js +1938 -0
- package/src/neural-network.ts +296 -0
- package/src/neural.js +574 -0
- package/src/performance-benchmarks.js +898 -0
- package/src/performance.js +458 -0
- package/src/persistence-pooled.js +695 -0
- package/src/persistence.js +480 -0
- package/src/schemas.js +864 -0
- package/src/security.js +218 -0
- package/src/singleton-container.js +183 -0
- package/src/sqlite-pool.js +587 -0
- package/src/sqlite-worker.js +141 -0
- package/src/types.ts +164 -0
- package/src/utils.ts +286 -0
- package/src/wasm-loader.js +601 -0
- package/src/wasm-loader2.js +404 -0
- package/src/wasm-memory-optimizer.js +783 -0
- package/src/wasm-types.d.ts +63 -0
- package/wasm/README.md +347 -0
- package/wasm/neuro-divergent.wasm +0 -0
- package/wasm/package.json +18 -0
- package/wasm/ruv-fann.wasm +0 -0
- package/wasm/ruv_swarm_simd.wasm +0 -0
- package/wasm/ruv_swarm_wasm.d.ts +391 -0
- package/wasm/ruv_swarm_wasm.js +2164 -0
- package/wasm/ruv_swarm_wasm_bg.wasm +0 -0
- package/wasm/ruv_swarm_wasm_bg.wasm.d.ts +123 -0
- package/wasm/wasm-bindings-loader.mjs +435 -0
- package/wasm/wasm-updates.md +684 -0
|
@@ -0,0 +1,1306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complete Neural Model Presets Integration
|
|
3
|
+
* 27+ Production-Ready Neural Network Architectures with Cognitive Patterns
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CognitivePatternEvolution } from '../cognitive-pattern-evolution.js';
|
|
7
|
+
import { MetaLearningFramework } from '../meta-learning-framework.js';
|
|
8
|
+
|
|
9
|
+
// Comprehensive neural model presets with cognitive patterns
|
|
10
|
+
export const COMPLETE_NEURAL_PRESETS = {
|
|
11
|
+
// 1. Transformer Models
|
|
12
|
+
transformer: {
|
|
13
|
+
bert_base: {
|
|
14
|
+
name: 'BERT Base',
|
|
15
|
+
description: 'Bidirectional encoder for language understanding',
|
|
16
|
+
model: 'transformer',
|
|
17
|
+
config: {
|
|
18
|
+
dimensions: 768,
|
|
19
|
+
heads: 12,
|
|
20
|
+
layers: 12,
|
|
21
|
+
ffDimensions: 3072,
|
|
22
|
+
dropoutRate: 0.1,
|
|
23
|
+
maxSequenceLength: 512,
|
|
24
|
+
vocabSize: 30522,
|
|
25
|
+
},
|
|
26
|
+
cognitivePatterns: ['convergent', 'systems', 'abstract'],
|
|
27
|
+
performance: {
|
|
28
|
+
expectedAccuracy: '92-95%',
|
|
29
|
+
inferenceTime: '15ms',
|
|
30
|
+
memoryUsage: '420MB',
|
|
31
|
+
trainingTime: '4 days on 16 TPUs',
|
|
32
|
+
},
|
|
33
|
+
useCase: 'Text classification, sentiment analysis, named entity recognition',
|
|
34
|
+
},
|
|
35
|
+
gpt_small: {
|
|
36
|
+
name: 'GPT Small',
|
|
37
|
+
description: 'Generative pre-trained transformer for text generation',
|
|
38
|
+
model: 'transformer',
|
|
39
|
+
config: {
|
|
40
|
+
dimensions: 768,
|
|
41
|
+
heads: 12,
|
|
42
|
+
layers: 12,
|
|
43
|
+
ffDimensions: 3072,
|
|
44
|
+
dropoutRate: 0.1,
|
|
45
|
+
maxSequenceLength: 1024,
|
|
46
|
+
vocabSize: 50257,
|
|
47
|
+
},
|
|
48
|
+
cognitivePatterns: ['divergent', 'lateral', 'abstract'],
|
|
49
|
+
performance: {
|
|
50
|
+
expectedAccuracy: '88-92%',
|
|
51
|
+
inferenceTime: '20ms',
|
|
52
|
+
memoryUsage: '510MB',
|
|
53
|
+
trainingTime: '2 weeks on 8 V100s',
|
|
54
|
+
},
|
|
55
|
+
useCase: 'Text generation, creative writing, code completion',
|
|
56
|
+
},
|
|
57
|
+
t5_base: {
|
|
58
|
+
name: 'T5 Base',
|
|
59
|
+
description: 'Text-to-text transformer for unified NLP tasks',
|
|
60
|
+
model: 'transformer',
|
|
61
|
+
config: {
|
|
62
|
+
dimensions: 768,
|
|
63
|
+
heads: 12,
|
|
64
|
+
encoderLayers: 12,
|
|
65
|
+
decoderLayers: 12,
|
|
66
|
+
ffDimensions: 3072,
|
|
67
|
+
dropoutRate: 0.1,
|
|
68
|
+
},
|
|
69
|
+
cognitivePatterns: ['systems', 'convergent', 'critical'],
|
|
70
|
+
performance: {
|
|
71
|
+
expectedAccuracy: '90-94%',
|
|
72
|
+
inferenceTime: '25ms',
|
|
73
|
+
memoryUsage: '850MB',
|
|
74
|
+
trainingTime: '3 weeks on 32 TPUs',
|
|
75
|
+
},
|
|
76
|
+
useCase: 'Translation, summarization, question answering',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// 2. CNN Models
|
|
81
|
+
cnn: {
|
|
82
|
+
efficientnet_b0: {
|
|
83
|
+
name: 'EfficientNet-B0',
|
|
84
|
+
description: 'Efficient convolutional network for image classification',
|
|
85
|
+
model: 'cnn',
|
|
86
|
+
config: {
|
|
87
|
+
inputShape: [224, 224, 3],
|
|
88
|
+
convLayers: [
|
|
89
|
+
{ filters: 32, kernelSize: 3, stride: 2, padding: 'same' },
|
|
90
|
+
{ filters: 16, kernelSize: 3, stride: 1, padding: 'same' },
|
|
91
|
+
{ filters: 24, kernelSize: 3, stride: 2, padding: 'same' },
|
|
92
|
+
{ filters: 40, kernelSize: 3, stride: 2, padding: 'same' },
|
|
93
|
+
{ filters: 80, kernelSize: 3, stride: 1, padding: 'same' },
|
|
94
|
+
{ filters: 112, kernelSize: 3, stride: 1, padding: 'same' },
|
|
95
|
+
{ filters: 192, kernelSize: 3, stride: 2, padding: 'same' },
|
|
96
|
+
{ filters: 320, kernelSize: 3, stride: 1, padding: 'same' },
|
|
97
|
+
],
|
|
98
|
+
outputSize: 1000,
|
|
99
|
+
},
|
|
100
|
+
cognitivePatterns: ['critical', 'convergent', 'abstract'],
|
|
101
|
+
performance: {
|
|
102
|
+
expectedAccuracy: '77.1% top-1',
|
|
103
|
+
inferenceTime: '4.9ms',
|
|
104
|
+
memoryUsage: '5.3MB',
|
|
105
|
+
trainingTime: '23 hours on 8 TPUs',
|
|
106
|
+
},
|
|
107
|
+
useCase: 'Image classification, feature extraction',
|
|
108
|
+
},
|
|
109
|
+
yolov5_small: {
|
|
110
|
+
name: 'YOLOv5 Small',
|
|
111
|
+
description: 'Real-time object detection network',
|
|
112
|
+
model: 'cnn',
|
|
113
|
+
config: {
|
|
114
|
+
inputShape: [640, 640, 3],
|
|
115
|
+
backbone: 'CSPDarknet',
|
|
116
|
+
neck: 'PANet',
|
|
117
|
+
head: 'YOLOv5Head',
|
|
118
|
+
anchors: [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]],
|
|
119
|
+
},
|
|
120
|
+
cognitivePatterns: ['systems', 'critical', 'convergent'],
|
|
121
|
+
performance: {
|
|
122
|
+
expectedAccuracy: '37.4% mAP',
|
|
123
|
+
inferenceTime: '6.4ms',
|
|
124
|
+
memoryUsage: '16MB',
|
|
125
|
+
trainingTime: '3 days on 1 V100',
|
|
126
|
+
},
|
|
127
|
+
useCase: 'Real-time object detection, autonomous driving',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
// 3. RNN Models (LSTM/GRU)
|
|
132
|
+
lstm: {
|
|
133
|
+
bilstm_sentiment: {
|
|
134
|
+
name: 'BiLSTM Sentiment Analyzer',
|
|
135
|
+
description: 'Bidirectional LSTM for sentiment analysis',
|
|
136
|
+
model: 'lstm',
|
|
137
|
+
config: {
|
|
138
|
+
inputSize: 300,
|
|
139
|
+
hiddenSize: 256,
|
|
140
|
+
numLayers: 2,
|
|
141
|
+
outputSize: 3,
|
|
142
|
+
bidirectional: true,
|
|
143
|
+
dropoutRate: 0.3,
|
|
144
|
+
},
|
|
145
|
+
cognitivePatterns: ['convergent', 'systems', 'critical'],
|
|
146
|
+
performance: {
|
|
147
|
+
expectedAccuracy: '89-91%',
|
|
148
|
+
inferenceTime: '8ms',
|
|
149
|
+
memoryUsage: '45MB',
|
|
150
|
+
trainingTime: '4 hours on 1 GPU',
|
|
151
|
+
},
|
|
152
|
+
useCase: 'Sentiment analysis, emotion detection',
|
|
153
|
+
},
|
|
154
|
+
lstm_timeseries: {
|
|
155
|
+
name: 'LSTM Time Series Predictor',
|
|
156
|
+
description: 'LSTM for multi-step time series forecasting',
|
|
157
|
+
model: 'lstm',
|
|
158
|
+
config: {
|
|
159
|
+
inputSize: 10,
|
|
160
|
+
hiddenSize: 128,
|
|
161
|
+
numLayers: 3,
|
|
162
|
+
outputSize: 1,
|
|
163
|
+
sequenceLength: 100,
|
|
164
|
+
returnSequence: false,
|
|
165
|
+
},
|
|
166
|
+
cognitivePatterns: ['systems', 'convergent', 'abstract'],
|
|
167
|
+
performance: {
|
|
168
|
+
expectedAccuracy: '92% R²',
|
|
169
|
+
inferenceTime: '5ms',
|
|
170
|
+
memoryUsage: '25MB',
|
|
171
|
+
trainingTime: '2 hours on 1 GPU',
|
|
172
|
+
},
|
|
173
|
+
useCase: 'Stock prediction, weather forecasting, demand prediction',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
// 4. GRU Models
|
|
178
|
+
gru: {
|
|
179
|
+
gru_translator: {
|
|
180
|
+
name: 'GRU Neural Translator',
|
|
181
|
+
description: 'GRU-based sequence-to-sequence translator',
|
|
182
|
+
model: 'gru',
|
|
183
|
+
config: {
|
|
184
|
+
inputSize: 512,
|
|
185
|
+
hiddenSize: 512,
|
|
186
|
+
numLayers: 4,
|
|
187
|
+
outputSize: 10000,
|
|
188
|
+
bidirectional: true,
|
|
189
|
+
attention: true,
|
|
190
|
+
},
|
|
191
|
+
cognitivePatterns: ['systems', 'abstract', 'convergent'],
|
|
192
|
+
performance: {
|
|
193
|
+
expectedAccuracy: '32.4 BLEU',
|
|
194
|
+
inferenceTime: '15ms',
|
|
195
|
+
memoryUsage: '120MB',
|
|
196
|
+
trainingTime: '5 days on 4 GPUs',
|
|
197
|
+
},
|
|
198
|
+
useCase: 'Machine translation, text summarization',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
// 5. Autoencoder Models
|
|
203
|
+
autoencoder: {
|
|
204
|
+
vae_mnist: {
|
|
205
|
+
name: 'VAE for MNIST',
|
|
206
|
+
description: 'Variational autoencoder for digit generation',
|
|
207
|
+
model: 'vae',
|
|
208
|
+
config: {
|
|
209
|
+
inputSize: 784,
|
|
210
|
+
encoderLayers: [512, 256],
|
|
211
|
+
latentDimensions: 20,
|
|
212
|
+
decoderLayers: [256, 512],
|
|
213
|
+
betaKL: 1.0,
|
|
214
|
+
},
|
|
215
|
+
cognitivePatterns: ['divergent', 'abstract', 'lateral'],
|
|
216
|
+
performance: {
|
|
217
|
+
expectedAccuracy: '98% reconstruction',
|
|
218
|
+
inferenceTime: '2ms',
|
|
219
|
+
memoryUsage: '8MB',
|
|
220
|
+
trainingTime: '30 minutes on 1 GPU',
|
|
221
|
+
},
|
|
222
|
+
useCase: 'Digit generation, anomaly detection',
|
|
223
|
+
},
|
|
224
|
+
dae_denoising: {
|
|
225
|
+
name: 'Denoising Autoencoder',
|
|
226
|
+
description: 'Autoencoder for image denoising',
|
|
227
|
+
model: 'autoencoder',
|
|
228
|
+
config: {
|
|
229
|
+
inputSize: 4096,
|
|
230
|
+
encoderLayers: [2048, 1024, 512],
|
|
231
|
+
bottleneckSize: 256,
|
|
232
|
+
denoisingNoise: 0.3,
|
|
233
|
+
activation: 'relu',
|
|
234
|
+
},
|
|
235
|
+
cognitivePatterns: ['convergent', 'critical', 'systems'],
|
|
236
|
+
performance: {
|
|
237
|
+
expectedAccuracy: '28.5 PSNR',
|
|
238
|
+
inferenceTime: '4ms',
|
|
239
|
+
memoryUsage: '32MB',
|
|
240
|
+
trainingTime: '2 hours on 1 GPU',
|
|
241
|
+
},
|
|
242
|
+
useCase: 'Image denoising, feature extraction',
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
// 6. GNN Models
|
|
247
|
+
gnn: {
|
|
248
|
+
gcn_citation: {
|
|
249
|
+
name: 'GCN Citation Network',
|
|
250
|
+
description: 'Graph convolutional network for citation networks',
|
|
251
|
+
model: 'gnn',
|
|
252
|
+
config: {
|
|
253
|
+
nodeDimensions: 1433,
|
|
254
|
+
hiddenDimensions: 16,
|
|
255
|
+
outputDimensions: 7,
|
|
256
|
+
numLayers: 2,
|
|
257
|
+
dropoutRate: 0.5,
|
|
258
|
+
},
|
|
259
|
+
cognitivePatterns: ['systems', 'abstract', 'lateral'],
|
|
260
|
+
performance: {
|
|
261
|
+
expectedAccuracy: '81.5%',
|
|
262
|
+
inferenceTime: '10ms',
|
|
263
|
+
memoryUsage: '50MB',
|
|
264
|
+
trainingTime: '10 minutes on 1 GPU',
|
|
265
|
+
},
|
|
266
|
+
useCase: 'Citation network classification, social network analysis',
|
|
267
|
+
},
|
|
268
|
+
gat_molecular: {
|
|
269
|
+
name: 'GAT Molecular Property',
|
|
270
|
+
description: 'Graph attention network for molecular property prediction',
|
|
271
|
+
model: 'gat',
|
|
272
|
+
config: {
|
|
273
|
+
nodeDimensions: 64,
|
|
274
|
+
attentionHeads: 8,
|
|
275
|
+
hiddenUnits: 256,
|
|
276
|
+
numLayers: 3,
|
|
277
|
+
outputDimensions: 1,
|
|
278
|
+
},
|
|
279
|
+
cognitivePatterns: ['critical', 'systems', 'convergent'],
|
|
280
|
+
performance: {
|
|
281
|
+
expectedAccuracy: '89% R²',
|
|
282
|
+
inferenceTime: '12ms',
|
|
283
|
+
memoryUsage: '75MB',
|
|
284
|
+
trainingTime: '8 hours on 2 GPUs',
|
|
285
|
+
},
|
|
286
|
+
useCase: 'Drug discovery, molecular property prediction',
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
// 7. ResNet Models
|
|
291
|
+
resnet: {
|
|
292
|
+
resnet50_imagenet: {
|
|
293
|
+
name: 'ResNet-50 ImageNet',
|
|
294
|
+
description: 'Deep residual network for image classification',
|
|
295
|
+
model: 'resnet',
|
|
296
|
+
config: {
|
|
297
|
+
numBlocks: 16,
|
|
298
|
+
blockDepth: 3,
|
|
299
|
+
hiddenDimensions: 2048,
|
|
300
|
+
initialChannels: 64,
|
|
301
|
+
inputShape: [224, 224, 3],
|
|
302
|
+
outputDimensions: 1000,
|
|
303
|
+
},
|
|
304
|
+
cognitivePatterns: ['convergent', 'critical', 'systems'],
|
|
305
|
+
performance: {
|
|
306
|
+
expectedAccuracy: '76.1% top-1',
|
|
307
|
+
inferenceTime: '25ms',
|
|
308
|
+
memoryUsage: '98MB',
|
|
309
|
+
trainingTime: '8 days on 8 V100s',
|
|
310
|
+
},
|
|
311
|
+
useCase: 'Image classification, transfer learning backbone',
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
// 8. Attention Models
|
|
316
|
+
attention: {
|
|
317
|
+
multihead_attention: {
|
|
318
|
+
name: 'Multi-Head Attention',
|
|
319
|
+
description: 'Stand-alone multi-head attention mechanism',
|
|
320
|
+
model: 'attention',
|
|
321
|
+
config: {
|
|
322
|
+
heads: 8,
|
|
323
|
+
dimensions: 512,
|
|
324
|
+
dropoutRate: 0.1,
|
|
325
|
+
useCausalMask: false,
|
|
326
|
+
},
|
|
327
|
+
cognitivePatterns: ['systems', 'abstract', 'convergent'],
|
|
328
|
+
performance: {
|
|
329
|
+
expectedAccuracy: 'task-dependent',
|
|
330
|
+
inferenceTime: '3ms',
|
|
331
|
+
memoryUsage: '15MB',
|
|
332
|
+
trainingTime: 'varies',
|
|
333
|
+
},
|
|
334
|
+
useCase: 'Attention mechanism component, sequence modeling',
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
// 9. Diffusion Models
|
|
339
|
+
diffusion: {
|
|
340
|
+
ddpm_mnist: {
|
|
341
|
+
name: 'DDPM MNIST Generator',
|
|
342
|
+
description: 'Denoising diffusion probabilistic model',
|
|
343
|
+
model: 'diffusion',
|
|
344
|
+
config: {
|
|
345
|
+
timesteps: 1000,
|
|
346
|
+
betaSchedule: 'cosine',
|
|
347
|
+
imageSize: 28,
|
|
348
|
+
channels: 1,
|
|
349
|
+
modelChannels: 128,
|
|
350
|
+
},
|
|
351
|
+
cognitivePatterns: ['divergent', 'lateral', 'abstract'],
|
|
352
|
+
performance: {
|
|
353
|
+
expectedAccuracy: '3.17 FID',
|
|
354
|
+
inferenceTime: '1000ms',
|
|
355
|
+
memoryUsage: '200MB',
|
|
356
|
+
trainingTime: '2 days on 4 GPUs',
|
|
357
|
+
},
|
|
358
|
+
useCase: 'Image generation, data augmentation',
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
// 10. Neural ODE Models
|
|
363
|
+
neural_ode: {
|
|
364
|
+
node_dynamics: {
|
|
365
|
+
name: 'Neural ODE Dynamics',
|
|
366
|
+
description: 'Continuous-time dynamics modeling',
|
|
367
|
+
model: 'neural_ode',
|
|
368
|
+
config: {
|
|
369
|
+
solverMethod: 'dopri5',
|
|
370
|
+
tolerance: 1e-6,
|
|
371
|
+
hiddenDimensions: 64,
|
|
372
|
+
timeDimension: 1,
|
|
373
|
+
},
|
|
374
|
+
cognitivePatterns: ['systems', 'abstract', 'convergent'],
|
|
375
|
+
performance: {
|
|
376
|
+
expectedAccuracy: '95% trajectory',
|
|
377
|
+
inferenceTime: '50ms',
|
|
378
|
+
memoryUsage: '30MB',
|
|
379
|
+
trainingTime: '6 hours on 1 GPU',
|
|
380
|
+
},
|
|
381
|
+
useCase: 'Physical system modeling, continuous processes',
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
// 11. Capsule Networks
|
|
386
|
+
capsnet: {
|
|
387
|
+
capsnet_mnist: {
|
|
388
|
+
name: 'CapsNet MNIST',
|
|
389
|
+
description: 'Capsule network with dynamic routing',
|
|
390
|
+
model: 'capsnet',
|
|
391
|
+
config: {
|
|
392
|
+
primaryCaps: 32,
|
|
393
|
+
digitCaps: 10,
|
|
394
|
+
routingIterations: 3,
|
|
395
|
+
capsuleDimensions: 16,
|
|
396
|
+
},
|
|
397
|
+
cognitivePatterns: ['lateral', 'systems', 'abstract'],
|
|
398
|
+
performance: {
|
|
399
|
+
expectedAccuracy: '99.23%',
|
|
400
|
+
inferenceTime: '15ms',
|
|
401
|
+
memoryUsage: '35MB',
|
|
402
|
+
trainingTime: '10 hours on 1 GPU',
|
|
403
|
+
},
|
|
404
|
+
useCase: 'Viewpoint-invariant recognition, part-whole relationships',
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
// 12. Spiking Neural Networks
|
|
409
|
+
snn: {
|
|
410
|
+
lif_classifier: {
|
|
411
|
+
name: 'LIF Spiking Classifier',
|
|
412
|
+
description: 'Leaky integrate-and-fire spiking neural network',
|
|
413
|
+
model: 'snn',
|
|
414
|
+
config: {
|
|
415
|
+
neuronModel: 'lif',
|
|
416
|
+
threshold: 1.0,
|
|
417
|
+
decay: 0.95,
|
|
418
|
+
timeWindow: 100,
|
|
419
|
+
codingScheme: 'rate',
|
|
420
|
+
},
|
|
421
|
+
cognitivePatterns: ['systems', 'critical', 'convergent'],
|
|
422
|
+
performance: {
|
|
423
|
+
expectedAccuracy: '92%',
|
|
424
|
+
inferenceTime: '100ms',
|
|
425
|
+
memoryUsage: '10MB',
|
|
426
|
+
trainingTime: '4 hours on 1 GPU',
|
|
427
|
+
},
|
|
428
|
+
useCase: 'Energy-efficient inference, neuromorphic computing',
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
// 13. Neural Turing Machines
|
|
433
|
+
ntm: {
|
|
434
|
+
ntm_copy: {
|
|
435
|
+
name: 'NTM Copy Task',
|
|
436
|
+
description: 'Neural Turing machine for sequence copying',
|
|
437
|
+
model: 'ntm',
|
|
438
|
+
config: {
|
|
439
|
+
memorySize: [128, 20],
|
|
440
|
+
controllerSize: 100,
|
|
441
|
+
numHeads: 1,
|
|
442
|
+
shiftRange: 3,
|
|
443
|
+
},
|
|
444
|
+
cognitivePatterns: ['systems', 'abstract', 'convergent'],
|
|
445
|
+
performance: {
|
|
446
|
+
expectedAccuracy: '99.9%',
|
|
447
|
+
inferenceTime: '20ms',
|
|
448
|
+
memoryUsage: '45MB',
|
|
449
|
+
trainingTime: '12 hours on 1 GPU',
|
|
450
|
+
},
|
|
451
|
+
useCase: 'Algorithm learning, external memory tasks',
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
// 14. Memory Networks
|
|
456
|
+
memnn: {
|
|
457
|
+
memnn_qa: {
|
|
458
|
+
name: 'MemNN Question Answering',
|
|
459
|
+
description: 'End-to-end memory network for QA',
|
|
460
|
+
model: 'memnn',
|
|
461
|
+
config: {
|
|
462
|
+
memorySlots: 100,
|
|
463
|
+
hops: 3,
|
|
464
|
+
embeddingSize: 50,
|
|
465
|
+
temporalEncoding: true,
|
|
466
|
+
},
|
|
467
|
+
cognitivePatterns: ['convergent', 'systems', 'critical'],
|
|
468
|
+
performance: {
|
|
469
|
+
expectedAccuracy: '95% on bAbI',
|
|
470
|
+
inferenceTime: '8ms',
|
|
471
|
+
memoryUsage: '25MB',
|
|
472
|
+
trainingTime: '2 hours on 1 GPU',
|
|
473
|
+
},
|
|
474
|
+
useCase: 'Question answering, reasoning tasks',
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
|
|
478
|
+
// 15. Neural Cellular Automata
|
|
479
|
+
nca: {
|
|
480
|
+
nca_growth: {
|
|
481
|
+
name: 'NCA Pattern Growth',
|
|
482
|
+
description: 'Neural cellular automata for pattern formation',
|
|
483
|
+
model: 'nca',
|
|
484
|
+
config: {
|
|
485
|
+
channels: 16,
|
|
486
|
+
updateRule: 'sobel',
|
|
487
|
+
cellStates: 16,
|
|
488
|
+
gridSize: [64, 64],
|
|
489
|
+
},
|
|
490
|
+
cognitivePatterns: ['divergent', 'lateral', 'systems'],
|
|
491
|
+
performance: {
|
|
492
|
+
expectedAccuracy: 'qualitative',
|
|
493
|
+
inferenceTime: '5ms/step',
|
|
494
|
+
memoryUsage: '15MB',
|
|
495
|
+
trainingTime: '6 hours on 1 GPU',
|
|
496
|
+
},
|
|
497
|
+
useCase: 'Pattern generation, self-organization studies',
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
|
|
501
|
+
// 16. HyperNetworks
|
|
502
|
+
hypernet: {
|
|
503
|
+
hypernet_adaptive: {
|
|
504
|
+
name: 'Adaptive HyperNetwork',
|
|
505
|
+
description: 'Network that generates weights for target network',
|
|
506
|
+
model: 'hypernet',
|
|
507
|
+
config: {
|
|
508
|
+
hyperDim: 512,
|
|
509
|
+
targetLayers: ['conv1', 'conv2', 'fc1'],
|
|
510
|
+
embeddingSize: 128,
|
|
511
|
+
},
|
|
512
|
+
cognitivePatterns: ['abstract', 'lateral', 'systems'],
|
|
513
|
+
performance: {
|
|
514
|
+
expectedAccuracy: '94%',
|
|
515
|
+
inferenceTime: '30ms',
|
|
516
|
+
memoryUsage: '80MB',
|
|
517
|
+
trainingTime: '15 hours on 2 GPUs',
|
|
518
|
+
},
|
|
519
|
+
useCase: 'Adaptive networks, few-shot learning',
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
|
|
523
|
+
// 17. Meta-Learning Models
|
|
524
|
+
maml: {
|
|
525
|
+
maml_fewshot: {
|
|
526
|
+
name: 'MAML Few-Shot',
|
|
527
|
+
description: 'Model-agnostic meta-learning',
|
|
528
|
+
model: 'maml',
|
|
529
|
+
config: {
|
|
530
|
+
innerLR: 0.01,
|
|
531
|
+
outerLR: 0.001,
|
|
532
|
+
innerSteps: 5,
|
|
533
|
+
numWays: 5,
|
|
534
|
+
numShots: 1,
|
|
535
|
+
},
|
|
536
|
+
cognitivePatterns: ['abstract', 'divergent', 'critical'],
|
|
537
|
+
performance: {
|
|
538
|
+
expectedAccuracy: '95% 5-way 1-shot',
|
|
539
|
+
inferenceTime: '50ms',
|
|
540
|
+
memoryUsage: '40MB',
|
|
541
|
+
trainingTime: '24 hours on 4 GPUs',
|
|
542
|
+
},
|
|
543
|
+
useCase: 'Few-shot learning, rapid adaptation',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
|
|
547
|
+
// 18. Neural Architecture Search
|
|
548
|
+
nas: {
|
|
549
|
+
darts_cifar: {
|
|
550
|
+
name: 'DARTS CIFAR-10',
|
|
551
|
+
description: 'Differentiable architecture search',
|
|
552
|
+
model: 'nas',
|
|
553
|
+
config: {
|
|
554
|
+
searchSpace: 'darts_space',
|
|
555
|
+
epochs: 50,
|
|
556
|
+
channels: 36,
|
|
557
|
+
layers: 20,
|
|
558
|
+
},
|
|
559
|
+
cognitivePatterns: ['divergent', 'critical', 'systems'],
|
|
560
|
+
performance: {
|
|
561
|
+
expectedAccuracy: '97.24%',
|
|
562
|
+
inferenceTime: '15ms',
|
|
563
|
+
memoryUsage: '60MB',
|
|
564
|
+
trainingTime: '4 days on 1 GPU',
|
|
565
|
+
},
|
|
566
|
+
useCase: 'AutoML, architecture optimization',
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
|
|
570
|
+
// 19. Mixture of Experts
|
|
571
|
+
moe: {
|
|
572
|
+
moe_nlp: {
|
|
573
|
+
name: 'MoE Language Model',
|
|
574
|
+
description: 'Sparse mixture of experts for NLP',
|
|
575
|
+
model: 'moe',
|
|
576
|
+
config: {
|
|
577
|
+
numExperts: 8,
|
|
578
|
+
expertCapacity: 2,
|
|
579
|
+
hiddenSize: 512,
|
|
580
|
+
routerType: 'top2',
|
|
581
|
+
},
|
|
582
|
+
cognitivePatterns: ['systems', 'divergent', 'abstract'],
|
|
583
|
+
performance: {
|
|
584
|
+
expectedAccuracy: '91% perplexity',
|
|
585
|
+
inferenceTime: '12ms',
|
|
586
|
+
memoryUsage: '400MB',
|
|
587
|
+
trainingTime: '1 week on 8 GPUs',
|
|
588
|
+
},
|
|
589
|
+
useCase: 'Large-scale language modeling, multi-task learning',
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
// 20. Neural Radiance Fields
|
|
594
|
+
nerf: {
|
|
595
|
+
nerf_3d: {
|
|
596
|
+
name: 'NeRF 3D Reconstruction',
|
|
597
|
+
description: 'Neural radiance field for 3D scene reconstruction',
|
|
598
|
+
model: 'nerf',
|
|
599
|
+
config: {
|
|
600
|
+
positionEncoding: 10,
|
|
601
|
+
directionEncoding: 4,
|
|
602
|
+
hiddenLayers: 8,
|
|
603
|
+
hiddenSize: 256,
|
|
604
|
+
},
|
|
605
|
+
cognitivePatterns: ['abstract', 'systems', 'lateral'],
|
|
606
|
+
performance: {
|
|
607
|
+
expectedAccuracy: '30 PSNR',
|
|
608
|
+
inferenceTime: '100ms/ray',
|
|
609
|
+
memoryUsage: '200MB',
|
|
610
|
+
trainingTime: '2 days on 1 GPU',
|
|
611
|
+
},
|
|
612
|
+
useCase: '3D reconstruction, novel view synthesis',
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
|
|
616
|
+
// 21. WaveNet
|
|
617
|
+
wavenet: {
|
|
618
|
+
wavenet_tts: {
|
|
619
|
+
name: 'WaveNet TTS',
|
|
620
|
+
description: 'WaveNet for text-to-speech synthesis',
|
|
621
|
+
model: 'wavenet',
|
|
622
|
+
config: {
|
|
623
|
+
dilationChannels: 32,
|
|
624
|
+
residualChannels: 32,
|
|
625
|
+
skipChannels: 512,
|
|
626
|
+
dilationDepth: 10,
|
|
627
|
+
dilationRepeat: 3,
|
|
628
|
+
},
|
|
629
|
+
cognitivePatterns: ['convergent', 'systems', 'critical'],
|
|
630
|
+
performance: {
|
|
631
|
+
expectedAccuracy: '4.5 MOS',
|
|
632
|
+
inferenceTime: '500ms/second',
|
|
633
|
+
memoryUsage: '150MB',
|
|
634
|
+
trainingTime: '1 week on 8 GPUs',
|
|
635
|
+
},
|
|
636
|
+
useCase: 'Speech synthesis, audio generation',
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
|
|
640
|
+
// 22. PointNet
|
|
641
|
+
pointnet: {
|
|
642
|
+
pointnet_seg: {
|
|
643
|
+
name: 'PointNet++ Segmentation',
|
|
644
|
+
description: 'Point cloud segmentation network',
|
|
645
|
+
model: 'pointnet',
|
|
646
|
+
config: {
|
|
647
|
+
pointFeatures: 3,
|
|
648
|
+
globalFeatures: 1024,
|
|
649
|
+
numClasses: 50,
|
|
650
|
+
samplingGroups: 3,
|
|
651
|
+
},
|
|
652
|
+
cognitivePatterns: ['systems', 'critical', 'abstract'],
|
|
653
|
+
performance: {
|
|
654
|
+
expectedAccuracy: '85.1% mIoU',
|
|
655
|
+
inferenceTime: '40ms',
|
|
656
|
+
memoryUsage: '90MB',
|
|
657
|
+
trainingTime: '20 hours on 2 GPUs',
|
|
658
|
+
},
|
|
659
|
+
useCase: '3D point cloud analysis, robotics',
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
|
|
663
|
+
// 23. World Models
|
|
664
|
+
world_model: {
|
|
665
|
+
world_model_rl: {
|
|
666
|
+
name: 'World Model RL',
|
|
667
|
+
description: 'World model for reinforcement learning',
|
|
668
|
+
model: 'world_model',
|
|
669
|
+
config: {
|
|
670
|
+
visionModel: 'vae',
|
|
671
|
+
memoryModel: 'mdn_rnn',
|
|
672
|
+
latentSize: 32,
|
|
673
|
+
hiddenSize: 256,
|
|
674
|
+
},
|
|
675
|
+
cognitivePatterns: ['systems', 'abstract', 'divergent'],
|
|
676
|
+
performance: {
|
|
677
|
+
expectedAccuracy: '900 score',
|
|
678
|
+
inferenceTime: '10ms',
|
|
679
|
+
memoryUsage: '120MB',
|
|
680
|
+
trainingTime: '3 days on 4 GPUs',
|
|
681
|
+
},
|
|
682
|
+
useCase: 'Model-based RL, environment simulation',
|
|
683
|
+
},
|
|
684
|
+
},
|
|
685
|
+
|
|
686
|
+
// 24. Normalizing Flows
|
|
687
|
+
flow: {
|
|
688
|
+
realvp_generation: {
|
|
689
|
+
name: 'RealNVP Generation',
|
|
690
|
+
description: 'Real-valued non-volume preserving flow',
|
|
691
|
+
model: 'normalizing_flow',
|
|
692
|
+
config: {
|
|
693
|
+
flowType: 'real_nvp',
|
|
694
|
+
couplingLayers: 8,
|
|
695
|
+
hiddenUnits: 512,
|
|
696
|
+
numBlocks: 2,
|
|
697
|
+
},
|
|
698
|
+
cognitivePatterns: ['divergent', 'abstract', 'lateral'],
|
|
699
|
+
performance: {
|
|
700
|
+
expectedAccuracy: '3.49 bits/dim',
|
|
701
|
+
inferenceTime: '20ms',
|
|
702
|
+
memoryUsage: '100MB',
|
|
703
|
+
trainingTime: '2 days on 4 GPUs',
|
|
704
|
+
},
|
|
705
|
+
useCase: 'Density estimation, generative modeling',
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
|
|
709
|
+
// 25. Energy-Based Models
|
|
710
|
+
ebm: {
|
|
711
|
+
ebm_generation: {
|
|
712
|
+
name: 'EBM Generator',
|
|
713
|
+
description: 'Energy-based generative model',
|
|
714
|
+
model: 'ebm',
|
|
715
|
+
config: {
|
|
716
|
+
energyFunction: 'mlp',
|
|
717
|
+
samplingSteps: 100,
|
|
718
|
+
stepSize: 10,
|
|
719
|
+
noise: 0.005,
|
|
720
|
+
},
|
|
721
|
+
cognitivePatterns: ['divergent', 'critical', 'systems'],
|
|
722
|
+
performance: {
|
|
723
|
+
expectedAccuracy: '7.85 FID',
|
|
724
|
+
inferenceTime: '200ms',
|
|
725
|
+
memoryUsage: '80MB',
|
|
726
|
+
trainingTime: '3 days on 2 GPUs',
|
|
727
|
+
},
|
|
728
|
+
useCase: 'Generative modeling, density estimation',
|
|
729
|
+
},
|
|
730
|
+
},
|
|
731
|
+
|
|
732
|
+
// 26. Neural Processes
|
|
733
|
+
neural_process: {
|
|
734
|
+
cnp_regression: {
|
|
735
|
+
name: 'CNP Regression',
|
|
736
|
+
description: 'Conditional neural process for regression',
|
|
737
|
+
model: 'neural_process',
|
|
738
|
+
config: {
|
|
739
|
+
latentDim: 128,
|
|
740
|
+
contextPoints: 10,
|
|
741
|
+
encoderHidden: [128, 128],
|
|
742
|
+
decoderHidden: [128, 128],
|
|
743
|
+
},
|
|
744
|
+
cognitivePatterns: ['abstract', 'systems', 'convergent'],
|
|
745
|
+
performance: {
|
|
746
|
+
expectedAccuracy: '0.15 MSE',
|
|
747
|
+
inferenceTime: '5ms',
|
|
748
|
+
memoryUsage: '30MB',
|
|
749
|
+
trainingTime: '4 hours on 1 GPU',
|
|
750
|
+
},
|
|
751
|
+
useCase: 'Few-shot regression, uncertainty estimation',
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
|
|
755
|
+
// 27. Set Transformer
|
|
756
|
+
set_transformer: {
|
|
757
|
+
set_anomaly: {
|
|
758
|
+
name: 'Set Anomaly Detection',
|
|
759
|
+
description: 'Set transformer for anomaly detection',
|
|
760
|
+
model: 'set_transformer',
|
|
761
|
+
config: {
|
|
762
|
+
inducingPoints: 32,
|
|
763
|
+
dimensions: 128,
|
|
764
|
+
numHeads: 4,
|
|
765
|
+
numBlocks: 4,
|
|
766
|
+
},
|
|
767
|
+
cognitivePatterns: ['critical', 'systems', 'convergent'],
|
|
768
|
+
performance: {
|
|
769
|
+
expectedAccuracy: '95% AUC',
|
|
770
|
+
inferenceTime: '15ms',
|
|
771
|
+
memoryUsage: '50MB',
|
|
772
|
+
trainingTime: '6 hours on 1 GPU',
|
|
773
|
+
},
|
|
774
|
+
useCase: 'Anomaly detection on sets, point cloud analysis',
|
|
775
|
+
},
|
|
776
|
+
},
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Cognitive Pattern Selector
|
|
781
|
+
* Automatically selects cognitive patterns based on model and task
|
|
782
|
+
*/
|
|
783
|
+
export class CognitivePatternSelector {
|
|
784
|
+
constructor() {
|
|
785
|
+
this.patternEvolution = new CognitivePatternEvolution();
|
|
786
|
+
this.metaLearning = new MetaLearningFramework();
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Select optimal cognitive patterns for a neural model preset
|
|
791
|
+
* @param {string} modelType - Type of neural model
|
|
792
|
+
* @param {string} presetName - Name of the preset
|
|
793
|
+
* @param {object} taskContext - Context about the task
|
|
794
|
+
*/
|
|
795
|
+
selectPatternsForPreset(modelType, presetName, taskContext = {}) {
|
|
796
|
+
const preset = COMPLETE_NEURAL_PRESETS[modelType]?.[presetName];
|
|
797
|
+
if (!preset) {
|
|
798
|
+
console.warn(`Preset not found: ${modelType}/${presetName}`);
|
|
799
|
+
return ['convergent']; // Default fallback
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// Start with preset's recommended patterns
|
|
803
|
+
let patterns = [...preset.cognitivePatterns];
|
|
804
|
+
|
|
805
|
+
// Adjust based on task context
|
|
806
|
+
if (taskContext.requiresCreativity) {
|
|
807
|
+
patterns = this.enhanceCreativity(patterns);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
if (taskContext.requiresPrecision) {
|
|
811
|
+
patterns = this.enhancePrecision(patterns);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
if (taskContext.requiresAdaptation) {
|
|
815
|
+
patterns = this.enhanceAdaptation(patterns);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
if (taskContext.complexity === 'high') {
|
|
819
|
+
patterns = this.handleHighComplexity(patterns);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// Ensure pattern diversity
|
|
823
|
+
patterns = this.ensurePatternDiversity(patterns);
|
|
824
|
+
|
|
825
|
+
return patterns;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Enhance patterns for creative tasks
|
|
830
|
+
*/
|
|
831
|
+
enhanceCreativity(patterns) {
|
|
832
|
+
if (!patterns.includes('divergent')) {
|
|
833
|
+
patterns.push('divergent');
|
|
834
|
+
}
|
|
835
|
+
if (!patterns.includes('lateral') && patterns.length < 4) {
|
|
836
|
+
patterns.push('lateral');
|
|
837
|
+
}
|
|
838
|
+
return patterns;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Enhance patterns for precision tasks
|
|
843
|
+
*/
|
|
844
|
+
enhancePrecision(patterns) {
|
|
845
|
+
if (!patterns.includes('convergent')) {
|
|
846
|
+
patterns.push('convergent');
|
|
847
|
+
}
|
|
848
|
+
if (!patterns.includes('critical') && patterns.length < 4) {
|
|
849
|
+
patterns.push('critical');
|
|
850
|
+
}
|
|
851
|
+
// Remove highly exploratory patterns for precision
|
|
852
|
+
return patterns.filter(p => p !== 'divergent' || patterns.length > 2);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Enhance patterns for adaptive tasks
|
|
857
|
+
*/
|
|
858
|
+
enhanceAdaptation(patterns) {
|
|
859
|
+
if (!patterns.includes('systems')) {
|
|
860
|
+
patterns.push('systems');
|
|
861
|
+
}
|
|
862
|
+
if (!patterns.includes('abstract') && patterns.length < 4) {
|
|
863
|
+
patterns.push('abstract');
|
|
864
|
+
}
|
|
865
|
+
return patterns;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Handle high complexity tasks
|
|
870
|
+
*/
|
|
871
|
+
handleHighComplexity(patterns) {
|
|
872
|
+
// For high complexity, ensure both analytical and creative patterns
|
|
873
|
+
const hasAnalytical = patterns.some(p => ['convergent', 'critical', 'systems'].includes(p));
|
|
874
|
+
const hasCreative = patterns.some(p => ['divergent', 'lateral', 'abstract'].includes(p));
|
|
875
|
+
|
|
876
|
+
if (!hasAnalytical) {
|
|
877
|
+
patterns.push('systems');
|
|
878
|
+
}
|
|
879
|
+
if (!hasCreative) {
|
|
880
|
+
patterns.push('abstract');
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
return patterns;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Ensure pattern diversity
|
|
888
|
+
*/
|
|
889
|
+
ensurePatternDiversity(patterns) {
|
|
890
|
+
// Limit to maximum 4 patterns
|
|
891
|
+
if (patterns.length > 4) {
|
|
892
|
+
// Keep the most diverse set
|
|
893
|
+
const diversity = this.calculatePatternDiversity(patterns);
|
|
894
|
+
patterns = this.selectMostDiverse(patterns, diversity, 4);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// Ensure at least 2 patterns for robustness
|
|
898
|
+
if (patterns.length < 2) {
|
|
899
|
+
if (!patterns.includes('convergent')) {
|
|
900
|
+
patterns.push('convergent');
|
|
901
|
+
} else {
|
|
902
|
+
patterns.push('systems');
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
return [...new Set(patterns)]; // Remove duplicates
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Calculate diversity score for pattern combinations
|
|
911
|
+
*/
|
|
912
|
+
calculatePatternDiversity(patterns) {
|
|
913
|
+
const patternTypes = {
|
|
914
|
+
analytical: ['convergent', 'critical'],
|
|
915
|
+
creative: ['divergent', 'lateral'],
|
|
916
|
+
systemic: ['systems', 'abstract'],
|
|
917
|
+
};
|
|
918
|
+
|
|
919
|
+
let diversityScore = 0;
|
|
920
|
+
const typesCovered = new Set();
|
|
921
|
+
|
|
922
|
+
patterns.forEach(pattern => {
|
|
923
|
+
Object.entries(patternTypes).forEach(([type, typePatterns]) => {
|
|
924
|
+
if (typePatterns.includes(pattern)) {
|
|
925
|
+
typesCovered.add(type);
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
diversityScore = typesCovered.size / Object.keys(patternTypes).length;
|
|
931
|
+
return diversityScore;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Select most diverse pattern combination
|
|
936
|
+
*/
|
|
937
|
+
selectMostDiverse(patterns, currentDiversity, targetCount) {
|
|
938
|
+
if (patterns.length <= targetCount) {
|
|
939
|
+
return patterns;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// Simple heuristic: keep patterns that maximize type coverage
|
|
943
|
+
const selected = [];
|
|
944
|
+
const patternTypes = {
|
|
945
|
+
analytical: ['convergent', 'critical'],
|
|
946
|
+
creative: ['divergent', 'lateral'],
|
|
947
|
+
systemic: ['systems', 'abstract'],
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
// First, ensure one pattern from each type if possible
|
|
951
|
+
Object.values(patternTypes).forEach(typePatterns => {
|
|
952
|
+
const available = patterns.filter(p => typePatterns.includes(p));
|
|
953
|
+
if (available.length > 0 && selected.length < targetCount) {
|
|
954
|
+
selected.push(available[0]);
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
// Fill remaining slots with most unique patterns
|
|
959
|
+
patterns.forEach(pattern => {
|
|
960
|
+
if (!selected.includes(pattern) && selected.length < targetCount) {
|
|
961
|
+
selected.push(pattern);
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
return selected;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Get preset recommendations based on use case
|
|
970
|
+
*/
|
|
971
|
+
getPresetRecommendations(useCase, requirements = {}) {
|
|
972
|
+
const recommendations = [];
|
|
973
|
+
|
|
974
|
+
Object.entries(COMPLETE_NEURAL_PRESETS).forEach(([modelType, presets]) => {
|
|
975
|
+
Object.entries(presets).forEach(([presetName, preset]) => {
|
|
976
|
+
if (preset.useCase.toLowerCase().includes(useCase.toLowerCase())) {
|
|
977
|
+
const score = this.calculatePresetScore(preset, requirements);
|
|
978
|
+
recommendations.push({
|
|
979
|
+
modelType,
|
|
980
|
+
presetName,
|
|
981
|
+
preset,
|
|
982
|
+
score,
|
|
983
|
+
cognitivePatterns: this.selectPatternsForPreset(modelType, presetName, requirements),
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
// Sort by score
|
|
990
|
+
recommendations.sort((a, b) => b.score - a.score);
|
|
991
|
+
|
|
992
|
+
return recommendations.slice(0, 5); // Top 5 recommendations
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Calculate preset score based on requirements
|
|
997
|
+
*/
|
|
998
|
+
calculatePresetScore(preset, requirements) {
|
|
999
|
+
let score = 1.0;
|
|
1000
|
+
|
|
1001
|
+
// Check performance requirements
|
|
1002
|
+
if (requirements.maxInferenceTime) {
|
|
1003
|
+
const inferenceTime = parseInt(preset.performance.inferenceTime, 10);
|
|
1004
|
+
if (inferenceTime <= requirements.maxInferenceTime) {
|
|
1005
|
+
score += 0.2;
|
|
1006
|
+
} else {
|
|
1007
|
+
score -= 0.3;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
if (requirements.maxMemoryUsage) {
|
|
1012
|
+
const memoryUsage = parseInt(preset.performance.memoryUsage, 10);
|
|
1013
|
+
if (memoryUsage <= requirements.maxMemoryUsage) {
|
|
1014
|
+
score += 0.2;
|
|
1015
|
+
} else {
|
|
1016
|
+
score -= 0.3;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
if (requirements.minAccuracy) {
|
|
1021
|
+
const accuracy = parseFloat(preset.performance.expectedAccuracy);
|
|
1022
|
+
if (accuracy >= requirements.minAccuracy) {
|
|
1023
|
+
score += 0.3;
|
|
1024
|
+
} else {
|
|
1025
|
+
score -= 0.2;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
// Cognitive pattern alignment
|
|
1030
|
+
if (requirements.cognitivePreference) {
|
|
1031
|
+
const hasPreferred = preset.cognitivePatterns.some(p =>
|
|
1032
|
+
p === requirements.cognitivePreference,
|
|
1033
|
+
);
|
|
1034
|
+
if (hasPreferred) {
|
|
1035
|
+
score += 0.2;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
return Math.max(0, Math.min(2, score));
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* Neural Adaptation Engine
|
|
1045
|
+
* Enables cross-session learning and adaptation
|
|
1046
|
+
*/
|
|
1047
|
+
export class NeuralAdaptationEngine {
|
|
1048
|
+
constructor() {
|
|
1049
|
+
this.adaptationHistory = new Map();
|
|
1050
|
+
this.crossSessionMemory = new Map();
|
|
1051
|
+
this.performanceBaselines = new Map();
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* Initialize adaptation for a model preset
|
|
1056
|
+
*/
|
|
1057
|
+
async initializeAdaptation(agentId, modelType, presetName) {
|
|
1058
|
+
const preset = COMPLETE_NEURAL_PRESETS[modelType]?.[presetName];
|
|
1059
|
+
if (!preset) {
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
this.adaptationHistory.set(agentId, {
|
|
1064
|
+
modelType,
|
|
1065
|
+
presetName,
|
|
1066
|
+
baselinePerformance: preset.performance,
|
|
1067
|
+
adaptations: [],
|
|
1068
|
+
sessionCount: 0,
|
|
1069
|
+
totalTrainingTime: 0,
|
|
1070
|
+
performanceGains: [],
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
this.performanceBaselines.set(`${modelType}/${presetName}`, preset.performance);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Record adaptation results
|
|
1078
|
+
*/
|
|
1079
|
+
async recordAdaptation(agentId, adaptationResult) {
|
|
1080
|
+
const history = this.adaptationHistory.get(agentId);
|
|
1081
|
+
if (!history) {
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
history.adaptations.push({
|
|
1086
|
+
timestamp: Date.now(),
|
|
1087
|
+
sessionId: history.sessionCount++,
|
|
1088
|
+
result: adaptationResult,
|
|
1089
|
+
performanceGain: this.calculatePerformanceGain(adaptationResult, history.baselinePerformance),
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
// Update cross-session memory
|
|
1093
|
+
await this.updateCrossSessionMemory(agentId, adaptationResult);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Calculate performance gain from adaptation
|
|
1098
|
+
*/
|
|
1099
|
+
calculatePerformanceGain(result, baseline) {
|
|
1100
|
+
const baselineAccuracy = parseFloat(baseline.expectedAccuracy) || 0;
|
|
1101
|
+
const currentAccuracy = result.accuracy || 0;
|
|
1102
|
+
|
|
1103
|
+
return {
|
|
1104
|
+
accuracyGain: currentAccuracy - baselineAccuracy,
|
|
1105
|
+
relativeGain: baselineAccuracy > 0 ? (currentAccuracy - baselineAccuracy) / baselineAccuracy : 0,
|
|
1106
|
+
efficiency: result.trainingTime ? baseline.trainingTime / result.trainingTime : 1,
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Update cross-session memory
|
|
1112
|
+
*/
|
|
1113
|
+
async updateCrossSessionMemory(agentId, adaptationResult) {
|
|
1114
|
+
const memoryKey = `agent_${agentId}_adaptations`;
|
|
1115
|
+
|
|
1116
|
+
if (!this.crossSessionMemory.has(memoryKey)) {
|
|
1117
|
+
this.crossSessionMemory.set(memoryKey, []);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
const memory = this.crossSessionMemory.get(memoryKey);
|
|
1121
|
+
memory.push({
|
|
1122
|
+
timestamp: Date.now(),
|
|
1123
|
+
patterns: adaptationResult.cognitivePatterns || [],
|
|
1124
|
+
performance: adaptationResult.performance || {},
|
|
1125
|
+
insights: adaptationResult.insights || [],
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
// Keep only recent memories (last 100)
|
|
1129
|
+
if (memory.length > 100) {
|
|
1130
|
+
memory.splice(0, memory.length - 100);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Get adaptation recommendations
|
|
1136
|
+
*/
|
|
1137
|
+
async getAdaptationRecommendations(agentId) {
|
|
1138
|
+
const history = this.adaptationHistory.get(agentId);
|
|
1139
|
+
if (!history || history.adaptations.length < 3) {
|
|
1140
|
+
return null; // Need more data
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
const recommendations = {
|
|
1144
|
+
patterns: this.analyzePatternEffectiveness(history),
|
|
1145
|
+
hyperparameters: this.suggestHyperparameters(history),
|
|
1146
|
+
trainingStrategy: this.recommendTrainingStrategy(history),
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
return recommendations;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* Analyze pattern effectiveness from history
|
|
1154
|
+
*/
|
|
1155
|
+
analyzePatternEffectiveness(history) {
|
|
1156
|
+
const patternPerformance = new Map();
|
|
1157
|
+
|
|
1158
|
+
history.adaptations.forEach(adaptation => {
|
|
1159
|
+
const patterns = adaptation.result.cognitivePatterns || [];
|
|
1160
|
+
const gain = adaptation.performanceGain.accuracyGain;
|
|
1161
|
+
|
|
1162
|
+
patterns.forEach(pattern => {
|
|
1163
|
+
if (!patternPerformance.has(pattern)) {
|
|
1164
|
+
patternPerformance.set(pattern, { totalGain: 0, count: 0 });
|
|
1165
|
+
}
|
|
1166
|
+
const stats = patternPerformance.get(pattern);
|
|
1167
|
+
stats.totalGain += gain;
|
|
1168
|
+
stats.count++;
|
|
1169
|
+
});
|
|
1170
|
+
});
|
|
1171
|
+
|
|
1172
|
+
// Calculate average gain per pattern
|
|
1173
|
+
const effectiveness = [];
|
|
1174
|
+
patternPerformance.forEach((stats, pattern) => {
|
|
1175
|
+
effectiveness.push({
|
|
1176
|
+
pattern,
|
|
1177
|
+
avgGain: stats.totalGain / stats.count,
|
|
1178
|
+
frequency: stats.count,
|
|
1179
|
+
});
|
|
1180
|
+
});
|
|
1181
|
+
|
|
1182
|
+
effectiveness.sort((a, b) => b.avgGain - a.avgGain);
|
|
1183
|
+
return effectiveness;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* Suggest hyperparameters based on history
|
|
1188
|
+
*/
|
|
1189
|
+
suggestHyperparameters(history) {
|
|
1190
|
+
// Analyze successful adaptations
|
|
1191
|
+
const successfulAdaptations = history.adaptations.filter(a =>
|
|
1192
|
+
a.performanceGain.accuracyGain > 0,
|
|
1193
|
+
);
|
|
1194
|
+
|
|
1195
|
+
if (successfulAdaptations.length === 0) {
|
|
1196
|
+
return {
|
|
1197
|
+
learningRate: 0.001,
|
|
1198
|
+
batchSize: 32,
|
|
1199
|
+
epochs: 10,
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// Extract and average successful hyperparameters
|
|
1204
|
+
const hyperparams = {
|
|
1205
|
+
learningRate: 0,
|
|
1206
|
+
batchSize: 0,
|
|
1207
|
+
epochs: 0,
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
successfulAdaptations.forEach(adaptation => {
|
|
1211
|
+
const config = adaptation.result.trainingConfig || {};
|
|
1212
|
+
hyperparams.learningRate += config.learningRate || 0.001;
|
|
1213
|
+
hyperparams.batchSize += config.batchSize || 32;
|
|
1214
|
+
hyperparams.epochs += config.epochs || 10;
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
const count = successfulAdaptations.length;
|
|
1218
|
+
return {
|
|
1219
|
+
learningRate: hyperparams.learningRate / count,
|
|
1220
|
+
batchSize: Math.round(hyperparams.batchSize / count),
|
|
1221
|
+
epochs: Math.round(hyperparams.epochs / count),
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Recommend training strategy
|
|
1227
|
+
*/
|
|
1228
|
+
recommendTrainingStrategy(history) {
|
|
1229
|
+
const recentPerformance = history.adaptations.slice(-5);
|
|
1230
|
+
const isImproving = recentPerformance.every((a, i) =>
|
|
1231
|
+
i === 0 || a.performanceGain.accuracyGain >= recentPerformance[i - 1].performanceGain.accuracyGain,
|
|
1232
|
+
);
|
|
1233
|
+
|
|
1234
|
+
if (isImproving) {
|
|
1235
|
+
return {
|
|
1236
|
+
strategy: 'continue_current',
|
|
1237
|
+
description: 'Current approach is showing consistent improvement',
|
|
1238
|
+
recommendations: ['Maintain current learning rate', 'Consider increasing batch size'],
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
return {
|
|
1242
|
+
strategy: 'explore_alternatives',
|
|
1243
|
+
description: 'Performance has plateaued',
|
|
1244
|
+
recommendations: [
|
|
1245
|
+
'Try different cognitive patterns',
|
|
1246
|
+
'Reduce learning rate',
|
|
1247
|
+
'Implement learning rate scheduling',
|
|
1248
|
+
'Consider data augmentation',
|
|
1249
|
+
],
|
|
1250
|
+
};
|
|
1251
|
+
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* Export adaptation insights
|
|
1256
|
+
*/
|
|
1257
|
+
exportAdaptationInsights() {
|
|
1258
|
+
const insights = {
|
|
1259
|
+
totalAgents: this.adaptationHistory.size,
|
|
1260
|
+
modelTypes: {},
|
|
1261
|
+
overallPerformance: {
|
|
1262
|
+
avgAccuracyGain: 0,
|
|
1263
|
+
totalAdaptations: 0,
|
|
1264
|
+
},
|
|
1265
|
+
bestPractices: [],
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
this.adaptationHistory.forEach((history, _agentId) => {
|
|
1269
|
+
const modelKey = `${history.modelType}/${history.presetName}`;
|
|
1270
|
+
|
|
1271
|
+
if (!insights.modelTypes[modelKey]) {
|
|
1272
|
+
insights.modelTypes[modelKey] = {
|
|
1273
|
+
count: 0,
|
|
1274
|
+
avgGain: 0,
|
|
1275
|
+
bestGain: 0,
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
const modelStats = insights.modelTypes[modelKey];
|
|
1280
|
+
modelStats.count++;
|
|
1281
|
+
|
|
1282
|
+
history.adaptations.forEach(adaptation => {
|
|
1283
|
+
const gain = adaptation.performanceGain.accuracyGain;
|
|
1284
|
+
modelStats.avgGain += gain;
|
|
1285
|
+
modelStats.bestGain = Math.max(modelStats.bestGain, gain);
|
|
1286
|
+
insights.overallPerformance.avgAccuracyGain += gain;
|
|
1287
|
+
insights.overallPerformance.totalAdaptations++;
|
|
1288
|
+
});
|
|
1289
|
+
});
|
|
1290
|
+
|
|
1291
|
+
// Calculate averages
|
|
1292
|
+
Object.values(insights.modelTypes).forEach(stats => {
|
|
1293
|
+
if (stats.count > 0) {
|
|
1294
|
+
stats.avgGain /= stats.count;
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1297
|
+
|
|
1298
|
+
if (insights.overallPerformance.totalAdaptations > 0) {
|
|
1299
|
+
insights.overallPerformance.avgAccuracyGain /= insights.overallPerformance.totalAdaptations;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
return insights;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
// All components are already exported above
|