AI visualisation
Veena's AI components separate semantic models from their rendered views. IDs and named axes remain stable while values and focus change.
Neural networksโ
const model = neuralNetwork([
{ id: "input", label: "Input", nodes: ["xโ", "xโ", "xโ", "xโ"] },
{ id: "hidden", label: "Hidden", nodes: ["hโ", "hโ", "hโ"] },
{ id: "output", label: "Output", nodes: ["ลทโ", "ลทโ"] },
]);
const network = NeuralNetwork(model);
this.add(network);
Networks support named layers, stable node/edge IDs, dense weights, explicit sparse or skip connections, activation snapshots, and signal flow over unique edges.
Biological neuronsโ
BiologicalNeuron is a stylised teaching view with three independently animated phases: input pulses travel inward through dendrites, charge illuminates the soma, and a signal travels outward along the axon to its terminals.
const neuron = BiologicalNeuron({ dendrites: 9, myelinated: true });
this.add(neuron);
timeline.animate(neuron).duration(1.2).to(neuron.receive());
timeline.animate(neuron).duration(0.5).to(neuron.illuminate());
timeline.animate(neuron).duration(1.5).to(neuron.fire());
The component is deliberately a visual explanation rather than a physiological simulation. Pair it with NeuralNetwork to explain which ideas inspired artificial neurons while keeping their differences explicit.
Semantic tensorsโ
tensorAxis and tensorSnapshot attach meaning to each dimension and element. Operations preserve or transform that meaning:
tensorAdd,tensorSplit,tensorMerge,tensorReshapetensorProject2d,tensorTranspose2d,tensorMatmultensorScale,tensorCausalMask,tensorSoftmaxtensorSampleCategorical
TensorView renders a chosen 2D projection while fixed named axes select the remaining slice.
Attention and transformersโ
TokenRow, AttentionMatrix, and TransformerBlock provide reusable teaching views. attentionMatrices() computes Q/K products, scaling, masking, and softmax for a complete small example rather than displaying arbitrary numbers.
Context and generationโ
ContextWindow visualises token-budget composition. KvCache, NormalizationPanel, NextTokenBoard, and EntropyBar cover common LLM mechanics and sampling stories.
See the focused examples under examples/ai/, especially self-attention-lesson.ts, tensor-semantics.ts, neural-networks.ts, and context-window.ts.