Skip to content
In depthExperiments

Verace Neocortex: simulation and tools

A pure-NumPy cortical transformer, morphological tokenizer, synthetic cognitive datasets and an ODE simulator of NCT training dynamics.

Verace Research
  1. Stochastic resonance gate: Stayed near 0.117 and never opened
  2. Training steps: Gates began opening around step 1700
  3. Tripartite ACh gate: Opened first and was the strongest, at 0.88
  4. Mechanism gate: Pushed open by utility, starts near 0.119
Figure 1. Opening of the 24 mechanism gates in the ODE surrogate of NCT training. Schematic: a sigmoid gate opening over simulated training in the scalar ODE surrogate of NCT V10.2. The gate values on it come from simulation, not from training the network.
Open the simulator on its own pageA gate with a soft edge: an interactive toy model of the principle. You can also try it below

Overview

This part of Verace Neocortex holds the research tooling around the model, which the lab's papers and code call the NeuroCortex Transformer (NCT). It has five parts: a pure-NumPy implementation of the model with its own autograd engine, a dual-route morphological tokenizer, generators for a synthetic cognitive dataset, a simulation framework, and architecture diagram generators. The simulation framework models NCT V10.2 training as coupled ordinary differential equations. It addresses one question: whether the 24 biologically motivated mechanism gates open, stay stable and add value. It answers that question cheaply, without running full training.

The model chains predictive coding, a six-signal neuromodulator, oscillatory phase binding, cortical-column consensus, excitatory-inhibitory attention, Hebbian fast weights and a k-winners-take-all feed-forward layer inside each block. The simulator dynamics.py Euler-steps a scalar surrogate of training. It tracks the learning rate, MSE, the precision σ2\sigma^2, the 24 gates, four neuromodulators, working memory, oscillations, the inhibitory triad and homeostasis, with noise added. Around it sit Latin hypercube Monte Carlo sampling with Spearman sensitivity, adaptive grid search, a what-if scenario engine and a paired-seed comparison of old and new algorithms.

The Run 13 research report covers about 500 or more simulations of a 49-theorem model with σ2\sigma^2 bounded in [0.3, 4.0]. In the lab's simulations, 200 Monte Carlo samples showed zero divergence and 16 of 24 gates opened at the default configuration. Ablating all 24 gates cost +0.21 NTP, and an aggressive recipe reached NTP 3.94 against 3.96 for the default. The StochasticResonance gate never opened. The lab's stochastic resonance analysis traced this to noise that did not depend on the signal, and it derived a signal-dependent replacement (Thm 48).

The NumPy model, autograd engine, optimizer, tokenizer, dataset generators and simulation framework are implemented. The training script runs on random token batches. No training run of the NumPy model is recorded in this part. Every measured figure comes from the scalar ODE surrogate, not from training the network. The five biophysical replacements and the stochastic resonance fix are derived analytically and simulated, and the analysis states that the fix was applied in the implementation. No measurement of its effect is recorded. The V11 local learning rules and the wake-sleep loop appear only in the architecture diagram generator, as design.

Status

Experiments. The code is implemented and the research report records Run 13 simulation results from the ODE surrogate. No training of the NumPy network is recorded.

Simulator

A gate rises from 0 to 1 around a threshold. Two hundred made-up inputs are passed through it: set how steep it is, where its threshold lies and how spread out the inputs are.

  • the inputs (made up): those the gate passes in colour
  • dashed: a hard step at the same threshold
Inputs passed
48%
Inputs left undecided
59%
Width of the undecided band
1.46
Mean output of the gate
0.48

Make the gate steeper and it tends to a hard step: fewer inputs are left undecided. Move the threshold through the inputs.

This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.

