@seanhogg/builderforce-memory-engine 2026.6.20 → 2026.6.27
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/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/kernels/limbic_affect.d.ts +2 -0
- package/dist/kernels/limbic_affect.d.ts.map +1 -0
- package/dist/kernels/limbic_affect.js +74 -0
- package/dist/kernels/limbic_affect.js.map +1 -0
- package/dist/limbic/index.d.ts +14 -0
- package/dist/limbic/index.d.ts.map +1 -0
- package/dist/limbic/index.js +11 -0
- package/dist/limbic/index.js.map +1 -0
- package/dist/limbic/limbic_model.d.ts +111 -0
- package/dist/limbic/limbic_model.d.ts.map +1 -0
- package/dist/limbic/limbic_model.js +299 -0
- package/dist/limbic/limbic_model.js.map +1 -0
- package/dist/limbic/limbic_trainer.d.ts +62 -0
- package/dist/limbic/limbic_trainer.d.ts.map +1 -0
- package/dist/limbic/limbic_trainer.js +172 -0
- package/dist/limbic/limbic_trainer.js.map +1 -0
- package/dist/limbic/regions.d.ts +79 -0
- package/dist/limbic/regions.d.ts.map +1 -0
- package/dist/limbic/regions.js +132 -0
- package/dist/limbic/regions.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +31 -0
- package/src/kernels/limbic_affect.ts +74 -0
- package/src/limbic/index.ts +28 -0
- package/src/limbic/limbic_model.ts +373 -0
- package/src/limbic/limbic_trainer.ts +253 -0
- package/src/limbic/regions.ts +141 -0
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export { ACTIVATIONS_WGSL, ACTIVATIONS_BACKWARD_WGSL, SOFTMAX_FORWARD_WGSL, SOFT
|
|
|
27
27
|
export { SSD_FORWARD_WGSL, SSD_BACKWARD_WGSL } from './kernels/ssd.js';
|
|
28
28
|
export { COMPLEX_SSD_FORWARD_WGSL, COMPLEX_SSD_BACKWARD_WGSL } from './kernels/complex_ssd.js';
|
|
29
29
|
export { ATTENTION_FORWARD_WGSL, ATTENTION_BACKWARD_WGSL, SOFTMAX_WGSL } from './kernels/attention.js';
|
|
30
|
+
export { REGION, LIMBIC_DIM, LIMBIC_DIM_NAMES, LIMBIC_STATE_DIM, LIMBIC_BOUNDS, NEUTRAL_STATE, clampDim, clampState, neutralState, stateToRecord, recordToState, LimbicModel, DEFAULT_LIMBIC_CONFIG, DEFAULT_LIMBIC_SEED, LimbicTrainer, } from './limbic/index.js';
|
|
31
|
+
export type { Region, LimbicDimName, LimbicModelConfig, LimbicForward, LimbicParam, LimbicSample, LimbicTrainOptions, } from './limbic/index.js';
|
|
32
|
+
export { LIMBIC_AFFECT_WGSL } from './kernels/limbic_affect.js';
|
|
30
33
|
export declare const VERSION = "2.0.0";
|
|
31
34
|
export declare const DESCRIPTION = "MambaCode.js: WebGPU-accelerated Mamba-1/2/3 and Hybrid SSM for browser code models";
|
|
32
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAE,MAAQ,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAQ,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAQ,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACH,MAAM,EACN,QAAQ,EACR,UAAU,EACV,MAAM,EACN,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACnB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C,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAC/D,wBAAwB,CAAC;AAIlC,OAAO,EACH,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,GAChB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACR,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIhE,eAAO,MAAM,OAAO,UAAc,CAAC;AACnC,eAAO,MAAM,WAAW,wFAAwF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,9 @@ export { SSD_FORWARD_WGSL, SSD_BACKWARD_WGSL } from './kernels/ssd.js';
|
|
|
34
34
|
export { COMPLEX_SSD_FORWARD_WGSL, COMPLEX_SSD_BACKWARD_WGSL } from './kernels/complex_ssd.js';
|
|
35
35
|
// Attention kernels
|
|
36
36
|
export { ATTENTION_FORWARD_WGSL, ATTENTION_BACKWARD_WGSL, SOFTMAX_WGSL } from './kernels/attention.js';
|
|
37
|
+
// ── Limbic system (trainable affective dynamics) ──────────────────────────────
|
|
38
|
+
export { REGION, LIMBIC_DIM, LIMBIC_DIM_NAMES, LIMBIC_STATE_DIM, LIMBIC_BOUNDS, NEUTRAL_STATE, clampDim, clampState, neutralState, stateToRecord, recordToState, LimbicModel, DEFAULT_LIMBIC_CONFIG, DEFAULT_LIMBIC_SEED, LimbicTrainer, } from './limbic/index.js';
|
|
39
|
+
export { LIMBIC_AFFECT_WGSL } from './kernels/limbic_affect.js';
|
|
37
40
|
// ── Version ───────────────────────────────────────────────────────────────────
|
|
38
41
|
export const VERSION = '2.0.0';
|
|
39
42
|
export const DESCRIPTION = 'MambaCode.js: WebGPU-accelerated Mamba-1/2/3 and Hybrid SSM for browser code models';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,iFAAiF;AAEjF,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,oBAAoB;AACpB,OAAO,EAAE,WAAW,EAAE,MAAQ,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAQ,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAQ,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,iFAAiF;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACH,MAAM,EACN,QAAQ,EACR,UAAU,EACV,MAAM,EACN,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,wBAAwB,CAAC;AAEhC,iFAAiF;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,iFAAiF;AAEjF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkB9E,iFAAiF;AAEjF,OAAO,EACH,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,UAAU,EACV,YAAY,EACZ,IAAI,GACP,MAAM,sBAAsB,CAAC;AAE9B,iFAAiF;AAEjF,OAAO,EACH,YAAY,EACZ,cAAc,EACd,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAc,EACd,sBAAsB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ACrC,kBAAkB,CAAC;AAE5B,8BAA8B;AAC9B,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MACrD,0BAA0B,CAAC;AAEpC,oBAAoB;AACpB,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAC/D,wBAAwB,CAAC;AAElC,iFAAiF;AAEjF,OAAO,EACH,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,GAChB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,iFAAiF;AAEjF,MAAM,CAAC,MAAM,OAAO,GAAO,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,WAAW,GAAG,qFAAqF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limbic_affect.d.ts","sourceRoot":"","sources":["../../src/kernels/limbic_affect.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,kBAAkB,EAAE,MAwDhC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Limbic Affect WGSL Kernel
|
|
2
|
+
//
|
|
3
|
+
// One forward step of the limbic model's recurrent affect core, run on the GPU.
|
|
4
|
+
// Given the previous hidden state, previous affective state, and an experience
|
|
5
|
+
// embedding, it produces the next hidden state and a bounded affect *delta*.
|
|
6
|
+
//
|
|
7
|
+
// This mirrors the CPU reference in limbic/limbic_model.ts exactly (same math):
|
|
8
|
+
// pre[j] = Σ_i Win[j,i]·x[i] + Σ_k Ws[j,k]·s[k]
|
|
9
|
+
// a[j] = sigmoid(A[j]) // per-channel recurrence gate
|
|
10
|
+
// h'[j] = a[j]·h[j] + (1-a[j])·tanh(pre[j]) // SSM-style leak/input
|
|
11
|
+
// Δ[k] = tanh( Σ_j Wout[k,j]·h'[j] + b[k] ) // bounded affect change
|
|
12
|
+
//
|
|
13
|
+
// hidden_dim is assumed ≤ 64 (the limbic head is tiny — the heavy lifting is in
|
|
14
|
+
// the hippocampus SSM that produces the experience embedding). Reward is NOT
|
|
15
|
+
// computed here: it is only needed during training, which runs the CPU backward
|
|
16
|
+
// path; the per-turn inference step only needs Δ and the next hidden state.
|
|
17
|
+
export const LIMBIC_AFFECT_WGSL = /* wgsl */ `
|
|
18
|
+
|
|
19
|
+
struct Dims {
|
|
20
|
+
input_dim : u32,
|
|
21
|
+
hidden_dim : u32,
|
|
22
|
+
state_dim : u32,
|
|
23
|
+
_pad : u32,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
@group(0) @binding(0) var<uniform> dims : Dims;
|
|
27
|
+
@group(0) @binding(1) var<storage, read> win : array<f32>; // hidden*input
|
|
28
|
+
@group(0) @binding(2) var<storage, read> ws : array<f32>; // hidden*state
|
|
29
|
+
@group(0) @binding(3) var<storage, read> a_logit : array<f32>; // hidden
|
|
30
|
+
@group(0) @binding(4) var<storage, read> wout_state : array<f32>; // state*hidden
|
|
31
|
+
@group(0) @binding(5) var<storage, read> bout_state : array<f32>; // state
|
|
32
|
+
@group(0) @binding(6) var<storage, read> x_in : array<f32>; // input
|
|
33
|
+
@group(0) @binding(7) var<storage, read> h_prev : array<f32>; // hidden
|
|
34
|
+
@group(0) @binding(8) var<storage, read> s_prev : array<f32>; // state
|
|
35
|
+
@group(0) @binding(9) var<storage, read_write> h_out : array<f32>; // hidden
|
|
36
|
+
@group(0) @binding(10) var<storage, read_write> delta_out : array<f32>; // state
|
|
37
|
+
|
|
38
|
+
var<workgroup> hbuf : array<f32, 64>;
|
|
39
|
+
|
|
40
|
+
// Single-workgroup dispatch: (1, 1, 1) with workgroup_size 64.
|
|
41
|
+
@compute @workgroup_size(64, 1, 1)
|
|
42
|
+
fn affect_step(
|
|
43
|
+
@builtin(local_invocation_id) lid : vec3<u32>,
|
|
44
|
+
) {
|
|
45
|
+
let j = lid.x;
|
|
46
|
+
|
|
47
|
+
// Pass 1: recurrent hidden update (one thread per hidden channel).
|
|
48
|
+
if (j < dims.hidden_dim) {
|
|
49
|
+
var pre : f32 = 0.0;
|
|
50
|
+
for (var i : u32 = 0u; i < dims.input_dim; i = i + 1u) {
|
|
51
|
+
pre = pre + win[j * dims.input_dim + i] * x_in[i];
|
|
52
|
+
}
|
|
53
|
+
for (var k : u32 = 0u; k < dims.state_dim; k = k + 1u) {
|
|
54
|
+
pre = pre + ws[j * dims.state_dim + k] * s_prev[k];
|
|
55
|
+
}
|
|
56
|
+
let a = 1.0 / (1.0 + exp(-a_logit[j]));
|
|
57
|
+
let hn = a * h_prev[j] + (1.0 - a) * tanh(pre);
|
|
58
|
+
hbuf[j] = hn;
|
|
59
|
+
h_out[j] = hn;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
workgroupBarrier();
|
|
63
|
+
|
|
64
|
+
// Pass 2: bounded affect delta (one thread per state dim).
|
|
65
|
+
if (j < dims.state_dim) {
|
|
66
|
+
var acc : f32 = bout_state[j];
|
|
67
|
+
for (var m : u32 = 0u; m < dims.hidden_dim; m = m + 1u) {
|
|
68
|
+
acc = acc + wout_state[j * dims.hidden_dim + m] * hbuf[m];
|
|
69
|
+
}
|
|
70
|
+
delta_out[j] = tanh(acc);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
//# sourceMappingURL=limbic_affect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limbic_affect.js","sourceRoot":"","sources":["../../src/kernels/limbic_affect.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,EAAE;AACF,gFAAgF;AAChF,mDAAmD;AACnD,iFAAiF;AACjF,0EAA0E;AAC1E,2EAA2E;AAC3E,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,gFAAgF;AAChF,4EAA4E;AAE5E,MAAM,CAAC,MAAM,kBAAkB,GAAW,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDpD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limbic system – trainable affective/motivational dynamics for agents.
|
|
3
|
+
*
|
|
4
|
+
* The dynamic counterpart to the (static) psychometric personality: where
|
|
5
|
+
* personality sets the homeostatic setpoints, the limbic model learns — in
|
|
6
|
+
* WebGPU — how an agent's affective state moves in response to experience.
|
|
7
|
+
*/
|
|
8
|
+
export { REGION, LIMBIC_DIM, LIMBIC_DIM_NAMES, LIMBIC_STATE_DIM, LIMBIC_BOUNDS, NEUTRAL_STATE, clampDim, clampState, neutralState, stateToRecord, recordToState, } from "./regions.js";
|
|
9
|
+
export type { Region, LimbicDimName } from "./regions.js";
|
|
10
|
+
export { LimbicModel, DEFAULT_LIMBIC_CONFIG, DEFAULT_LIMBIC_SEED } from "./limbic_model.js";
|
|
11
|
+
export type { LimbicModelConfig, LimbicForward, LimbicParam } from "./limbic_model.js";
|
|
12
|
+
export { LimbicTrainer } from "./limbic_trainer.js";
|
|
13
|
+
export type { LimbicSample, LimbicTrainOptions } from "./limbic_trainer.js";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/limbic/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5F,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limbic system – trainable affective/motivational dynamics for agents.
|
|
3
|
+
*
|
|
4
|
+
* The dynamic counterpart to the (static) psychometric personality: where
|
|
5
|
+
* personality sets the homeostatic setpoints, the limbic model learns — in
|
|
6
|
+
* WebGPU — how an agent's affective state moves in response to experience.
|
|
7
|
+
*/
|
|
8
|
+
export { REGION, LIMBIC_DIM, LIMBIC_DIM_NAMES, LIMBIC_STATE_DIM, LIMBIC_BOUNDS, NEUTRAL_STATE, clampDim, clampState, neutralState, stateToRecord, recordToState, } from "./regions.js";
|
|
9
|
+
export { LimbicModel, DEFAULT_LIMBIC_CONFIG, DEFAULT_LIMBIC_SEED } from "./limbic_model.js";
|
|
10
|
+
export { LimbicTrainer } from "./limbic_trainer.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/limbic/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG5F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* limbic_model.ts – LimbicModel: a small, trainable recurrent affect head.
|
|
3
|
+
*
|
|
4
|
+
* The limbic model learns the *dynamics* of an agent's affective/motivational
|
|
5
|
+
* state. Given an experience embedding (produced upstream by the hippocampus
|
|
6
|
+
* SSM) and the current affective state, it predicts:
|
|
7
|
+
* • a bounded affect *delta* (how valence/arousal/drives/attention/exploration
|
|
8
|
+
* should move in response to this experience), and
|
|
9
|
+
* • a scalar *reward* prediction (how good/bad this experience was).
|
|
10
|
+
*
|
|
11
|
+
* Architecture (intentionally tiny — the heavy representation work happens in
|
|
12
|
+
* the hippocampus; this head just maps representation → affect):
|
|
13
|
+
*
|
|
14
|
+
* pre[j] = Σ_i Win[j,i]·x[i] + Σ_k Ws[j,k]·s[k] (hidden pre-activation)
|
|
15
|
+
* a[j] = sigmoid(A[j]) (per-channel SSM gate)
|
|
16
|
+
* h'[j] = a[j]·h[j] + (1-a[j])·tanh(pre[j]) (recurrent leak/input)
|
|
17
|
+
* Δ[k] = tanh( Σ_j Wout[k,j]·h'[j] + b[k] ) (bounded affect delta)
|
|
18
|
+
* r = Σ_j Wr[j]·h'[j] + br (reward prediction)
|
|
19
|
+
*
|
|
20
|
+
* It runs on WebGPU (per-turn `step()` via {@link LIMBIC_AFFECT_WGSL}, and the
|
|
21
|
+
* AdamW optimiser via the shared WEIGHT_UPDATE_WGSL kernel during training) with
|
|
22
|
+
* a numerically-identical pure-CPU reference path used when no GPUDevice is
|
|
23
|
+
* available — the same WebGPU-or-fallback contract the rest of the engine uses.
|
|
24
|
+
*
|
|
25
|
+
* Training uses truncated BPTT(1): the recurrent state is carried forward across
|
|
26
|
+
* a sequence, but each step's gradient treats the incoming hidden state as a
|
|
27
|
+
* constant. For an affect head this is stable and sufficient — each
|
|
28
|
+
* (experience, state) → affect pair is close to an independent regression.
|
|
29
|
+
*/
|
|
30
|
+
export interface LimbicModelConfig {
|
|
31
|
+
/** Experience-embedding dimension (input). Default 32. */
|
|
32
|
+
inputDim: number;
|
|
33
|
+
/** Hidden recurrent width. Must be ≤ 64 (the GPU kernel's workgroup size). Default 16. */
|
|
34
|
+
hiddenDim: number;
|
|
35
|
+
/** Affective state dimension. Default {@link LIMBIC_STATE_DIM} (8). */
|
|
36
|
+
stateDim: number;
|
|
37
|
+
/** Deterministic init seed for reproducible cold-start weights. */
|
|
38
|
+
seed?: number;
|
|
39
|
+
/** Weight of the reward-prediction term in the training loss. Default 0.5. */
|
|
40
|
+
rewardWeight?: number;
|
|
41
|
+
}
|
|
42
|
+
export declare const DEFAULT_LIMBIC_CONFIG: Required<Omit<LimbicModelConfig, "seed">>;
|
|
43
|
+
/** Result of a single forward step. */
|
|
44
|
+
export interface LimbicForward {
|
|
45
|
+
/** Next hidden recurrent state (length hiddenDim). */
|
|
46
|
+
hidden: Float32Array;
|
|
47
|
+
/** Bounded affect delta in (-1, 1) per state dim (length stateDim). */
|
|
48
|
+
delta: Float32Array;
|
|
49
|
+
/** Reward prediction (scalar). */
|
|
50
|
+
reward: number;
|
|
51
|
+
}
|
|
52
|
+
/** A named trainable parameter tensor (flat row-major Float32Array). */
|
|
53
|
+
export interface LimbicParam {
|
|
54
|
+
name: string;
|
|
55
|
+
data: Float32Array;
|
|
56
|
+
numel: number;
|
|
57
|
+
}
|
|
58
|
+
/** Fixed default init seed — reproducible byte-identical cold start across machines. */
|
|
59
|
+
export declare const DEFAULT_LIMBIC_SEED = 296863214;
|
|
60
|
+
export declare class LimbicModel {
|
|
61
|
+
readonly config: Required<Omit<LimbicModelConfig, "seed">>;
|
|
62
|
+
win: Float32Array;
|
|
63
|
+
ws: Float32Array;
|
|
64
|
+
aLogit: Float32Array;
|
|
65
|
+
woutState: Float32Array;
|
|
66
|
+
boutState: Float32Array;
|
|
67
|
+
woutReward: Float32Array;
|
|
68
|
+
boutReward: Float32Array;
|
|
69
|
+
private gWin;
|
|
70
|
+
private gWs;
|
|
71
|
+
private gALogit;
|
|
72
|
+
private gWoutState;
|
|
73
|
+
private gBoutState;
|
|
74
|
+
private gWoutReward;
|
|
75
|
+
private gBoutReward;
|
|
76
|
+
constructor(config?: Partial<LimbicModelConfig>);
|
|
77
|
+
/** Trainable parameters, in the canonical checkpoint order. */
|
|
78
|
+
parameters(): LimbicParam[];
|
|
79
|
+
/** Gradient buffers, index-aligned with {@link parameters}. */
|
|
80
|
+
gradients(): LimbicParam[];
|
|
81
|
+
zeroGrad(): void;
|
|
82
|
+
/** A fresh zeroed hidden state. */
|
|
83
|
+
initHidden(): Float32Array;
|
|
84
|
+
/**
|
|
85
|
+
* One forward step (CPU reference). Pure — does not mutate the model or the
|
|
86
|
+
* inputs. The GPU kernel path produces numerically-identical results.
|
|
87
|
+
*/
|
|
88
|
+
forward(x: ArrayLike<number>, hPrev: ArrayLike<number>, sPrev: ArrayLike<number>): LimbicForward;
|
|
89
|
+
private _forwardCached;
|
|
90
|
+
/**
|
|
91
|
+
* Accumulate gradients for one (input, state) → (deltaTarget, rewardTarget)
|
|
92
|
+
* sample using truncated BPTT(1). Returns the scalar loss for this step and
|
|
93
|
+
* the next hidden state to carry forward. Call {@link zeroGrad} before a batch
|
|
94
|
+
* and apply the optimiser after.
|
|
95
|
+
*/
|
|
96
|
+
backwardStep(x: ArrayLike<number>, hPrev: ArrayLike<number>, sPrev: ArrayLike<number>, deltaTarget: ArrayLike<number>, rewardTarget: number): {
|
|
97
|
+
loss: number;
|
|
98
|
+
hidden: Float32Array;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Serialise weights to a compact "LMBC" binary. fp16 (v2) halves the size at
|
|
102
|
+
* ~0.5% precision cost; f32 (v1) is exact. Layout: magic, version, [inputDim,
|
|
103
|
+
* hiddenDim, stateDim], then params in {@link parameters} order.
|
|
104
|
+
*/
|
|
105
|
+
exportWeights(opts?: {
|
|
106
|
+
fp16?: boolean;
|
|
107
|
+
}): ArrayBuffer;
|
|
108
|
+
/** Load weights from an "LMBC" binary. Validates magic + dims. */
|
|
109
|
+
loadWeights(buffer: ArrayBuffer): void;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=limbic_model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limbic_model.d.ts","sourceRoot":"","sources":["../../src/limbic/limbic_model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAMH,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,0FAA0F;IAC1F,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAK3E,CAAC;AAEF,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,MAAM,EAAE,YAAY,CAAC;IACrB,uEAAuE;IACvE,KAAK,EAAE,YAAY,CAAC;IACpB,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAcD,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAID,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,YAAa,CAAC;AAM9C,qBAAa,WAAW;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;IAG3D,GAAG,EAAE,YAAY,CAAC;IAClB,EAAE,EAAE,YAAY,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,YAAY,CAAC;IACxB,SAAS,EAAE,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a small, trainable recurrent affect head.
|
|
3
|
+
*
|
|
4
|
+
* The limbic model learns the *dynamics* of an agent's affective/motivational
|
|
5
|
+
* state. Given an experience embedding (produced upstream by the hippocampus
|
|
6
|
+
* SSM) and the current affective state, it predicts:
|
|
7
|
+
* • a bounded affect *delta* (how valence/arousal/drives/attention/exploration
|
|
8
|
+
* should move in response to this experience), and
|
|
9
|
+
* • a scalar *reward* prediction (how good/bad this experience was).
|
|
10
|
+
*
|
|
11
|
+
* Architecture (intentionally tiny — the heavy representation work happens in
|
|
12
|
+
* the hippocampus; this head just maps representation → affect):
|
|
13
|
+
*
|
|
14
|
+
* pre[j] = Σ_i Win[j,i]·x[i] + Σ_k Ws[j,k]·s[k] (hidden pre-activation)
|
|
15
|
+
* a[j] = sigmoid(A[j]) (per-channel SSM gate)
|
|
16
|
+
* h'[j] = a[j]·h[j] + (1-a[j])·tanh(pre[j]) (recurrent leak/input)
|
|
17
|
+
* Δ[k] = tanh( Σ_j Wout[k,j]·h'[j] + b[k] ) (bounded affect delta)
|
|
18
|
+
* r = Σ_j Wr[j]·h'[j] + br (reward prediction)
|
|
19
|
+
*
|
|
20
|
+
* It runs on WebGPU (per-turn `step()` via {@link LIMBIC_AFFECT_WGSL}, and the
|
|
21
|
+
* AdamW optimiser via the shared WEIGHT_UPDATE_WGSL kernel during training) with
|
|
22
|
+
* a numerically-identical pure-CPU reference path used when no GPUDevice is
|
|
23
|
+
* available — the same WebGPU-or-fallback contract the rest of the engine uses.
|
|
24
|
+
*
|
|
25
|
+
* Training uses truncated BPTT(1): the recurrent state is carried forward across
|
|
26
|
+
* a sequence, but each step's gradient treats the incoming hidden state as a
|
|
27
|
+
* constant. For an affect head this is stable and sufficient — each
|
|
28
|
+
* (experience, state) → affect pair is close to an independent regression.
|
|
29
|
+
*/
|
|
30
|
+
import { SeededRng } from "../utils/rng.js";
|
|
31
|
+
import { quantizeFp16, dequantizeFp16 } from "../utils/quantization.js";
|
|
32
|
+
import { LIMBIC_STATE_DIM } from "./regions.js";
|
|
33
|
+
export const DEFAULT_LIMBIC_CONFIG = {
|
|
34
|
+
inputDim: 32,
|
|
35
|
+
hiddenDim: 16,
|
|
36
|
+
stateDim: LIMBIC_STATE_DIM,
|
|
37
|
+
rewardWeight: 0.5,
|
|
38
|
+
};
|
|
39
|
+
const MAGIC = 0x4c4d4243; // "LMBC"
|
|
40
|
+
/** Fixed default init seed — reproducible byte-identical cold start across machines. */
|
|
41
|
+
export const DEFAULT_LIMBIC_SEED = 0x11b1c5ee;
|
|
42
|
+
function sigmoid(x) {
|
|
43
|
+
return 1 / (1 + Math.exp(-x));
|
|
44
|
+
}
|
|
45
|
+
export class LimbicModel {
|
|
46
|
+
config;
|
|
47
|
+
// Parameters (flat, row-major).
|
|
48
|
+
win; // hidden × input
|
|
49
|
+
ws; // hidden × state
|
|
50
|
+
aLogit; // hidden
|
|
51
|
+
woutState; // state × hidden
|
|
52
|
+
boutState; // state
|
|
53
|
+
woutReward; // hidden
|
|
54
|
+
boutReward; // 1
|
|
55
|
+
// Gradient accumulators (same shapes), allocated lazily.
|
|
56
|
+
gWin;
|
|
57
|
+
gWs;
|
|
58
|
+
gALogit;
|
|
59
|
+
gWoutState;
|
|
60
|
+
gBoutState;
|
|
61
|
+
gWoutReward;
|
|
62
|
+
gBoutReward;
|
|
63
|
+
constructor(config = {}) {
|
|
64
|
+
const cfg = { ...DEFAULT_LIMBIC_CONFIG, ...config };
|
|
65
|
+
if (cfg.hiddenDim > 64) {
|
|
66
|
+
throw new Error(`LimbicModel hiddenDim must be ≤ 64 (got ${cfg.hiddenDim})`);
|
|
67
|
+
}
|
|
68
|
+
this.config = cfg;
|
|
69
|
+
const { inputDim, hiddenDim, stateDim } = cfg;
|
|
70
|
+
const rng = new SeededRng(((config.seed ?? DEFAULT_LIMBIC_SEED) >>> 0) || 1);
|
|
71
|
+
const randn = (std) => {
|
|
72
|
+
const u1 = Math.max(rng.next(), 1e-12);
|
|
73
|
+
const u2 = rng.next();
|
|
74
|
+
return std * Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
|
|
75
|
+
};
|
|
76
|
+
const gauss = (n, std) => {
|
|
77
|
+
const a = new Float32Array(n);
|
|
78
|
+
for (let i = 0; i < n; i++)
|
|
79
|
+
a[i] = randn(std);
|
|
80
|
+
return a;
|
|
81
|
+
};
|
|
82
|
+
// Small init — affect deltas should start near zero so an untrained model is
|
|
83
|
+
// inert (no spurious mood swings) until it has learned from experience.
|
|
84
|
+
this.win = gauss(hiddenDim * inputDim, 0.1);
|
|
85
|
+
this.ws = gauss(hiddenDim * stateDim, 0.1);
|
|
86
|
+
this.aLogit = gauss(hiddenDim, 0.05); // sigmoid(~0) ≈ 0.5 leak
|
|
87
|
+
this.woutState = gauss(stateDim * hiddenDim, 0.05);
|
|
88
|
+
this.boutState = new Float32Array(stateDim);
|
|
89
|
+
this.woutReward = gauss(hiddenDim, 0.05);
|
|
90
|
+
this.boutReward = new Float32Array(1);
|
|
91
|
+
this.gWin = new Float32Array(this.win.length);
|
|
92
|
+
this.gWs = new Float32Array(this.ws.length);
|
|
93
|
+
this.gALogit = new Float32Array(this.aLogit.length);
|
|
94
|
+
this.gWoutState = new Float32Array(this.woutState.length);
|
|
95
|
+
this.gBoutState = new Float32Array(this.boutState.length);
|
|
96
|
+
this.gWoutReward = new Float32Array(this.woutReward.length);
|
|
97
|
+
this.gBoutReward = new Float32Array(1);
|
|
98
|
+
}
|
|
99
|
+
/** Trainable parameters, in the canonical checkpoint order. */
|
|
100
|
+
parameters() {
|
|
101
|
+
return [
|
|
102
|
+
{ name: "win", data: this.win, numel: this.win.length },
|
|
103
|
+
{ name: "ws", data: this.ws, numel: this.ws.length },
|
|
104
|
+
{ name: "aLogit", data: this.aLogit, numel: this.aLogit.length },
|
|
105
|
+
{ name: "woutState", data: this.woutState, numel: this.woutState.length },
|
|
106
|
+
{ name: "boutState", data: this.boutState, numel: this.boutState.length },
|
|
107
|
+
{ name: "woutReward", data: this.woutReward, numel: this.woutReward.length },
|
|
108
|
+
{ name: "boutReward", data: this.boutReward, numel: this.boutReward.length },
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
/** Gradient buffers, index-aligned with {@link parameters}. */
|
|
112
|
+
gradients() {
|
|
113
|
+
return [
|
|
114
|
+
{ name: "win", data: this.gWin, numel: this.gWin.length },
|
|
115
|
+
{ name: "ws", data: this.gWs, numel: this.gWs.length },
|
|
116
|
+
{ name: "aLogit", data: this.gALogit, numel: this.gALogit.length },
|
|
117
|
+
{ name: "woutState", data: this.gWoutState, numel: this.gWoutState.length },
|
|
118
|
+
{ name: "boutState", data: this.gBoutState, numel: this.gBoutState.length },
|
|
119
|
+
{ name: "woutReward", data: this.gWoutReward, numel: this.gWoutReward.length },
|
|
120
|
+
{ name: "boutReward", data: this.gBoutReward, numel: this.gBoutReward.length },
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
zeroGrad() {
|
|
124
|
+
this.gWin.fill(0);
|
|
125
|
+
this.gWs.fill(0);
|
|
126
|
+
this.gALogit.fill(0);
|
|
127
|
+
this.gWoutState.fill(0);
|
|
128
|
+
this.gBoutState.fill(0);
|
|
129
|
+
this.gWoutReward.fill(0);
|
|
130
|
+
this.gBoutReward.fill(0);
|
|
131
|
+
}
|
|
132
|
+
/** A fresh zeroed hidden state. */
|
|
133
|
+
initHidden() {
|
|
134
|
+
return new Float32Array(this.config.hiddenDim);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* One forward step (CPU reference). Pure — does not mutate the model or the
|
|
138
|
+
* inputs. The GPU kernel path produces numerically-identical results.
|
|
139
|
+
*/
|
|
140
|
+
forward(x, hPrev, sPrev) {
|
|
141
|
+
const cache = this._forwardCached(x, hPrev, sPrev);
|
|
142
|
+
return { hidden: cache.hn, delta: cache.delta, reward: cache.reward };
|
|
143
|
+
}
|
|
144
|
+
_forwardCached(x, hPrev, sPrev) {
|
|
145
|
+
const { inputDim, hiddenDim, stateDim } = this.config;
|
|
146
|
+
const xa = Float32Array.from({ length: inputDim }, (_, i) => x[i] ?? 0);
|
|
147
|
+
const ha = Float32Array.from({ length: hiddenDim }, (_, j) => hPrev[j] ?? 0);
|
|
148
|
+
const sa = Float32Array.from({ length: stateDim }, (_, k) => sPrev[k] ?? 0);
|
|
149
|
+
const a = new Float32Array(hiddenDim);
|
|
150
|
+
const t = new Float32Array(hiddenDim);
|
|
151
|
+
const hn = new Float32Array(hiddenDim);
|
|
152
|
+
for (let j = 0; j < hiddenDim; j++) {
|
|
153
|
+
let pre = 0;
|
|
154
|
+
const wiOff = j * inputDim;
|
|
155
|
+
for (let i = 0; i < inputDim; i++)
|
|
156
|
+
pre += this.win[wiOff + i] * xa[i];
|
|
157
|
+
const wsOff = j * stateDim;
|
|
158
|
+
for (let k = 0; k < stateDim; k++)
|
|
159
|
+
pre += this.ws[wsOff + k] * sa[k];
|
|
160
|
+
a[j] = sigmoid(this.aLogit[j]);
|
|
161
|
+
t[j] = Math.tanh(pre);
|
|
162
|
+
hn[j] = a[j] * ha[j] + (1 - a[j]) * t[j];
|
|
163
|
+
}
|
|
164
|
+
const delta = new Float32Array(stateDim);
|
|
165
|
+
for (let k = 0; k < stateDim; k++) {
|
|
166
|
+
let acc = this.boutState[k];
|
|
167
|
+
const off = k * hiddenDim;
|
|
168
|
+
for (let j = 0; j < hiddenDim; j++)
|
|
169
|
+
acc += this.woutState[off + j] * hn[j];
|
|
170
|
+
delta[k] = Math.tanh(acc);
|
|
171
|
+
}
|
|
172
|
+
let reward = this.boutReward[0];
|
|
173
|
+
for (let j = 0; j < hiddenDim; j++)
|
|
174
|
+
reward += this.woutReward[j] * hn[j];
|
|
175
|
+
return { x: xa, sPrev: sa, hPrev: ha, a, t, hn, delta, reward };
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Accumulate gradients for one (input, state) → (deltaTarget, rewardTarget)
|
|
179
|
+
* sample using truncated BPTT(1). Returns the scalar loss for this step and
|
|
180
|
+
* the next hidden state to carry forward. Call {@link zeroGrad} before a batch
|
|
181
|
+
* and apply the optimiser after.
|
|
182
|
+
*/
|
|
183
|
+
backwardStep(x, hPrev, sPrev, deltaTarget, rewardTarget) {
|
|
184
|
+
const { inputDim, hiddenDim, stateDim, rewardWeight } = this.config;
|
|
185
|
+
const c = this._forwardCached(x, hPrev, sPrev);
|
|
186
|
+
// Loss
|
|
187
|
+
let loss = 0;
|
|
188
|
+
const dDelta = new Float32Array(stateDim);
|
|
189
|
+
for (let k = 0; k < stateDim; k++) {
|
|
190
|
+
const diff = c.delta[k] - (deltaTarget[k] ?? 0);
|
|
191
|
+
loss += 0.5 * diff * diff;
|
|
192
|
+
dDelta[k] = diff;
|
|
193
|
+
}
|
|
194
|
+
const dRewardDiff = c.reward - rewardTarget;
|
|
195
|
+
loss += 0.5 * rewardWeight * dRewardDiff * dRewardDiff;
|
|
196
|
+
const dReward = rewardWeight * dRewardDiff;
|
|
197
|
+
// Backprop to hidden through both heads.
|
|
198
|
+
const dHn = new Float32Array(hiddenDim);
|
|
199
|
+
for (let k = 0; k < stateDim; k++) {
|
|
200
|
+
const dPreDelta = dDelta[k] * (1 - c.delta[k] * c.delta[k]); // tanh'
|
|
201
|
+
this.gBoutState[k] = this.gBoutState[k] + dPreDelta;
|
|
202
|
+
const off = k * hiddenDim;
|
|
203
|
+
for (let j = 0; j < hiddenDim; j++) {
|
|
204
|
+
this.gWoutState[off + j] = this.gWoutState[off + j] + dPreDelta * c.hn[j];
|
|
205
|
+
dHn[j] = dHn[j] + dPreDelta * this.woutState[off + j];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
this.gBoutReward[0] = this.gBoutReward[0] + dReward;
|
|
209
|
+
for (let j = 0; j < hiddenDim; j++) {
|
|
210
|
+
this.gWoutReward[j] = this.gWoutReward[j] + dReward * c.hn[j];
|
|
211
|
+
dHn[j] = dHn[j] + dReward * this.woutReward[j];
|
|
212
|
+
}
|
|
213
|
+
// Backprop through the recurrent update hn = a·hPrev + (1-a)·t.
|
|
214
|
+
for (let j = 0; j < hiddenDim; j++) {
|
|
215
|
+
const aj = c.a[j];
|
|
216
|
+
const tj = c.t[j];
|
|
217
|
+
// ∂hn/∂A = (hPrev - t)·a·(1-a)
|
|
218
|
+
this.gALogit[j] = this.gALogit[j] + dHn[j] * (c.hPrev[j] - tj) * aj * (1 - aj);
|
|
219
|
+
// ∂hn/∂t = (1-a); ∂t/∂pre = 1 - t²
|
|
220
|
+
const dPre = dHn[j] * (1 - aj) * (1 - tj * tj);
|
|
221
|
+
const wiOff = j * inputDim;
|
|
222
|
+
for (let i = 0; i < inputDim; i++)
|
|
223
|
+
this.gWin[wiOff + i] = this.gWin[wiOff + i] + dPre * c.x[i];
|
|
224
|
+
const wsOff = j * stateDim;
|
|
225
|
+
for (let k = 0; k < stateDim; k++)
|
|
226
|
+
this.gWs[wsOff + k] = this.gWs[wsOff + k] + dPre * c.sPrev[k];
|
|
227
|
+
}
|
|
228
|
+
return { loss, hidden: c.hn };
|
|
229
|
+
}
|
|
230
|
+
// ── Checkpoint serialisation ──────────────────────────────────────────────
|
|
231
|
+
/**
|
|
232
|
+
* Serialise weights to a compact "LMBC" binary. fp16 (v2) halves the size at
|
|
233
|
+
* ~0.5% precision cost; f32 (v1) is exact. Layout: magic, version, [inputDim,
|
|
234
|
+
* hiddenDim, stateDim], then params in {@link parameters} order.
|
|
235
|
+
*/
|
|
236
|
+
exportWeights(opts = {}) {
|
|
237
|
+
const fp16 = opts.fp16 ?? false;
|
|
238
|
+
const params = this.parameters();
|
|
239
|
+
const total = params.reduce((n, p) => n + p.numel, 0);
|
|
240
|
+
const headerEls = 5; // magic, version, inputDim, hiddenDim, stateDim
|
|
241
|
+
const headerBytes = headerEls * 4;
|
|
242
|
+
const dataBytes = fp16 ? total * 2 : total * 4;
|
|
243
|
+
const buf = new ArrayBuffer(headerBytes + dataBytes);
|
|
244
|
+
const head = new Uint32Array(buf, 0, headerEls);
|
|
245
|
+
head[0] = MAGIC;
|
|
246
|
+
head[1] = fp16 ? 2 : 1;
|
|
247
|
+
head[2] = this.config.inputDim;
|
|
248
|
+
head[3] = this.config.hiddenDim;
|
|
249
|
+
head[4] = this.config.stateDim;
|
|
250
|
+
if (fp16) {
|
|
251
|
+
const flat = new Float32Array(total);
|
|
252
|
+
let o = 0;
|
|
253
|
+
for (const p of params) {
|
|
254
|
+
flat.set(p.data, o);
|
|
255
|
+
o += p.numel;
|
|
256
|
+
}
|
|
257
|
+
const q = quantizeFp16(flat); // Uint16Array
|
|
258
|
+
new Uint16Array(buf, headerBytes, total).set(q);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
const out = new Float32Array(buf, headerBytes, total);
|
|
262
|
+
let o = 0;
|
|
263
|
+
for (const p of params) {
|
|
264
|
+
out.set(p.data, o);
|
|
265
|
+
o += p.numel;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return buf;
|
|
269
|
+
}
|
|
270
|
+
/** Load weights from an "LMBC" binary. Validates magic + dims. */
|
|
271
|
+
loadWeights(buffer) {
|
|
272
|
+
const head = new Uint32Array(buffer, 0, 5);
|
|
273
|
+
if (head[0] !== MAGIC)
|
|
274
|
+
throw new Error("LimbicModel.loadWeights: bad magic (not an LMBC checkpoint)");
|
|
275
|
+
const version = head[1];
|
|
276
|
+
const inputDim = head[2];
|
|
277
|
+
const hiddenDim = head[3];
|
|
278
|
+
const stateDim = head[4];
|
|
279
|
+
if (inputDim !== this.config.inputDim || hiddenDim !== this.config.hiddenDim || stateDim !== this.config.stateDim) {
|
|
280
|
+
throw new Error(`LimbicModel.loadWeights: dim mismatch — checkpoint ${inputDim}/${hiddenDim}/${stateDim} vs model ${this.config.inputDim}/${this.config.hiddenDim}/${this.config.stateDim}`);
|
|
281
|
+
}
|
|
282
|
+
const params = this.parameters();
|
|
283
|
+
const total = params.reduce((n, p) => n + p.numel, 0);
|
|
284
|
+
const headerBytes = 20;
|
|
285
|
+
let flat;
|
|
286
|
+
if (version === 2) {
|
|
287
|
+
flat = dequantizeFp16(new Uint16Array(buffer, headerBytes, total));
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
flat = new Float32Array(buffer.slice(headerBytes, headerBytes + total * 4));
|
|
291
|
+
}
|
|
292
|
+
let o = 0;
|
|
293
|
+
for (const p of params) {
|
|
294
|
+
p.data.set(flat.subarray(o, o + p.numel));
|
|
295
|
+
o += p.numel;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=limbic_model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limbic_model.js","sourceRoot":"","sources":["../../src/limbic/limbic_model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAehD,MAAM,CAAC,MAAM,qBAAqB,GAA8C;IAC9E,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,gBAAgB;IAC1B,YAAY,EAAE,GAAG;CAClB,CAAC;AA+BF,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,SAAS;AAEnC,wFAAwF;AACxF,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAE9C,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,OAAO,WAAW;IACb,MAAM,CAA4C;IAE3D,gCAAgC;IAChC,GAAG,CAAe,CAAC,iBAAiB;IACpC,EAAE,CAAe,CAAC,iBAAiB;IACnC,MAAM,CAAe,CAAC,SAAS;IAC/B,SAAS,CAAe,CAAC,iBAA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