Delon Swartz commited on
add README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- kuramoto
|
| 5 |
+
- oscillator
|
| 6 |
+
- language-model
|
| 7 |
+
- tinystories
|
| 8 |
+
library_name: pytorch
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# KOLM-Alpha — a native Kuramoto-Oscillator Language Model
|
| 12 |
+
|
| 13 |
+
**KOLM-Alpha is, to our knowledge, the first language model whose per-token
|
| 14 |
+
processing layers are networks of coupled Kuramoto oscillators, trained
|
| 15 |
+
natively from scratch.** Each layer uses standard causal attention for
|
| 16 |
+
routing between tokens and a **Kuramoto block** for processing: *H*
|
| 17 |
+
oscillators, each a unit vector on a sphere, relax over *K* settling steps
|
| 18 |
+
under trained pairwise couplings, conditioned on the attention output. The
|
| 19 |
+
oscillator block replaces the Transformer's feed-forward network; attention
|
| 20 |
+
is retained.
|
| 21 |
+
|
| 22 |
+
## The result
|
| 23 |
+
|
| 24 |
+
Under a strictly controlled **twin protocol** — identical tokenizer, data,
|
| 25 |
+
data order, context length, optimizer, schedule and seed, with *only* the
|
| 26 |
+
feed-forward slot differing — KOLM-Alpha is compared against **TMT**
|
| 27 |
+
(Transformer Model Twin), a standard attention + MLP model. Both were
|
| 28 |
+
trained from scratch on 11.3M tokens of TinyStories on a single consumer
|
| 29 |
+
laptop.
|
| 30 |
+
|
| 31 |
+

|
| 32 |
+
|
| 33 |
+
TMT leads early; KOLM-Alpha closes the gap steadily, crosses near 7M tokens,
|
| 34 |
+
and finishes ahead — **with 3.5% fewer parameters.**
|
| 35 |
+
|
| 36 |
+

|
| 37 |
+
|
| 38 |
+
| Model | Parameters | Val loss | Perplexity |
|
| 39 |
+
|---|---|---|---|
|
| 40 |
+
| **KOLM-Alpha** | **16,916,224** | **2.6946** | **14.80** |
|
| 41 |
+
| TMT (Transformer twin) | 17,538,816 | 2.7188 | 15.16 |
|
| 42 |
+
|
| 43 |
+
Both models generate coherent TinyStories-grade prose. Prompt *"Once upon a
|
| 44 |
+
time there was a little red shoe"*:
|
| 45 |
+
|
| 46 |
+
> **KOLM-Alpha:** …The little boy would come home and play with his friends.
|
| 47 |
+
> One day, the little girl was playing with the big castle in the sky…
|
| 48 |
+
|
| 49 |
+
## Why it matters
|
| 50 |
+
|
| 51 |
+
A Transformer computes with a fixed number of operations per token. A
|
| 52 |
+
Kuramoto block computes by **iterative settling** — the oscillator field
|
| 53 |
+
relaxes toward a configuration over *K* steps — which opens a second axis of
|
| 54 |
+
scale that costs no additional memory, only settling time. KOLM-Alpha
|
| 55 |
+
establishes the first point: at matched parameters, oscillatory processing
|
| 56 |
+
is not merely competitive with a Transformer feed-forward network — it edges
|
| 57 |
+
it out.
|
| 58 |
+
|
| 59 |
+
## Files
|
| 60 |
+
|
| 61 |
+
| File | Purpose |
|
| 62 |
+
|---|---|
|
| 63 |
+
| `native_kolm.py` | model + twin trainer (`--arch kolm` / `--arch transformer`) |
|
| 64 |
+
| `kuramoto_torch.py` | the Kuramoto block (parity-tested to 2.2e-16 vs a NumPy reference) |
|
| 65 |
+
| `kolm.py`, `olm.py` | pure-NumPy reference core with hand-derived, gradient-checked backprop |
|
| 66 |
+
| `sample_native.py` | generation from the trained weights |
|
| 67 |
+
| `native_kolm.pt` | **KOLM-Alpha weights** (16.9M) |
|
| 68 |
+
| `native_transformer.pt` | TMT weights (17.5M) |
|
| 69 |
+
| `tiny8k.json` | tokenizer (required to run the model) |
|
| 70 |
+
| `curve_kolm.csv`, `curve_transformer.csv` | validation-loss curves |
|
| 71 |
+
|
| 72 |
+
## Run it
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
python3 -m venv --system-site-packages .venv
|
| 76 |
+
.venv/bin/pip install torch tokenizers
|
| 77 |
+
|
| 78 |
+
# generate from the released weights
|
| 79 |
+
.venv/bin/python sample_native.py --prompt "Once upon a time"
|
| 80 |
+
|
| 81 |
+
# verify the hand-derived gradients of the NumPy reference (no PyTorch needed)
|
| 82 |
+
python3 kolm.py --gradcheck
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## Reproduce the comparison
|
| 86 |
+
|
| 87 |
+
```bash
|
| 88 |
+
.venv/bin/pip install transformers accelerate
|
| 89 |
+
.venv/bin/python native_kolm.py --prep # build tokenizer + data
|
| 90 |
+
.venv/bin/python native_kolm.py --arch kolm --steps 5500
|
| 91 |
+
.venv/bin/python native_kolm.py --arch transformer --steps 5500
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
## Roadmap
|
| 95 |
+
|
| 96 |
+
KOLM-Alpha is the first release. In progress:
|
| 97 |
+
|
| 98 |
+
- **KOLM-Beta** — a larger model with frustrated coupling and a broader
|
| 99 |
+
training corpus, grown from Alpha via function-preserving depth growth.
|
| 100 |
+
- **KOLM-Chat** — an instruction-tuned conversational KOLM, exposing the
|
| 101 |
+
settling depth as a user-facing "think-harder" control.
|
| 102 |
+
|
| 103 |
+
## Details
|
| 104 |
+
|
| 105 |
+
- **Architecture:** 8 layers, d=384, 6 heads, context 256, 8k byte-level BPE.
|
| 106 |
+
Feed-forward slot = Kuramoto block (H=320 oscillators on S³, K=4 settling
|
| 107 |
+
steps, 32 order-parameter readouts).
|
| 108 |
+
- **Training:** AdamW, lr 1e-4 cosine, gradient clip 1.0, single seed.
|
| 109 |
+
- **Hardware:** one Apple-silicon laptop (MPS), ~6 hours.
|
| 110 |
+
- **Status:** research preview. The headline comparison is single-seed; a
|
| 111 |
+
second seed is queued.
|
| 112 |
+
|
| 113 |
+
## License
|
| 114 |
+
|
| 115 |
+
Apache-2.0.
|
| 116 |
+
|
| 117 |
+
## Acknowledgements
|
| 118 |
+
|
| 119 |
+
Builds on the Kuramoto-oscillator formulation of **AKOrN** (Miyato et al.,
|
| 120 |
+
ICLR 2025) and the **TinyStories** corpus (Eldan & Li, 2023).
|