Architecture

  1. Pure-NumPy NCT model

    NCTModel stacks NCTBlock layers with tied embeddings. NCTConfig defaults to d=512, L=12, 6 excitatory and 2 inhibitory heads, K=4 columns, P=4 phases and M=6 neuromodulatory signals.

  2. Autograd and nn library

    tensor.py is a reverse-mode autograd engine on NumPy. nn.py adds Module, Parameter, Xavier-initialised Linear, Embedding, RMSNorm and inverted Dropout.

  3. GPT-like baseline

    baseline.py is a standard comparison model for TinyStories: pre-norm RMSNorm, RoPE, dense SwiGLU, all-excitatory attention and tied embeddings. Its defaults are d=128, L=6, H=8, d_ff=512 and V=50257.

  4. Dual-route morphological tokenizer

    NCTTokenizer maps frequent whole words to single tokens, decomposes other words into morphemes and falls back to UTF-8 bytes. It adds case-marker tokens and saves and loads in an HF-compatible format.

  5. Cognitive dataset generators

    Template generators produce synthetic documents for seven cognitive demand categories, including entity tracking, temporal ordering, inhibitory control, uncertainty calibration and multi-step reasoning. Each document carries metadata naming the NCT modules it targets.

  6. ODE training-dynamics surrogate

    NCTDynamicalSystem in dynamics.py Euler-steps scalar coupled subsystems of NCT V10.2 training. Noise is added so that the simulator can expose instabilities.

  7. Monte Carlo sensitivity engine

    monte_carlo.py samples parameter configurations by Latin hypercube, uniform or perturbation sampling and simulates each one. It reports Spearman sensitivities, the top configurations and 2D divergence maps.

  8. Parameter space registry

    parameter_space.py defines 33 tunable parameters with ranges, defaults, scale type, sensitivity tier and coupling class.

  9. Grid search and scenario engines

    grid_search.py runs one-at-a-time sweeps, pairwise grids and adaptive zoom refinement. scenarios.py runs ablations, coupling studies, the σ2\sigma^2 phase diagram, the gate opening cascade, counterfactuals and scale predictions.

  10. Algorithm comparison and algebra

    algorithmic_mathematics.py derives and simulates five biophysical replacements. run_algorithm_comparison.py compares the new and old versions over 100 paired-seed samples.

  11. Plotting and CLI

    run.py dispatches the Monte Carlo, grid search, scenario, sensitivity and full pipelines. visualize.py draws tornado plots, heatmaps, gate trajectories, ablation bars and stability maps.

  12. Architecture diagram generators

    generate_unified.py and generate_hybrid.py emit Excalidraw JSON for the V11 architecture and for the hybrid continuous-training decision flow.

Implementation

Mechanisms as they are implemented in the source code, with the constants the code uses.

