Downloads · 30 days
0
Quazim0t0/SpikeWhale-SNN-216M
SpikeWhale-SNN-216M is a text generation model from Quazim0t0. Use it when you need the model to write or continue text. It is set up for pytorch. The card lists the license as apache-2.0.
Model will be ungated for open download soon! These models are undertrained, and are NOT meant to be finished. These are Research Artifacts only.
Downloads · 30 days
0
Access
Public
Updated Sep 20, 2026
Repo size
866 MB
Likes
6
Public
Click a slice to open those files.
.pth865 MB · 100%
From the Hugging Face model README
Model will be ungated for open download soon! These models are undertrained, and are NOT meant to be finished. These are Research Artifacts only.

Every neuron of the 4 stacked LIF layers, coloured by its dominant gene program and
sized by its learned recurrent wiring. Rendered straight from the checkpoint with
src/scripts/visualize_architecture.py - no
training data required.
~216M spiking neural network language model. Entirely from scratch.
This is the original SpikeWhale project - the one that started the rest of
the SpikeWhale work. Every spiking primitive is hand-written in plain PyTorch:
leaky integrate-and-fire (LIF), fast-sigmoid surrogate gradient, BPTT loop.
No snntorch, no spikingjelly, no norse, no bindsnet. Genuine
from-scratch SNN.
Two extra ideas on top of the spiking core:
beta, input gain) is modulated by a frozen virtual-cell
gene-program model. Every hidden neuron is assigned a gene knockdown; the
cell model predicts that perturbation's effect on six gene programs, and that
identity vector sets the LIF parameters. Mapping directions are fixed (from
biology); strengths are learned. Deliberate, ablatable experiment - not a
claim that gene expression literally sets neural thresholds. Full story:
The virtual cell.A live demo is hosted at the companion Space SpikeWhale-SNN v1, which pulls these weights at runtime.
<a href="https://hfviewer.com/Quazim0t0/SpikeWhale-SNN-216M?utm_source=huggingface&utm_medium=embedded_model_card&utm_campaign=Quazim0t0__SpikeWhale-SNN-216M_card&utm_content=embedded_card_open_viewer&from=embedded-model-card" target="_blank" rel="noopener"> <img src="https://hfviewer.com/api/card.svg?source=Quazim0t0%2FSpikeWhale-SNN-216M&granularity=auto&v=20260516-title-pills-card" alt="Architecture graph for Quazim0t0/SpikeWhale-SNN-216M. Open in hfviewer" width="100%" /> </a>| Parameters | 215,901,779 (~216M) |
| Architecture | Recurrent LIF spiking LM (SpikingCharLM) |
| Depth × width | 4 stacked LIF layers × 1488 hidden |
| Readout | All-layer pre-reset membrane → linear head (per-position logits) |
| Weight tying | Embedding ⇄ output table tied |
| Tokenizer | Custom SpikeWhale byte-level "length-max" tokenizer, vocab 16,512 |
| Neuron model | Leaky integrate-and-fire + fast-sigmoid surrogate gradient (Neftci et al. 2019) |
| Modulation | program - neurons modulated by the frozen virtual-cell bridge |
| Training data | Streamed 75% FineWeb-Edu + 25% FineMath |
| Training step (this ckpt) | 31,824 |
| Val bits/token | 3.977 (uniform baseline ≈ log₂16512 ≈ 14.0) |
| Mean firing rate | ≈ 41% (healthy: not dead, not saturated) |
| Precision | float32 |
Engram · HRM · MTP · SpikeAttn · ProgSem · Kuramoto · JEPA (MoE off), plus an
anti-death firing regulariser (firing_target=0.2, weight 50).
token id ─► embedding (input current)
─► LIF layer 0 ─► spikes ─► LIF layer 1 ─► … ─► LIF layer 3
│
(per layer: mem[t] = beta·mem[t-1] + input; spike if mem ≥ threshold; soft reset)
│
all layers' pre-reset membranes ─► tanh ─► linear readout ─► next-token logits
"Time" is token position: one LIF time-step per token, with membrane
potentials and recurrent spikes carrying memory across the sequence. Because the
forward spike is a step function, gradients flow through a surrogate
(1/(1+slope·|mem-thresh|)²), which also passes gradient to each neuron's
threshold - that is what lets the gene-program bridge train end-to-end.
The "virtual cell" is a small, frozen perturbation-prediction model trained separately, before the SNN. It answers one question: if you knock down gene X, how does the cell's gene expression change? The SNN then borrows those predicted biological effects to configure its neurons.
src/ml/VirtualCell.py - a deliberately tiny MLP that
predicts a delta from a control expression profile:
pred_expression = control_expression + delta_net(gene_embedding)
src/scripts/compute_esm2_embeddings.py).delta_net: Linear(1280→64) → LayerNorm → GELU → Linear(64→2177). The
final layer is zero-initialised, so at init the model predicts "no change"
(control) and learns perturbation effects from there.The bundled model was trained on the real Virtual Cell Challenge (VCC) dataset
(source="real") - a Perturb-seq screen in the H1 human embryonic stem cell
(hESC) line, a fast-dividing, pluripotent cell that is the canonical starting
point for neuronal differentiation. Training (src/scripts/train_programs.py):
expression is total-count normalised + log1p, reduced to per-perturbation
pseudobulk profiles, and split by held-out perturbation gene. The loss
up-weights program genes and additionally matches per-program Δ-scores; validation
reports the Pearson correlation of predicted vs. true Δ-program score. The frozen
result ships here as models/programs_real_20260628_022009.pth.
src/ml/gene_programs.py groups genes into named,
biologically-meaningful programs (curated marker sets, e.g. Tirosh et al. 2016
S / G2-M cell-cycle genes, pan-neuronal markers, pluripotency factors):
| Program | Meaning | High score means… |
|---|---|---|
cell_division | S + G2/M cell-cycle / mitosis genes | actively dividing |
neuron_identity | pan-neuronal markers (MAP2, RBFOX3, SYN1…) | neuron-like |
pluripotency | hESC ground-state factors (POU5F1, NANOG, SOX2…) | stem-cell-like |
endocrine | hormones / receptors / steroidogenesis | endocrine (odd for hESC - deliberate) |
metabolism | glycolysis, TCA, lipid/sterol, OxPhos | high metabolic drive |
signaling_identity | RTK→RAS/MAPK/PI3K, Wnt, TGFβ, JAK/STAT | proliferative signalling |
The original motivating idea was the "cell-dividing neuron" - the biologically
unusual corner where cell_division and neuron_identity are both high.
src/snn/cell_modulation.py turns those biological
predictions into LIF parameters:
Assign each of the 1488 hidden neurons a gene knockdown drawn from the dataset's perturbation pool.
Predict - run the frozen cell model on (mean control, gene ESM2 embedding)
and score the predicted profile's Δ against each of the 6 programs → a per-neuron
identity vector. This checkpoint uses the concat strategy over 3 seed
draws, so each neuron carries its identity under 3 independent gene assignments:
the stored program matrix P is [1488 × 18] (6 programs × 3 seeds), z-scored.
Map identity → LIF dynamics, with learnable per-program strengths:
threshold = base_thr · exp(P · thr_gain) clamp [0.25, 3.0]
beta = sigmoid(logit(base_beta) + P·beta_gain) clamp [0.50, 0.97]
gain = exp(P · in_gain) clamp [0.30, 3.0]
The directions are seeded from biology (neuron-identity → lower threshold,
longer memory, stronger drive; all other programs start neutral); the
strengths (thr_gain, beta_gain, in_gain) are nn.Parameters the SNN
trains end-to-end - so the network learns how much to lean on the biology.
Because gradient flows to the neuron threshold through the surrogate, this is
fully differentiable.
The ablation: --modulation none zeroes the bridge, giving homogeneous LIF
neurons - the control that tests whether the biological coupling actually helps.
Nothing about the cell model is needed at inference: the computed matrix P and
the learned gains are baked into the checkpoint.
The checkpoint records its own tokenizer, model shape, and modulation matrix, so loading rebuilds the exact architecture automatically.
pip install torch numpy scipy transformers huggingface_hub
import torch, sys
from huggingface_hub import snapshot_download
repo = snapshot_download("Quazim0t0/SpikeWhale-SNN-216M")
sys.path.insert(0, f"{repo}/src")
from snn.text import SpikeVocab
from snn.model import SpikingCharLM
from snn.cell_modulation import NeuronModulation
ckpt = torch.load(f"{repo}/snn_stream_program.pth", map_location="cpu", weights_only=False)
vocab = SpikeVocab((ckpt["vocab"] or {}).get("tokenizer_json"))
m = ckpt["modulation"]
mod = NeuronModulation(m["P"] if m["enabled"] else None, m["hidden"],
base_threshold=m["base_threshold"], base_beta=m["base_beta"],
enabled=m["enabled"])
cfg = ckpt["config"]
model = SpikingCharLM(cfg["vocab_size"], cfg["emb_dim"], cfg["hidden"], mod,
readout_decay=cfg["readout_decay"], num_layers=cfg["num_layers"],
tie_embeddings=cfg["tie_embeddings"], **cfg.get("family", {}))
model.load_state_dict(ckpt["model_state_dict"]); model.eval()
ids = model.generate(vocab.encode("The ").tolist(), 80, temperature=0.7,
device=torch.device("cpu"), top_k=10)
print(vocab.decode(ids))
Or, from the bundled scripts:
PYTHONPATH=src python src/scripts/generate_snn.py \
--checkpoint snn_stream_program.pth --prompt "The " --length 120
⚠️ This is a recurrent net: one LIF step per token, so CPU sampling is slow. A GPU is strongly recommended for both training and long generations.
This repo is a complete, self-contained training package - clone it and run
the same project end-to-end. See START_HERE.md and
SNN.md for the full write-up.
pip install -r requirements.txt
pip install -e . --no-deps # makes `snn` and `ml` importable
# train the ~216M spiking LM on the streamed FineWeb-Edu + FineMath blend,
# neurons bridged to the frozen virtual-cell program model:
python src/scripts/train_snn_stream.py --modulation program --data-dir data
# ablation - homogeneous neurons, no bridge (needs no cell data):
python src/scripts/train_snn_stream.py --modulation none --no-family
The datasets stream on the fly (nothing large is stored locally). Watch the
firing rate printed each step: deep spiking stacks can go silent in the upper
layers - the input projection of the deeper layers is scaled (spike_input_gain)
to keep spikes propagating through all 4 layers.
src/snn/ lif.py model.py cell_modulation.py family.py text.py muon.py
src/ml/ the frozen virtual-cell gene-program model (read-only, for the bridge)
src/scripts/ train_snn_stream.py train_snn.py generate_snn.py train_programs.py …
spike_tokenizer.py special_tokens.py tokenizer.json # the SpikeWhale tokenizer
data/ models/ # the cell-bridge bundle + frozen program model
research/ # analysis / health-check scripts
snn_stream_program.pth latest.txt # the trained weights (this card)
Apache-2.0.
@software{byrne_spikewhale_snn_2026,
title = {SpikeWhale-SNN-216M: a from-scratch spiking neural network language
model bridged to a virtual-cell gene-program model},
author = {Byrne, Dean (Quazim0t0)},
year = {2026},
url = {https://huggingface.co/Quazim0t0/SpikeWhale-SNN-216M}
}