laserbrain
v1.1.1
Published
gated Laplace diffusion kernel — blends each position toward its neighbours with exponential decay and a learned gate
Maintainers
Readme
laserbrain
Gated Laplace diffusion kernel for token sequences.
Each position absorbs from its neighbours via exponential decay — close positions pull more than distant ones. A sigmoid gate controls how much blending occurs.
const { quadrize } = require('laserbrain')
const x = new Float32Array([1, 2, 3, 4, 5])
const out = quadrize(x)API
quadrize(x, k, gate, d)
| param | type | default | description |
|-------|------|---------|-------------|
| x | Float32Array | — | input sequence, length ctx or ctx*d |
| k | number | 1.0 | decay rate — higher k = sharper, more local |
| gate | number | -1.4 | pre-sigmoid blend strength (~0.2 at default) |
| d | number | 1 | embedding dimension (for 2D input, row-major) |
Returns a Float32Array of the same length.
quadrize.kernel
{ name: 'phronesis', k: 1.0 }intuition
k high → sharp kernel, each token stays close to itself
k low → flat kernel, all tokens collapse toward the mean
gate → how strongly the blended signal overwrites the originalAt default settings each position blends ~20% toward its neighbourhood.
2D (embeddings)
Pass flattened ctx × d row-major data with d set:
// 4 tokens, 3 dims each
const x = new Float32Array([
1, 0, 0,
0, 1, 0,
0, 0, 1,
1, 1, 0,
])
const out = quadrize(x, 1.0, -1.4, 3)install
npm i laserbrain