Interaction-coupled mechanism gate dynamics
Each of the 24 gates receives a push p=(ueff−c)⋅12⋅g(1−g)⋅(0.8+0.4 DA)⋅(0.5+0.5 cp)⋅(0.3+0.7 a)p = (u_{eff} - c) \cdot 12 \cdot g(1-g) \cdot (0.8 + 0.4\,DA) \cdot (0.5 + 0.5\,cp) \cdot (0.3 + 0.7\,a), where cpcp is the critical period factor and aa the auxiliary fraction. The update is r←r+20 η pr \leftarrow r + 20\,\eta\,p on gate_raw, clipped to [-10, 10]. The cost is 0.01, or 1.0 for the disabled gates 5, 6 and 10, and each gate starts at σ(−2)≈0.119\sigma(-2) \approx 0.119.
Sigmoid-bounded Friston precision learning
The log-precision is γ=γmin+(γmax−γmin) σ(ω)\gamma = \gamma_{min} + (\gamma_{max} - \gamma_{min})\,\sigma(\omega) with γ∈[−1.609,2.303]\gamma \in [-1.609, 2.303], so that σ2=e−γ∈(0.1,5)\sigma^2 = e^{-\gamma} \in (0.1, 5). With free energy F=eγMSE−γF = e^{\gamma} \mathrm{MSE} - \gamma, the gradient is ∂F/∂ω=(eγMSE−1) ∂γ/∂ω\partial F / \partial \omega = (e^{\gamma}\mathrm{MSE} - 1)\,\partial \gamma / \partial \omega, and ω\omega moves by −η⋅0.1⋅15-\eta \cdot 0.1 \cdot 15 times the summed gradient. This drives σ2\sigma^2 toward MSE.
Asymmetric sigma2 boundary penalty
The KL term is λkl a (relu(0.3−σ2)2+relu(σ2−4.0)2)\lambda_{kl}\,a\,(\mathrm{relu}(0.3 - \sigma^2)^2 + \mathrm{relu}(\sigma^2 - 4.0)^2), whose gradient is zero inside the free zone [0.3, 4.0]. It replaces an older symmetric γ2\gamma^2 pull toward σ2=1\sigma^2 = 1. The code's sigmoid range (0.1, 5) is wider than the [0.3, 4.0] that the research report describes as bounded by construction.
Astrocyte calcium transient detector
Per layer, δt=∥gt∥−∥gt−1∥\delta_t = \|g_t\| - \|g_{t-1}\|, Ca←0.97 Ca+0.03 δCa \leftarrow 0.97\,Ca + 0.03\,\delta and gain=1+0.5tanh⁡(Ca)∈[0.5,1.5]\mathrm{gain} = 1 + 0.5\tanh(Ca) \in [0.5, 1.5]. This is the highpass filter H(z)=β(1−z−1)/(1−(1−β)z−1)H(z) = \beta(1 - z^{-1}) / (1 - (1-\beta)z^{-1}) with β=0.03\beta = 0.03: steady gradients give a gain of 1, and the code cites De Pitta 2009 for the detector. It replaces a dual-EMA detector (0.03/0.002) whose gain was 0.8+0.4 σ(5Δ)0.8 + 0.4\,\sigma(5\Delta).
D1/D2 dual-pathway Boltzmann modulation
D1=σ(k1(DA−0.65))D_1 = \sigma(k_1(DA - 0.65)) and D2=σ(k2(DA−0.25))D_2 = \sigma(k_2(DA - 0.25)) with k=8k = 8, using tonic dopamine. The modulation is M=d1D1−d2D2M = d_1 D_1 - d_2 D_2 and the output is X(1+gM)X(1 + gM). This replaces the symmetric 4 DA(1−DA)4\,DA(1 - DA) curve.
VIP to SST disinhibitory gating
The disinhibition is d=gvip σ(VIP(c))d = g_{vip}\,\sigma(\mathrm{VIP}(c)), so that seff=s(1−d)s_{eff} = s(1 - d) and the output is c (1−gsst seff)c\,(1 - g_{sst}\,s_{eff}), where cc is the top-down correction. Both gates start at σ(−2)≈0.119\sigma(-2) \approx 0.119, which gives near-identity behaviour (about 0.944) at initialisation. VIP is applied before SST, following Pfeffer 2013.
Baddeley phonological loop buffer
K=8 slots decay by a=σ(⋅)≈0.982a = \sigma(\cdot) \approx 0.982 per token. Rehearsal adds about 0.27 times the attention weight times the readout. Writes are gated by importance with bias -2, which gives about a 12% write rate. The predicted capacity is about 5 items with 4-token rehearsal.
Surprise-gated predictive coding
The prediction error is ϵ=X−X^\epsilon = X - \hat{X}, with surprise s=mean(ϵ2)s = \sqrt{\mathrm{mean}(\epsilon^2)} and gate g=σ(10(s−softplus(τ)))g = \sigma(10(s - \mathrm{softplus}(\tau))), where tau_init is 1.0. The output is (1−g)X^+gX(1-g)\hat{X} + gX, so predictable tokens are replaced by their prediction. The first layer uses a surprise of 1.
Six-signal neuromodulator
An MLP from d to 256 to 6 reads the context (mean+s⋅max)⋅max⁡(1+s−conf,0.1)(\mathrm{mean} + s \cdot \mathrm{max}) \cdot \max(1 + s - \mathrm{conf}, 0.1). It outputs attention temperature (0.5 to 2.0), FFN sparsity (0.1 to 1.0), layer gate (0 to 1), residual scale (0.1 to 2.0), inhibition strength (0 to 1) and plasticity rate (0.001 to 0.1). The output bias starts at 0.
Oscillatory phase-coherence binding
Each token has a soft membership ϕ\phi over P=4 phases. Each phase runs attention without RoPE, using the bias log⁡(ϕiϕj)(1+2 inh)\log(\phi_i \phi_j)(1 + 2\,\mathrm{inh}) with the product floored at 1e-4. The phase outputs are weighted by ϕ\phi and summed.
Cortical column agreement consensus
K=4 views of size d/K pass through one shared canonical circuit. Each column's agreement is its mean cosine similarity with the other columns, and the weights are softmax(agree/softplus(τcons))\mathrm{softmax}(\mathrm{agree} / \mathrm{softplus}(\tau_{cons})). The mean pairwise cosine is fed back to the neuromodulator as confidence.
Composite auxiliary loss
The NTP cross-entropy is summed with weighted auxiliary terms. The predictive coding term is the MSE between each layer's prediction and the detached next-layer output. The other terms are Lphase=(Hϕ−0.5ln⁡P)2L_{phase} = (H_\phi - 0.5 \ln P)^2 and Lei=(σ(α)‾−0.3)2L_{ei} = (\overline{\sigma(\alpha)} - 0.3)^2. A column diversity penalty on the squared cosine similarity of the column output projections is added with lambda_div = 0.01.
Dynamic reverse-mode autograd
Each operation computes its output and registers a closure that accumulates into the parents' .grad, reducing gradients correctly under broadcasting. backward() walks the graph iteratively in reverse topological order. A global _NO_GRAD_DEPTH counter disables graph building.
AdamW with warmup-cosine schedule
AdamW uses betas 0.9/0.999, eps 1e-8 and weight decay 0.1, with bias correction and decoupled decay. The learning rate rises linearly over 2000 warmup steps, then decays along a cosine to 1e-5. train.py clips the global gradient norm to 1.0 and saves .npz checkpoints every 500 steps.
Latin hypercube sampling
Each dimension of the parameter space receives exactly one sample per 1/n stratum. This gives better marginal coverage than uniform random sampling for the Monte Carlo runs.
Spearman rank sensitivity
Parameter importance is the rank correlation between sampled parameter values and outcome metrics. Pairs containing NaNs are dropped, and a parameter with fewer than 10 valid samples gets 0.
Adaptive grid zoom refinement
Each round is a full factorial grid with n points per dimension. The next round centres on the best result with its width multiplied by zoom_factor 0.3, clipped to the original bounds.
Ablation by utility zeroing
A mechanism is ablated by setting its gate's base utility to 0 instead of forcing the gate closed. The gate then receives no loss benefit and is never pushed open.
Paired-seed old/new algorithm comparison
Both variants run with identical seeds, a common-random-numbers form of variance reduction. Only the five overridden subsystems differ, over 100 samples, and the report prints mean and standard deviation deltas.
Scored greedy affix stripping
Suffixes are tried longest first, and each candidate is scored as root quality times 1000 plus the root length if the root is known, or the suffix length otherwise. Stripping stops early at a known root, with MAX_SUFFIXES=3, MAX_PREFIXES=2 and MIN_ROOT_LEN=3. A false-decomposition list and morphophonemic normalisation (runn to run, mak to make, happi to happy) refine the roots.
Difficulty-scaled entity curriculum
A difficulty d∈[0,1]d \in [0,1] sets the number of entities to 3+5d3 + 5d (3 to 8) and the gap to 50+450d50 + 450d tokens (50 to 500). Templates then rescale the gap by (0.3+0.7d)(0.3 + 0.7d) with a floor of 30, and documents are wrapped to at least 1500 tokens.
Tokenizer vocabulary build
build_vocab.py builds the vocabulary from WikiText-103 with options max_roots 8000, max_whole_words 5000 and minimum frequencies 5/3. It tests losslessness against GPT-2 BPE and retokenises the corpus into int32 .bin files. Ids 0 to 5 are special tokens, followed by 256 byte tokens.

