@openfluke/welvet 0.3.0 → 0.75.0
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/LICENSE +200 -200
- package/README.md +64 -353
- package/dist/benchmark_tiling.html +244 -0
- package/dist/benchmark_training.html +249 -0
- package/dist/benchmark_training_comparison.html +230 -0
- package/dist/cabi_verify.html +360 -0
- package/dist/coverage_check.html +298 -0
- package/dist/dna_evo_benchmark.html +420 -0
- package/dist/example.html +283 -0
- package/dist/index.d.ts +152 -31
- package/dist/index.js +170 -60
- package/dist/loader.browser.d.ts +2 -2
- package/dist/loader.browser.js +7 -8
- package/dist/loader.d.ts +2 -2
- package/dist/loader.js +12 -25
- package/dist/main.wasm +0 -0
- package/dist/src/index.d.ts +182 -0
- package/dist/src/index.js +207 -0
- package/dist/src/loader.browser.d.ts +5 -0
- package/dist/src/loader.browser.js +24 -0
- package/dist/src/loader.d.ts +5 -0
- package/dist/src/loader.js +26 -0
- package/dist/src/types.d.ts +354 -0
- package/dist/src/types.js +65 -0
- package/dist/tests/benchmark.d.ts +5 -0
- package/dist/tests/benchmark.js +139 -0
- package/dist/tests/benchmark.ts +148 -0
- package/dist/tests/cabi_verify.d.ts +5 -0
- package/dist/tests/cabi_verify.js +181 -0
- package/dist/tests/cabi_verify.ts +192 -0
- package/dist/tests/coverage.ts +113 -0
- package/dist/types.d.ts +326 -169
- package/dist/types.js +63 -2
- package/dist/wasm_exec.js +575 -575
- package/package.json +87 -88
- package/dist/index.browser.d.ts +0 -32
- package/dist/index.browser.js +0 -39
package/README.md
CHANGED
|
@@ -1,410 +1,121 @@
|
|
|
1
|
-
# @openfluke/welvet
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
| | **Runtime Dependency** | **None** | Heavy | Light | Light | None |
|
|
16
|
-
| **Loading** | **Safetensors** | ✅ **Native** | ❌ | ❌ | ❌ | ✅ |
|
|
17
|
-
| | **Structure Inference** | ✅ **Auto-Detect** | ❌ | ❌ | ❌ | ❌ |
|
|
18
|
-
| **Training** | **Browser Training** | ✅ **Full** | ✅ (Slow) | ✅ | ❌ | ✅ |
|
|
19
|
-
| | **Neural Tweening** | ✅ **Hybrid Engine** | ❌ | ❌ | ❌ | ❌ |
|
|
20
|
-
| | **LR Schedulers** | ✅ **7 Types** | ✅ | ⚠️ | ❌ | ✅ |
|
|
21
|
-
| **Layer Support** | **Dense (MLP)** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
22
|
-
| | **Conv1D/2D** | ✅ **Native** | ✅ | ❌ | ✅ | ✅ |
|
|
23
|
-
| | **RNN / LSTM** | ✅ **Full Gate** | ✅ | ✅ | ✅ | ✅ |
|
|
24
|
-
| | **Transformer (MHA)** | ✅ (Explicit) | ✅ | ❌ | ✅ | ✅ |
|
|
25
|
-
| | **Parallel / MoE** | ✅ **Structure** | ❌ (Manual) | ❌ | ❌ | ❌ |
|
|
26
|
-
| | **Sequential Layers** | ✅ **Native** | ⚠️ | ⚠️ | ❌ | ⚠️ |
|
|
27
|
-
| **Advanced** | **Step-Based Forward** | ✅ **Unique** | ❌ | ❌ | ❌ | ❌ |
|
|
28
|
-
| | **Stitch Layers** | ✅ **Native** | ❌ | ❌ | ❌ | ❌ |
|
|
29
|
-
| | **K-Means / Stats** | ✅ **Parallel** | ❌ | ❌ | ❌ | ❌ |
|
|
30
|
-
| | **Cross-Lang ABI** | ✅ **Universal** | ❌ | ❌ | ❌ | ⚠️ |
|
|
31
|
-
| **Streaming** | **LLM Streaming** | ✅ | ✅ | ❌ | ❌ | ✅ |
|
|
32
|
-
| | **Pure Go Tokenizer** | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
33
|
-
|
|
34
|
-
For detailed comparison, see [`docs/loom_assessment_comparison.md`](../docs/loom_assessment_comparison.md).
|
|
35
|
-
|
|
36
|
-
## 🌍 Cross-Ecosystem Compatibility
|
|
37
|
-
|
|
38
|
-
Models trained in TypeScript can be loaded instantly in Python, C#, Go, or other WASM environments. **Bit-for-bit identical results** across all platforms.
|
|
39
|
-
|
|
40
|
-
| Platform | Package | Install |
|
|
41
|
-
|:---------|:--------|:--------|
|
|
42
|
-
| **TypeScript/Node** | [NPM](https://www.npmjs.com/package/@openfluke/welvet) | `npm install @openfluke/welvet` |
|
|
43
|
-
| **Python** | [PyPI](https://pypi.org/project/welvet/) | `pip install welvet` |
|
|
44
|
-
| **C#/.NET** | [NuGet](https://www.nuget.org/packages/Welvet) | `dotnet add package Welvet` |
|
|
45
|
-
| **Go** | [GitHub](https://github.com/openfluke/loom) | `go get github.com/openfluke/loom` |
|
|
46
|
-
|
|
47
|
-
### Key Strengths
|
|
48
|
-
|
|
49
|
-
- **True Embeddability**: Single WASM binary. Works in Node.js and browsers with the same API.
|
|
50
|
-
- **Hybrid Gradient/Geometric Engine**: "Neural Tweening" combines geometric gap-closing with backpropagation-guided momentum.
|
|
51
|
-
- **Structural Parallelism**: Native support for Inception, ResNeXt, Siamese, and MoE architectures via `LayerParallel`.
|
|
52
|
-
- **Native Mixed-Precision**: Generic tensor backend supports `int8`, `uint16`, and `float32`.
|
|
53
|
-
- **Complete Evaluation Suite**: Deviation metrics, training milestones, and adaptation tracking.
|
|
54
|
-
- **Network Telemetry**: Runtime introspection with `GetMethodsJSON()` and `ExtractNetworkBlueprint()`.
|
|
1
|
+
# @openfluke/welvet
|
|
2
|
+
|
|
3
|
+
**M-POLY-VTD AI Engine (Loom v0.75.0)** — Isomorphic TypeScript/WASM library for building, training, and evolving neural networks with 21 numerical types, WebGPU acceleration, and DNA-based evolution.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@openfluke/welvet)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Isomorphic Architecture**: Runs seamlessly in Node.js, Bun, and the Browser (React/Frontend).
|
|
11
|
+
- **Multi-Precision Support**: Native support for 21 numerical types (FP64, FP32, FP16, BF16, FP8, INT8... all the way down to Binary/Ternary).
|
|
12
|
+
- **Hybrid Training**: standard Backprop, Target Propagation, and NEAT-style structural evolution in a single unified engine.
|
|
13
|
+
- **Hardware Acceleration**: WebGPU support for high-performance inference and training in the browser.
|
|
14
|
+
- **DNA Evolution**: Network "DNA" extraction and comparison for architectural analysis and genetic recombination.
|
|
55
15
|
|
|
56
16
|
## Installation
|
|
57
17
|
|
|
58
18
|
```bash
|
|
59
19
|
npm install @openfluke/welvet
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
**Using Bun:**
|
|
63
|
-
```bash
|
|
20
|
+
# or
|
|
64
21
|
bun add @openfluke/welvet
|
|
65
22
|
```
|
|
66
23
|
|
|
67
24
|
## Quick Start
|
|
68
25
|
|
|
69
|
-
###
|
|
26
|
+
### 1. Initialization
|
|
70
27
|
|
|
71
|
-
The
|
|
28
|
+
The engine initializes automatically after a single call to `init()`. It detects whether it's running in Node.js, Bun, or the Browser and loads the appropriate WASM environment.
|
|
72
29
|
|
|
73
30
|
```typescript
|
|
74
|
-
import
|
|
75
|
-
|
|
76
|
-
// Initialize LOOM WASM
|
|
77
|
-
await init();
|
|
78
|
-
|
|
79
|
-
// Create network from JSON config
|
|
80
|
-
const config = {
|
|
81
|
-
batch_size: 1,
|
|
82
|
-
grid_rows: 1,
|
|
83
|
-
grid_cols: 3,
|
|
84
|
-
layers_per_cell: 1,
|
|
85
|
-
layers: [
|
|
86
|
-
{ type: "dense", input_size: 8, output_size: 16, activation: "relu" },
|
|
87
|
-
{
|
|
88
|
-
type: "parallel",
|
|
89
|
-
combine_mode: "grid_scatter",
|
|
90
|
-
grid_output_rows: 3, grid_output_cols: 1, grid_output_layers: 1,
|
|
91
|
-
grid_positions: [
|
|
92
|
-
{ branch_index: 0, target_row: 0, target_col: 0, target_layer: 0 },
|
|
93
|
-
{ branch_index: 1, target_row: 1, target_col: 0, target_layer: 0 },
|
|
94
|
-
{ branch_index: 2, target_row: 2, target_col: 0, target_layer: 0 },
|
|
95
|
-
],
|
|
96
|
-
branches: [
|
|
97
|
-
{ type: "parallel", combine_mode: "add", branches: [
|
|
98
|
-
{ type: "dense", input_size: 16, output_size: 8, activation: "relu" },
|
|
99
|
-
{ type: "dense", input_size: 16, output_size: 8, activation: "gelu" },
|
|
100
|
-
]},
|
|
101
|
-
{ type: "lstm", input_size: 16, hidden_size: 8, seq_length: 1 },
|
|
102
|
-
{ type: "rnn", input_size: 16, hidden_size: 8, seq_length: 1 },
|
|
103
|
-
],
|
|
104
|
-
},
|
|
105
|
-
{ type: "dense", input_size: 24, output_size: 2, activation: "sigmoid" },
|
|
106
|
-
],
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const network = createNetworkFromJSON(JSON.stringify(config));
|
|
110
|
-
|
|
111
|
-
// Training
|
|
112
|
-
const batches = [
|
|
113
|
-
{ Input: [0.2, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8], Target: [1.0, 0.0] },
|
|
114
|
-
{ Input: [0.9, 0.9, 0.9, 0.9, 0.1, 0.1, 0.1, 0.1], Target: [0.0, 1.0] },
|
|
115
|
-
];
|
|
116
|
-
|
|
117
|
-
const trainingConfig = {
|
|
118
|
-
Epochs: 800,
|
|
119
|
-
LearningRate: 0.15,
|
|
120
|
-
LossType: "mse",
|
|
121
|
-
GradientClip: 1.0,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
network.Train(JSON.stringify([batches, trainingConfig]));
|
|
125
|
-
|
|
126
|
-
// Forward pass
|
|
127
|
-
const [output] = network.ForwardCPU(JSON.stringify([[0.2, 0.2, 0.2, 0.2, 0.8, 0.8, 0.8, 0.8]]));
|
|
128
|
-
console.log("Output:", JSON.parse(output)); // [0.95, 0.05]
|
|
31
|
+
import welvet from "@openfluke/welvet";
|
|
129
32
|
|
|
130
|
-
//
|
|
131
|
-
const [modelJSON] = network.SaveModelToString(JSON.stringify(["my_model"]));
|
|
132
|
-
const loadedNetwork = loadLoomNetwork(modelJSON, "my_model");
|
|
33
|
+
await welvet.init(); // Auto-detects Node.js/Browser and loads WASM
|
|
133
34
|
```
|
|
134
35
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
| Function | Description |
|
|
138
|
-
|:---------|:------------|
|
|
139
|
-
| `createNetworkFromJSON(config)` | Create network from JSON |
|
|
140
|
-
| `loadLoomNetwork(json, id)` | Load saved model |
|
|
141
|
-
| `network.ForwardCPU(input)` | Forward pass |
|
|
142
|
-
| `network.BackwardCPU(gradients)` | Backward pass |
|
|
143
|
-
| `network.Train(params)` | Train network |
|
|
144
|
-
| `network.SaveModelToString(id)` | Save to JSON string |
|
|
145
|
-
| `network.EvaluateNetwork(params)` | Evaluate with metrics |
|
|
36
|
+
> [!TIP]
|
|
37
|
+
> In browser environments, if your assets are served from a non-standard path, you can optionally pass a custom URL: `await init("/custom/path/to/main.wasm")`.
|
|
146
38
|
|
|
147
|
-
###
|
|
148
|
-
|
|
149
|
-
Execute networks one step at a time for online learning:
|
|
39
|
+
### 2. Create a Network
|
|
150
40
|
|
|
151
41
|
```typescript
|
|
152
|
-
import
|
|
153
|
-
|
|
154
|
-
await init();
|
|
42
|
+
import welvet from "@openfluke/welvet";
|
|
155
43
|
|
|
156
|
-
|
|
157
|
-
|
|
44
|
+
// 1D sequential stack on the Volumetric Grid (cell 0,0,0)
|
|
45
|
+
const net = welvet.createNetwork({
|
|
46
|
+
depth: 1, rows: 1, cols: 1, layers_per_cell: 2,
|
|
158
47
|
layers: [
|
|
159
|
-
{ type: "
|
|
160
|
-
{ type: "
|
|
161
|
-
{ type: "dense", input_height: 12, output_height: 3, activation: "softmax" }
|
|
48
|
+
{ z: 0, y: 0, x: 0, l: 0, type: "Dense", input_height: 784, output_height: 256, activation: "ReLU" },
|
|
49
|
+
{ z: 0, y: 0, x: 0, l: 1, type: "Dense", input_height: 256, output_height: 10, activation: "Linear" }
|
|
162
50
|
]
|
|
163
51
|
});
|
|
164
52
|
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
// Training loop - update weights after EACH step
|
|
169
|
-
for (let step = 0; step < 100000; step++) {
|
|
170
|
-
state.setInput(new Float32Array([0.1, 0.2, 0.1, 0.3]));
|
|
171
|
-
state.stepForward();
|
|
172
|
-
const output = state.getOutput();
|
|
173
|
-
|
|
174
|
-
// Backward pass
|
|
175
|
-
const gradients = output.map((o, i) => o - target[i]);
|
|
176
|
-
state.stepBackward(gradients);
|
|
177
|
-
|
|
178
|
-
// Update weights immediately
|
|
179
|
-
network.ApplyGradients(JSON.stringify([learningRate]));
|
|
180
|
-
}
|
|
53
|
+
const input = new Float32Array(784).fill(0.5);
|
|
54
|
+
const output = net.sequentialForward(input);
|
|
55
|
+
console.log("Prediction:", output[0]); // Returns Float32Array
|
|
181
56
|
```
|
|
182
57
|
|
|
183
|
-
###
|
|
184
|
-
|
|
185
|
-
Direct weight adjustment without backpropagation:
|
|
58
|
+
### 3. Training
|
|
186
59
|
|
|
187
60
|
```typescript
|
|
188
|
-
import {
|
|
189
|
-
|
|
190
|
-
await init();
|
|
191
|
-
|
|
192
|
-
const network = createNetwork(config);
|
|
193
|
-
|
|
194
|
-
// Create tween state (with optional chain rule)
|
|
195
|
-
const tweenState: TweenState = network.createTweenState(true); // useChainRule=true
|
|
196
|
-
|
|
197
|
-
// Training loop - direct weight updates
|
|
198
|
-
for (let step = 0; step < 10000; step++) {
|
|
199
|
-
const loss = tweenState.TweenStep(
|
|
200
|
-
new Float32Array([0.1, 0.2, 0.3, 0.4]),
|
|
201
|
-
1, // targetClass
|
|
202
|
-
4, // outputSize
|
|
203
|
-
0.02 // learningRate
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
```
|
|
61
|
+
import { trainNetwork } from "@openfluke/welvet";
|
|
207
62
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
63
|
+
const batches = [
|
|
64
|
+
{ input: [0.1, 0.2, ...], target: [1, 0, ...] },
|
|
65
|
+
];
|
|
211
66
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
bun run test18_adaptation.ts
|
|
67
|
+
const result = trainNetwork(net, batches, 10, 0.001);
|
|
68
|
+
console.log("Final Loss:", result.final_loss);
|
|
215
69
|
```
|
|
216
70
|
|
|
217
|
-
|
|
218
|
-
- **Architectures:** Dense, Conv2D, RNN, LSTM, Attention
|
|
219
|
-
- **Depths:** 3, 5, 9 layers
|
|
220
|
-
- **Modes:** NormalBP, StepBP, Tween, TweenChain, StepTweenChain
|
|
221
|
-
|
|
222
|
-
## Complete Test Suite
|
|
223
|
-
|
|
224
|
-
The `universal_test.ts` example demonstrates all framework capabilities with **100% parity** to the Go/C core.
|
|
225
|
-
|
|
226
|
-
### Running in Browser (v0.3.0+)
|
|
227
|
-
|
|
228
|
-
The universal test suite now runs directly in the browser with a full DOM report:
|
|
229
|
-
|
|
230
|
-
```bash
|
|
231
|
-
cd typescript
|
|
232
|
-
python3 serve.py
|
|
233
|
-
# Open http://localhost:8081
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### Running in Node/Bun
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
cd example
|
|
240
|
-
bun run universal_test.ts
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Test Coverage (2298 Tests):**
|
|
244
|
-
- ✅ **Serialization**: 12 Layer Types × 15 Data Types (2100 combinations)
|
|
245
|
-
- ✅ **In-Memory WASM**: SafeTensors without filesystem (144 tests)
|
|
246
|
-
- ✅ **Advanced Math**: K-Means, Correlation, Grafting, Ensembles
|
|
247
|
-
- ✅ **GPU Parity**: Determinism checks for forward/backward passes
|
|
248
|
-
- ✅ **Core**: Architecture generation, combinators, sequential layers
|
|
249
|
-
|
|
250
|
-
See [`example/universal_test.ts`](./example/universal_test.ts) for the complete test implementation.
|
|
251
|
-
|
|
252
|
-
## Layer Types
|
|
253
|
-
|
|
254
|
-
| Layer | Type String | Description |
|
|
255
|
-
|:------|:------------|:------------|
|
|
256
|
-
| Dense | `dense` | Fully connected layer |
|
|
257
|
-
| LSTM | `lstm` | Long Short-Term Memory |
|
|
258
|
-
| RNN | `rnn` | Recurrent Neural Network |
|
|
259
|
-
| GRU | `gru` | Gated Recurrent Unit |
|
|
260
|
-
| Conv2D | `conv2d` | 2D Convolution |
|
|
261
|
-
| Conv1D | `conv1d` | 1D Convolution |
|
|
262
|
-
| Multi-Head Attention | `multi_head_attention` | Transformer attention |
|
|
263
|
-
| LayerNorm | `layer_norm` | Layer normalization |
|
|
264
|
-
| RMSNorm | `rms_norm` | RMS normalization |
|
|
265
|
-
| SwiGLU | `swiglu` | SwiGLU activation layer |
|
|
266
|
-
| Softmax | `softmax` | Softmax classification |
|
|
267
|
-
| Embedding | `embedding` | Token embedding |
|
|
268
|
-
| Parallel | `parallel` | Branching with combine modes |
|
|
269
|
-
| Sequential | `sequential` | Grouped sub-layers |
|
|
270
|
-
|
|
271
|
-
**Parallel Combine Modes:** `add`, `concat`, `multiply`, `average`, `grid_scatter`, `filter`
|
|
272
|
-
|
|
273
|
-
## Activation Functions
|
|
274
|
-
|
|
275
|
-
`relu`, `sigmoid`, `tanh`, `softmax`, `gelu`, `swish`, `mish`, `leaky_relu`, `elu`, `selu`, `linear`
|
|
276
|
-
|
|
277
|
-
## API Reference
|
|
278
|
-
|
|
279
|
-
### Initialization
|
|
71
|
+
### 4. Transformer (LLM Context)
|
|
280
72
|
|
|
281
73
|
```typescript
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
74
|
+
// Create an MHA layer (Multi-Head Attention)
|
|
75
|
+
const tnet = welvet.createNetwork({
|
|
76
|
+
layers: [{ z: 0, y: 0, x: 0, l: 0, type: "MHA", d_model: 64, num_heads: 4 }]
|
|
77
|
+
});
|
|
286
78
|
|
|
287
|
-
//
|
|
288
|
-
|
|
79
|
+
// Wrap in Transformer context with pre-loaded weights
|
|
80
|
+
const model = welvet.createTransformer(tnet, embeds, lmHead, finalNorm);
|
|
81
|
+
const logits = model.forwardFull([1, 2, 3, 4]); // Direct token prefill
|
|
289
82
|
```
|
|
290
83
|
|
|
291
|
-
###
|
|
292
|
-
|
|
293
|
-
All Network methods follow the WASM calling convention:
|
|
294
|
-
- **Input:** JSON string of an array of parameters
|
|
295
|
-
- **Return:** JSON string of an array of results
|
|
84
|
+
### 5. NEAT Evolution
|
|
296
85
|
|
|
297
86
|
```typescript
|
|
298
|
-
|
|
299
|
-
const
|
|
87
|
+
const population = welvet.createNEATPopulation(net, 100);
|
|
88
|
+
const fitnesses = new Array(100).fill(1.0);
|
|
300
89
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
// Save model
|
|
305
|
-
const saved = network.SaveModelToString(JSON.stringify(["my-model"]));
|
|
90
|
+
population.evolveWithFitnesses(fitnesses);
|
|
91
|
+
console.log("Top Fitness:", population.bestFitness());
|
|
306
92
|
```
|
|
307
93
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
| Method | Parameters | Description |
|
|
311
|
-
|:-------|:-----------|:------------|
|
|
312
|
-
| `ForwardCPU` | `[inputs]` | CPU forward pass |
|
|
313
|
-
| `ForwardGPU` | `[inputs]` | GPU forward pass |
|
|
314
|
-
| `BackwardCPU` | `[gradients]` | CPU backward pass |
|
|
315
|
-
| `Train` | `[batches, config]` | Train network |
|
|
316
|
-
| `SaveModelToString` | `["modelID"]` | Save to JSON |
|
|
317
|
-
| `GetWeights` | `[row, col, layer]` | Get layer weights |
|
|
318
|
-
| `SetWeights` | `[row, col, layer, weights]` | Set layer weights |
|
|
319
|
-
| `GetBiases` | `[row, col, layer]` | Get layer biases |
|
|
320
|
-
| `SetBiases` | `[row, col, layer, biases]` | Set layer biases |
|
|
321
|
-
| `GetNetworkInfo` | `[]` | Get network info |
|
|
322
|
-
| `GetTotalParameters` | `[]` | Get parameter count |
|
|
323
|
-
| `Clone` | `[]` | Clone network |
|
|
324
|
-
| `TotalLayers` | `[]` | Get total layer count |
|
|
325
|
-
|
|
326
|
-
### Statistical Tools
|
|
327
|
-
|
|
328
|
-
```typescript
|
|
329
|
-
import welvet from "@openfluke/welvet";
|
|
330
|
-
|
|
331
|
-
// K-Means Clustering
|
|
332
|
-
const data = [[1, 1], [1.1, 1.1], [5, 5], [5.1, 5.1]];
|
|
333
|
-
const result = welvet.kmeans(data, 2, 100);
|
|
334
|
-
console.log(`Centroids: ${result.centroids}`);
|
|
335
|
-
console.log(`Silhouette Score: ${result.silhouette_score}`);
|
|
94
|
+
## Testing & Benchmarks
|
|
336
95
|
|
|
337
|
-
|
|
338
|
-
const matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
|
339
|
-
const corr = welvet.correlation(matrix);
|
|
340
|
-
console.log(`Pearson: ${corr.pearson}`);
|
|
341
|
-
```
|
|
96
|
+
The package includes a built-in TypeScript testing suite suitable for both CI and environment verification.
|
|
342
97
|
|
|
343
|
-
###
|
|
98
|
+
### Run tests in Node.js:
|
|
344
99
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
```typescript
|
|
348
|
-
const h1 = welvet.createKHandle(config);
|
|
349
|
-
const h2 = welvet.createKHandle(config);
|
|
350
|
-
|
|
351
|
-
const result = welvet.graft([h1, h2], "concat");
|
|
352
|
-
console.log(`Grafted: ${result.num_branches} branches`);
|
|
100
|
+
```bash
|
|
101
|
+
npm test
|
|
353
102
|
```
|
|
354
103
|
|
|
355
|
-
|
|
356
|
-
|
|
104
|
+
Or individual suites:
|
|
357
105
|
```bash
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
# Grid Scatter Multi-Agent
|
|
361
|
-
bun run grid-scatter.ts
|
|
362
|
-
|
|
363
|
-
# Stepping Training (LSTM)
|
|
364
|
-
bun run step_train_v3.ts
|
|
365
|
-
|
|
366
|
-
# Adaptation Benchmark (75 tests)
|
|
367
|
-
bun run test18_adaptation.ts
|
|
368
|
-
|
|
369
|
-
# Full Test Suite (77 tests)
|
|
370
|
-
bun run universal_test.ts
|
|
106
|
+
npm run test:cabi # Check WASM exports and functional smoke tests
|
|
107
|
+
npm run test:bench # Run layer-by-layer performance benchmarks
|
|
371
108
|
```
|
|
372
109
|
|
|
373
|
-
|
|
110
|
+
### Integrate tests into Frontend/React:
|
|
374
111
|
|
|
375
112
|
```typescript
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
layers_per_cell?: number;
|
|
381
|
-
layers: LayerConfig[];
|
|
382
|
-
dtype?: "float32" | "float64" | "int32" | "int16" | "int8" | "uint8";
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
interface TrainingConfig {
|
|
386
|
-
Epochs: number;
|
|
387
|
-
LearningRate: number;
|
|
388
|
-
LossType?: string;
|
|
389
|
-
Verbose?: boolean;
|
|
390
|
-
UseGPU?: boolean;
|
|
391
|
-
GradientClip?: number;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
interface TrainingBatch {
|
|
395
|
-
Input: number[];
|
|
396
|
-
Target: number[];
|
|
397
|
-
}
|
|
113
|
+
import { runVerify } from "@openfluke/welvet/tests/cabi_verify";
|
|
114
|
+
|
|
115
|
+
// Run benchmarks or verification logic directly in your app's lifecycle
|
|
116
|
+
await runVerify();
|
|
398
117
|
```
|
|
399
118
|
|
|
400
119
|
## License
|
|
401
120
|
|
|
402
121
|
Apache-2.0
|
|
403
|
-
|
|
404
|
-
## Links
|
|
405
|
-
|
|
406
|
-
- **GitHub**: [github.com/openfluke/loom](https://github.com/openfluke/loom)
|
|
407
|
-
- **NPM**: [@openfluke/welvet](https://www.npmjs.com/package/@openfluke/welvet)
|
|
408
|
-
- **PyPI**: [welvet](https://pypi.org/project/welvet/)
|
|
409
|
-
- **NuGet**: [Welvet](https://www.nuget.org/packages/Welvet)
|
|
410
|
-
- **Documentation**: [`docs/loom_assessment_comparison.md`](../docs/loom_assessment_comparison.md)
|