An incremental, GPU-capable sequence-learning engine for float-tensor observations — a hand-rolled alternative to a neural net for online prediction.
repliKate learns to predict "what comes next" in a stream of tensors (e.g. board states) one observation at a time, with no offline training pass and no gradient descent. Instead, TensorSequenceTree builds a weighted transition graph over quantized, deduplicated tensor states, augmented with n-gram context windows, RNN-style delta (velocity/acceleration) extrapolation, and experience replay. It's demonstrated end-to-end in a Connect 4 app where a TensorAi learns to play through self-play, competing against a simple heuristic AI.
- Continuous online learning —
Learn/LearnWithOutcomeingest one sequence at a time; there's no separate training phase. - State dedup via quantized similarity — new tensors are matched against existing states by cosine similarity (≥0.95) on 16-bit quantized data, avoiding duplicate nodes for near-identical observations.
- Multiple prediction strategies over the same structure — graph walk (
PredictNext), n-gram context lookup, nearest-neighbor regression with trend (PredictNextRegressionWithTrend), physics-style delta extrapolation (PredictNextDelta/PredictNextDeltaSmoothed), and an ensemble that blends them (PredictNextEnsemble). - Experience replay — an outcome-weighted buffer (
experienceBuffer) keeps the most significant past sequences and replays them at reduced weight, RL-style. - Temporal decay and loop detection — transition weights decay over time; recurring states are recognized across sequence positions (
equivalentStateIndices,IsLoopingState,AnalyzeLoopsInSequence). - Optional GPU acceleration — ILGPU kernels for cosine similarity, quantize/dequantize, delta updates, and vector addition, each with a CPU-equivalent fallback.
Everything lives in a single file, repliKate/TensorSequenceTree.cs:
Tensor— a plain float-array wrapper (shape, data, cosine similarity, clone/scale/normalize).QuantizedTensor— the same tensor compressed to 16-bit values plus min/max, for memory efficiency; has parallel CPU and ILGPU code paths.DeltaState— a per-sequence recurrent tracker (current value, velocity, acceleration, EMA-smoothed value) that extrapolates the next value the way an RNN propagates hidden state forward.TensorNode— one node per distinct observed tensor position, holding weighted transition counts to "next" indices.TensorSequenceTree— ties it together: a rolling-window master sequence, the node graph, per-order n-gram tables with hashed fast lookup, the experience-replay buffer, and pruning to bound memory growth.
GPU acceleration is wired up (InitializeGpu, five ILGPU kernels: cosine similarity, quantize, dequantize, delta update, vector add) but is off by default in every constructor actually used — the shipped app runs entirely on the CPU code paths, with the GPU path available and falling back gracefully if CUDA init fails.
Connect4App (Avalonia desktop app) is the test bed: AI/TensorAi.cs wraps a TensorSequenceTree to play Connect 4, encoding the board as a tensor sequence and learning from game outcomes; AI/BasicAi.cs is a simple heuristic opponent; GameController drives self-play or tensor-vs-heuristic matches on a timer.
dotnet build repliKate/repliKate.csproj # library only
dotnet run --project Connect4App/Connect4App.csproj # windowed Connect 4 demo
Both projects target net9.0. The library depends on ILGPU.Algorithms (pulling in ILGPU); the app additionally depends on Avalonia 11.
Early-stage, single-developer prototype — two commits, no automated tests, no license file. GPU acceleration exists but is disabled by default and unexercised in the shipped demo. Model save/load is stubbed (a path is defined but load/save isn't implemented) — nothing persists between runs yet. Treat this as a working experiment in online sequence learning, not a finished library.
No license file is currently present in the repository.