Results

From the lab's own experiments and records. They have not been independently replicated.

  1. Zero divergence across the parameter space

    In the Run 13 simulations, 200 Monte Carlo samples across the full parameter space showed zero divergence.

  2. 16 of 24 gates open at default

    The research report records 16 of 24 gates opening reliably: 4 closed by design (utility 0) and 4 weak. TripartiteAChGate opened first, at step 1688, and was the strongest at 0.88.

  3. Precision converges slowly under tighter bounds

    In the simulations, σ2\sigma^2 approached the MSE more slowly with the [0.3, 4.0] bounds. The ratio σ2/MSE\sigma^2/\mathrm{MSE} was 2.22 at 7.5K steps and 1.34 at 50K.

  4. Default trajectory over 7500 steps

    Simulated NTP fell from 10.000 to 4.108 by step 500 and reached 4.027 at step 7500. Gates began opening around step 1700, and tonic dopamine dropped from 0.50 to 0.21, which the report reads as a shift from exploration to exploitation (Thm 47).

  5. Ablating all gates costs 0.21 NTP

    The scenario engine found that ablating all 24 gates raised NTP by 0.21. The NMDA slots and the phonological loop were the most essential.

  6. Working memory and inhibitory equilibria

    The NMDA level filled to 26%, the silent trace to 24% and the phonological loop to 3%. The inhibitory triad settled at SST 0.65, VIP 0.68, Apical 0.41 and Chandelier 0.11.

  7. Aggressive recipe is the best counterfactual

    lr=6e-4, gate_mult=30 and clip=3.5 gave NTP 3.94 against 3.96 for the default and opened 20 gates, according to the simulation records.

  8. Critical periods close near step 5500

    The report records critical periods closing by about step 5500, at a factor of 0.10.

  9. Stochastic resonance gate never opens

    Across training runs 9, 10, 11, 12 and 13, the StochasticResonance gate stayed near 0.117, and in simulation it was the only gate that never opened. The lab's analysis attributed this to noise that did not depend on the signal and derived a signal-dependent replacement. Its effect has not been measured.

Concepts

