flockml 1.0.0 β 1.0.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 +72 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# FlockML π
|
|
2
|
+
|
|
3
|
+
**Decentralized, WebGPU-Accelerated Machine Learning in the Browser.**
|
|
4
|
+
|
|
5
|
+
FlockML allows you to train massive Machine Learning models (100M+ parameters) entirely in the background of your website visitors' browser tabs. It uses idle compute to create a free, decentralized supercomputer.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/flockml)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
## π₯ Features
|
|
11
|
+
- **WebGPU Native Acceleration:** Bypasses V8 JavaScript limits by executing matrix math directly on the user's GPU via TensorFlow.js.
|
|
12
|
+
- **Zero-Latency Payloads:** Uses Protocol Buffers and 8-bit quantization to compress network layer weights down to 91 bytes.
|
|
13
|
+
- **Differential Privacy:** Mathematically secures user data by injecting cryptographic Laplacian noise into gradients before they leave the browser.
|
|
14
|
+
- **Server-Side Anomaly Detection:** Instantly drops poisoned payloads (`NaN` injection, Sybil attacks) to protect the global model.
|
|
15
|
+
|
|
16
|
+
## π¦ Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm i flockml
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## π Quick Start
|
|
23
|
+
|
|
24
|
+
FlockML uses a **Federated Learning** architecture. You need a centralized Coordinator (Server) and Edge Nodes (Clients).
|
|
25
|
+
|
|
26
|
+
### 1. Initialize the Server Coordinator (Node.js)
|
|
27
|
+
The coordinator manages the global weights and runs the `FedAvg` aggregation algorithm.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { Coordinator } from 'flockml';
|
|
31
|
+
|
|
32
|
+
// Initialize a network with 2 inputs, 4 hidden nodes, 1 output
|
|
33
|
+
const coordinator = new Coordinator(2, 4, 1);
|
|
34
|
+
|
|
35
|
+
// Send these weights to your clients via WebSocket
|
|
36
|
+
const globalWeights = coordinator.getGlobalWeightsForBroadcast();
|
|
37
|
+
|
|
38
|
+
// When a client sends back an updated payload:
|
|
39
|
+
// coordinator.receiveUpdate(binaryPayload);
|
|
40
|
+
// coordinator.aggregate();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Run the Edge Node (Browser)
|
|
44
|
+
The edge node runs completely sandboxed in a Web Worker, utilizing WebGPU to train the model locally.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { FlockNode } from 'flockml';
|
|
48
|
+
|
|
49
|
+
// 1. Initialize the edge node
|
|
50
|
+
const node = new FlockNode(2, 4, 1);
|
|
51
|
+
|
|
52
|
+
// 2. Sync with the server's global weights
|
|
53
|
+
node.syncGlobalWeights(weights_ih, weights_ho, bias_h, bias_o);
|
|
54
|
+
|
|
55
|
+
// 3. Train on the user's local data
|
|
56
|
+
const inputs = [[0, 0], [0, 1], [1, 0], [1, 1]];
|
|
57
|
+
const targets = [[0], [1], [1], [0]];
|
|
58
|
+
node.trainLocalBatch(inputs, targets);
|
|
59
|
+
|
|
60
|
+
// 4. Export secure, quantized protobuf payload to send back to server
|
|
61
|
+
node.privacyEpsilon = 1.0; // Enable Differential Privacy
|
|
62
|
+
const binaryPayload = node.exportSecureGradients();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## π Documentation
|
|
66
|
+
For deep profiling reports, stress tests, and advanced architecture guides, visit the [official FlockML documentation](https://supratimdev.qzz.io/flock-ml).
|
|
67
|
+
|
|
68
|
+
## π‘οΈ Security
|
|
69
|
+
FlockML strictly executes inside isolated Web Workers, ensuring it has zero access to the DOM, cookies, `localStorage`, or the clientβs file system.
|
|
70
|
+
|
|
71
|
+
## π License
|
|
72
|
+
MIT License
|