@aleph-ai/tinyaleph 1.1.0 → 1.2.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/README.md +230 -2
- package/core/entanglement.js +712 -0
- package/core/events.js +907 -0
- package/core/hypercomplex.js +500 -0
- package/core/index.js +46 -0
- package/core/rformer-layers.js +811 -0
- package/docs/reference/01-core.md +515 -1
- package/docs/reference/02-physics.md +186 -1
- package/package.json +1 -1
- package/physics/index.js +46 -0
- package/physics/primeon_z_ladder_multi.js +669 -0
- package/physics/primeon_z_ladder_u.js +493 -0
- package/physics/stochastic-kuramoto.js +566 -0
package/README.md
CHANGED
|
@@ -10,14 +10,19 @@ A novel computational paradigm that encodes meaning as prime number signatures,
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
12
|
- **Prime Semantics**: Encode concepts as unique prime number signatures
|
|
13
|
-
- **Hypercomplex Algebra**: 16-dimensional sedenion space with non-commutative multiplication
|
|
13
|
+
- **Hypercomplex Algebra**: 16-dimensional sedenion space with non-commutative multiplication, exp/log/slerp
|
|
14
14
|
- **Oscillator Dynamics**: Kuramoto-model synchronization for coherent reasoning
|
|
15
|
+
- **Stochastic Dynamics**: Noise-robust Kuramoto with Langevin, colored, and thermal noise models
|
|
16
|
+
- **Prime Entanglement**: Graph-based tracking of prime relationships and co-occurrences
|
|
17
|
+
- **Event Streaming**: Real-time monitoring with EventEmitter pattern and async iteration
|
|
15
18
|
- **Entropy Minimization**: Reasoning as reduction of semantic uncertainty
|
|
16
19
|
- **Multiple Backends**: Semantic (NLP), Cryptographic (hashing), Scientific (quantum-inspired)
|
|
17
20
|
- **Formal Type System**: Typed term calculus with N(p)/A(p)/S types and ordering constraints
|
|
18
21
|
- **Reduction Semantics**: Strong normalization with prime-preserving operators
|
|
19
22
|
- **Lambda Translation**: Model-theoretic semantics via λ-calculus embedding
|
|
20
23
|
- **Enochian Vocabulary**: 21-letter angelic alphabet with prime basis and sedenion operations
|
|
24
|
+
- **ResoFormer Architecture**: Complete prime-indexed transformer with multi-head attention
|
|
25
|
+
- **Multi-Z Memory**: Hierarchical memory with fast/slow/permanent channels
|
|
21
26
|
|
|
22
27
|
## Installation
|
|
23
28
|
|
|
@@ -205,6 +210,103 @@ const multi = new MultiSystemCoupling([system1, system2, system3]);
|
|
|
205
210
|
console.log('Inter-system coherence:', multi.interSystemCoherence());
|
|
206
211
|
```
|
|
207
212
|
|
|
213
|
+
### Stochastic Kuramoto Models
|
|
214
|
+
|
|
215
|
+
Noise-robust synchronization with Langevin dynamics:
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
const {
|
|
219
|
+
StochasticKuramoto, // White noise Langevin dynamics
|
|
220
|
+
ColoredNoiseKuramoto, // Ornstein-Uhlenbeck noise
|
|
221
|
+
ThermalKuramoto // Temperature-dependent coupling
|
|
222
|
+
} = require('@aleph-ai/tinyaleph');
|
|
223
|
+
|
|
224
|
+
// White noise model
|
|
225
|
+
const stochastic = new StochasticKuramoto(frequencies, {
|
|
226
|
+
coupling: 0.5,
|
|
227
|
+
noiseIntensity: 0.1
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
stochastic.evolve(100, 0.01);
|
|
231
|
+
const { mean, stdDev } = stochastic.orderParameterWithUncertainty(50, 0.01);
|
|
232
|
+
|
|
233
|
+
// Colored noise (Ornstein-Uhlenbeck process)
|
|
234
|
+
const colored = new ColoredNoiseKuramoto(frequencies, {
|
|
235
|
+
correlationTime: 2.0,
|
|
236
|
+
noiseIntensity: 0.1
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Thermal model with temperature-dependent noise
|
|
240
|
+
const thermal = new ThermalKuramoto(frequencies, { temperature: 2.0 });
|
|
241
|
+
thermal.setTemperature(4.0); // Higher temp = more noise
|
|
242
|
+
const Tc = thermal.estimateCriticalTemperature();
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Prime Entanglement Graph
|
|
246
|
+
|
|
247
|
+
Track prime relationships from co-occurrence and resonance:
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
const { PrimeEntanglementGraph } = require('@aleph-ai/tinyaleph');
|
|
251
|
+
|
|
252
|
+
const graph = new PrimeEntanglementGraph([2, 3, 5, 7, 11]);
|
|
253
|
+
|
|
254
|
+
// Record co-occurrences
|
|
255
|
+
graph.observe([2, 3], [5, 7], 0.8);
|
|
256
|
+
graph.observe([5, 7], [11], 0.6);
|
|
257
|
+
|
|
258
|
+
// Query relationships
|
|
259
|
+
const neighbors = graph.neighbors(7, 2); // 2-hop neighborhood
|
|
260
|
+
const path = graph.shortestPath(2, 11);
|
|
261
|
+
|
|
262
|
+
// Graph metrics
|
|
263
|
+
const cc = graph.clusteringCoefficient(5);
|
|
264
|
+
const stats = graph.stats();
|
|
265
|
+
|
|
266
|
+
// Convert to Kuramoto network
|
|
267
|
+
const adjacency = graph.toAdjacencyMatrix([2, 3, 5, 7, 11]);
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Event-Driven Streaming
|
|
271
|
+
|
|
272
|
+
Real-time monitoring and async iteration:
|
|
273
|
+
|
|
274
|
+
```javascript
|
|
275
|
+
const {
|
|
276
|
+
AlephEventEmitter,
|
|
277
|
+
AlephMonitor,
|
|
278
|
+
EvolutionStream
|
|
279
|
+
} = require('@aleph-ai/tinyaleph');
|
|
280
|
+
|
|
281
|
+
// Event emitter with throttling
|
|
282
|
+
const emitter = new AlephEventEmitter();
|
|
283
|
+
emitter.throttle('tick', 100); // Max once per 100ms
|
|
284
|
+
|
|
285
|
+
emitter.on('collapse', ({ from, to, probability }) => {
|
|
286
|
+
console.log(`Collapsed with p=${probability}`);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
emitter.on('sync', ({ orderParameter }) => {
|
|
290
|
+
console.log(`Synchronized: r=${orderParameter}`);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Promise-based waiting
|
|
294
|
+
const data = await emitter.waitFor('ready', 5000);
|
|
295
|
+
|
|
296
|
+
// Async iteration over evolution
|
|
297
|
+
const stream = EvolutionStream.fromEvolvable(kuramoto);
|
|
298
|
+
|
|
299
|
+
for await (const state of stream.take(100)) {
|
|
300
|
+
console.log(state.orderParameter);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Stream operators
|
|
304
|
+
const filtered = stream
|
|
305
|
+
.filter(s => s.entropy < 2.0)
|
|
306
|
+
.map(s => s.orderParameter)
|
|
307
|
+
.take(50);
|
|
308
|
+
```
|
|
309
|
+
|
|
208
310
|
### Entropy and Stability
|
|
209
311
|
|
|
210
312
|
```javascript
|
|
@@ -218,6 +320,96 @@ const lambda = estimateLyapunov(entropyTimeSeries);
|
|
|
218
320
|
console.log('Stable:', lambda < 0);
|
|
219
321
|
```
|
|
220
322
|
|
|
323
|
+
### Hypercomplex Algebra Extensions
|
|
324
|
+
|
|
325
|
+
Extended operations for smooth interpolation and rotations:
|
|
326
|
+
|
|
327
|
+
```javascript
|
|
328
|
+
const { Hypercomplex } = require('@aleph-ai/tinyaleph');
|
|
329
|
+
|
|
330
|
+
const q1 = Hypercomplex.fromArray([1, 0, 0, 0]);
|
|
331
|
+
const q2 = Hypercomplex.fromAxisAngle(4, [0, 0, 1], Math.PI/2);
|
|
332
|
+
|
|
333
|
+
// Exponential and logarithm
|
|
334
|
+
const expQ = q1.exp();
|
|
335
|
+
const logQ = q2.log();
|
|
336
|
+
|
|
337
|
+
// Smooth interpolation (slerp)
|
|
338
|
+
for (let t = 0; t <= 1; t += 0.1) {
|
|
339
|
+
const interpolated = q1.slerp(q2, t);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Rotation operations
|
|
343
|
+
const rotated = q2.sandwich(vector);
|
|
344
|
+
const axis = q2.toAxisAngle();
|
|
345
|
+
|
|
346
|
+
// Power operations
|
|
347
|
+
const squared = q1.pow(2);
|
|
348
|
+
const cubed = q1.powInt(3);
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Multi-Z Channel Primeon Ladder
|
|
352
|
+
|
|
353
|
+
Hierarchical memory with different decay rates:
|
|
354
|
+
|
|
355
|
+
```javascript
|
|
356
|
+
const { PrimeonZLadderMulti, createAdiabaticSchedule } = require('@aleph-ai/tinyaleph');
|
|
357
|
+
|
|
358
|
+
const ladder = new PrimeonZLadderMulti({
|
|
359
|
+
N: 32,
|
|
360
|
+
zChannels: [
|
|
361
|
+
{ name: 'fast', dz: 1, leak: 0.2, decay: 0.1 },
|
|
362
|
+
{ name: 'slow', dz: 1, leak: 0.01, decay: 0.001 },
|
|
363
|
+
{ name: 'permanent', dz: 1, leak: 0.0, decay: 0.0 }
|
|
364
|
+
],
|
|
365
|
+
J: 0.25
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// Per-channel metrics
|
|
369
|
+
const metrics = ladder.channelMetrics();
|
|
370
|
+
console.log('Fast entropy:', metrics.fast.entropy);
|
|
371
|
+
console.log('Slow Z-flux:', metrics.slow.totalFlux);
|
|
372
|
+
|
|
373
|
+
// Adiabatic parameter schedules
|
|
374
|
+
const Jt = createAdiabaticSchedule(0.1, 0.5, 100, 'sinusoidal');
|
|
375
|
+
const ladder2 = new PrimeonZLadderMulti({ N: 16, Jt });
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### ResoFormer Architecture
|
|
379
|
+
|
|
380
|
+
Complete prime-indexed transformer:
|
|
381
|
+
|
|
382
|
+
```javascript
|
|
383
|
+
const {
|
|
384
|
+
ResoFormer,
|
|
385
|
+
ResoFormerBlock,
|
|
386
|
+
ResonantMultiHeadAttention,
|
|
387
|
+
PrimeFFN,
|
|
388
|
+
SparsePrimeState
|
|
389
|
+
} = require('@aleph-ai/tinyaleph');
|
|
390
|
+
|
|
391
|
+
// Create sparse prime states
|
|
392
|
+
const state1 = SparsePrimeState.fromPrimes([2, 3, 5]);
|
|
393
|
+
const state2 = SparsePrimeState.fromPrimes([7, 11, 13]);
|
|
394
|
+
|
|
395
|
+
// Multi-head attention
|
|
396
|
+
const attention = new ResonantMultiHeadAttention({
|
|
397
|
+
numHeads: 8,
|
|
398
|
+
numPrimes: 4096
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
const result = attention.forward(state1, [state2], [state2]);
|
|
402
|
+
|
|
403
|
+
// Full ResoFormer model
|
|
404
|
+
const model = new ResoFormer({
|
|
405
|
+
numLayers: 6,
|
|
406
|
+
numHeads: 8,
|
|
407
|
+
hiddenDim: 256
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
const outputs = model.forward([state1, state2]);
|
|
411
|
+
```
|
|
412
|
+
|
|
221
413
|
## Formal Semantics
|
|
222
414
|
|
|
223
415
|
### Typed Term Calculus
|
|
@@ -349,7 +541,7 @@ console.log(CORE_VOCABULARY['ZORGE']); // "be friendly unto"
|
|
|
349
541
|
| `SemanticBackend` | Natural language processing |
|
|
350
542
|
| `CryptographicBackend` | Hashing and key derivation |
|
|
351
543
|
| `ScientificBackend` | Quantum-inspired computation |
|
|
352
|
-
| `Hypercomplex` | Sedenion algebra |
|
|
544
|
+
| `Hypercomplex` | Sedenion algebra with exp/log/slerp |
|
|
353
545
|
| `Oscillator` / `OscillatorBank` | Phase-amplitude oscillators |
|
|
354
546
|
| `KuramotoModel` | Coupled oscillator synchronization |
|
|
355
547
|
| `NetworkKuramoto` | Topology-aware coupling |
|
|
@@ -357,6 +549,16 @@ console.log(CORE_VOCABULARY['ZORGE']); // "be friendly unto"
|
|
|
357
549
|
| `SakaguchiKuramoto` | Phase frustration / chimera states |
|
|
358
550
|
| `SmallWorldKuramoto` | Watts-Strogatz topology |
|
|
359
551
|
| `MultiSystemCoupling` | Cross-system synchronization |
|
|
552
|
+
| `StochasticKuramoto` | Langevin noise dynamics |
|
|
553
|
+
| `ColoredNoiseKuramoto` | Ornstein-Uhlenbeck noise |
|
|
554
|
+
| `ThermalKuramoto` | Temperature-dependent coupling |
|
|
555
|
+
| `PrimeEntanglementGraph` | Prime relationship tracking |
|
|
556
|
+
| `AlephEventEmitter` | Event-driven monitoring |
|
|
557
|
+
| `AlephMonitor` | Engine state monitoring |
|
|
558
|
+
| `EvolutionStream` | Async iteration over evolution |
|
|
559
|
+
| `PrimeonZLadderMulti` | Multi-channel Z memory |
|
|
560
|
+
| `ResoFormer` | Prime-indexed transformer |
|
|
561
|
+
| `SparsePrimeState` | Sparse prime activations |
|
|
360
562
|
| `hash(input)` | Quick semantic hash |
|
|
361
563
|
| `deriveKey(pass, salt)` | Quick key derivation |
|
|
362
564
|
|
|
@@ -395,6 +597,32 @@ const backends = require('@aleph-ai/tinyaleph/backends');
|
|
|
395
597
|
const engine = require('@aleph-ai/tinyaleph/engine');
|
|
396
598
|
```
|
|
397
599
|
|
|
600
|
+
### New Physics Exports
|
|
601
|
+
|
|
602
|
+
| Export | Description |
|
|
603
|
+
|--------|-------------|
|
|
604
|
+
| `StochasticKuramoto` | White noise Langevin dynamics |
|
|
605
|
+
| `ColoredNoiseKuramoto` | Ornstein-Uhlenbeck colored noise |
|
|
606
|
+
| `ThermalKuramoto` | Temperature-dependent coupling |
|
|
607
|
+
| `PrimeonZLadderMulti` | Hierarchical Z memory channels |
|
|
608
|
+
| `createAdiabaticSchedule` | Parameter sweep schedules |
|
|
609
|
+
|
|
610
|
+
### New Core Exports
|
|
611
|
+
|
|
612
|
+
| Export | Description |
|
|
613
|
+
|--------|-------------|
|
|
614
|
+
| `PrimeEntanglementGraph` | Prime co-occurrence tracking |
|
|
615
|
+
| `AlephEventEmitter` | Event pub/sub system |
|
|
616
|
+
| `AlephMonitor` | Engine monitoring wrapper |
|
|
617
|
+
| `EvolutionStream` | Async iteration for dynamics |
|
|
618
|
+
| `ResoFormer` | Full transformer model |
|
|
619
|
+
| `ResoFormerBlock` | Single transformer block |
|
|
620
|
+
| `ResonantMultiHeadAttention` | Multi-head attention |
|
|
621
|
+
| `PrimeFFN` | Feed-forward network |
|
|
622
|
+
| `PrimeLayerNorm` | Prime-preserving normalization |
|
|
623
|
+
| `PositionalPrimeEncoding` | Position as prime phases |
|
|
624
|
+
| `SparsePrimeState` | Sparse activation storage |
|
|
625
|
+
|
|
398
626
|
## Documentation
|
|
399
627
|
|
|
400
628
|
Full documentation is available in the `docs/` directory:
|