Mechanism gates
Each of the 24 biologically motivated mechanisms is scaled by a learned gate that starts near 0.119. The gate opens only when the mechanism lowers the loss more than it costs.
Scalar ODE surrogate
Instead of training the network, the simulator represents each subsystem by a few scalar state variables and integrates their coupled equations with Euler steps. This makes hundreds of runs cheap.
NTP loss
The next-token prediction cross-entropy, the main training loss the simulator tracks alongside MSE and σ2\sigma^2.
Friston sigma2 precision
σ2\sigma^2 is the learned variance of the prediction error, so its inverse is the precision. Minimising F=eγMSE−γF = e^{\gamma}\mathrm{MSE} - \gamma drives σ2\sigma^2 toward the MSE.
Sigmoid-bounded sigma2 (Thm 28g)
The Run 13 configuration bounds σ2\sigma^2 in [0.3, 4.0], which the research report states holds by construction.
Stochastic resonance
Adding noise lets a subthreshold signal cross a nonlinear threshold more often, which improves detection. Gammaitoni et al. 1998 name three required ingredients: a threshold, a subthreshold signal and noise matched to the gap between them.
Uniform noise gives no learning signal
The old module computed Xout=X+g ϵ σX_{out} = X + g\,\epsilon\,\sigma with ϵ∼N(0,I)\epsilon \sim N(0, I). The lab's analysis shows that near a smooth minimum E[∂L/∂σd]≈g2σd ∂2L/∂Xd2>0\mathbb{E}[\partial L / \partial \sigma_d] \approx g^2 \sigma_d\,\partial^2 L / \partial X_d^2 > 0, so gradient descent removes the noise and the gate closes.
Kramers escape argument
Citing Gerstner et al., Neuronal Dynamics, the analysis gives the escape rate as rK∝exp⁡(−ΔV/D)r_K \propto \exp(-\Delta V / D) with ΔV=(θ−u0)2\Delta V = (\theta - u_0)^2, and the optimal noise as about 23(θ−u0)\frac{2}{3}(\theta - u_0). The analysis argues that noise on subthreshold dimensions raises the chance of crossing the threshold and lowers the expected loss.
Signal-dependent stochastic resonance (Thm 48)
The proposed fix scales the noise by a subthreshold indicator instead of applying it uniformly. The analysis derives that the gate gradient then favours opening.
Tsodyks-Markram activity-silent trace (Thm 35)
A two-variable facilitation and depression trace replaces the additive working-memory trace. It is self-limiting and has stable eigenvalues.
Baddeley phonological loop (Thm 36)
A slot buffer with decay, content-addressable read, rehearsal and selective write. It replaces a blind cyclic write.
D1/D2 inverted-U (Thm 37)
Two sigmoid receptor curves with EC50 0.65 and 0.25 give an asymmetric inverted-U response to dopamine. The model follows Durstewitz and Seamans 2008.
VIP-SST disinhibitory motif (Thm 38/46)
VIP interneurons read the top-down correction and reduce SST suppression of it, giving a monotonic, bounded transfer function. The motif follows Pfeffer et al. 2013 on inhibition of inhibition.
Astrocyte transient detection (Thm 12)
A calcium highpass detector reacts to the rate of change of gradient norms and rejects their constant level. It replaces a dual-EMA bandpass.
Inhibitory triad
The SST, VIP, Apical and Chandelier components of cortical inhibition, which the simulator tracks as coupled state variables.
Working memory hierarchy
Four levels (NMDA active slots, activity-silent trace, phonological loop and D1/D2 gating) that develop progressively during simulated training.
Critical periods
A factor in the gate and learning dynamics that decays during training, locking learned representations once it closes.
Dual-route tokenization
Following the Coltheart DRC model, frequent words take a lexical route to one token and other words a sublexical morpheme route, with byte fallback. Case is carried by <cap> and <allcap> tokens, so the vocabulary stays lowercase and lossless.
Gamma-theta token alignment
A design target in which one token matches one gamma cycle and one morpheme, and a word spans one theta cycle of 3 to 7 tokens. The validation suite tests that most words have 1 to 3 tokens and nearly all have at most 7.
Cognitive demand categories
Seven demand types (entity tracking, temporal ordering, inhibitory control, uncertainty, conflict, attention and reasoning chains), each mapped to named NCT modules in the dataset metadata.
Wake-sleep training loop
Appears only in the V11 diagram generator, as design. Sleep pressure grows by 0.001(1+PE)0.001(1 + PE) per step, and sleep triggers at 0.7 or after 100 wake steps, followed by replay, weight downscaling by 0.99, noisy dreams and k-means consolidation into 8 clusters.

About this page

Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.

Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.