You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

plastic

Test-time-training models with a transactional safety harness, and a study of what they can learn lastingly from experience.

Live Workbench (plastic.dtmont.com) · Source on GitHub · Models on Hugging Face · Live Hugging Face Space

Weights: TTT chat safetensors · PlasticCore text · PlasticCore physics · Download instructions and checkpoint identities

plastic studies models that learn while they read: their memory is a set of fast weights that take gradient steps on a self-supervised objective as tokens arrive, so context is compressed into weights instead of a growing cache. Three substrates share one transactional safety harness:

  • PlasticCore (v1 & v2), a from-scratch model of ~6M parameters: a selective state-space recurrence plus fast-weight memory (delta, chunk, v2 deltaproduct with energy-coupled uniform boundedness, and v2 causal swiglu nonlinear memory="mlp"), meta-trained end to end through its inner loop. The same block stack serves text and hidden-friction physics.
  • A pretrained TTT-MLP chat model: the 760M TTT-MLP of Sun et al. (RetentionLabs conversion), whose sequence layer is a two-layer MLP updated by inner gradient steps on every 16-token mini-batch, chat fine-tuned for 250 steps on 8,000 SmolTalk conversations.
  • A coordinate block (experimental): a selective recurrence whose nonlinear fast weights change the coordinates of its own state with exact canonical carry transport, studied on a physics mechanism testbed.

A Qwen model is available as an observational comparison; it has no test-time-training layer.

Learning at inference is a security surface: every input is a gradient step, so a hostile input is not just a bad answer, it is a bad thing learned. plastic wraps the inner loop in a transactional harness—each chunk is a transaction that measures model-native signals (loss, surprise, write rate, update norm, curvature, probe drift, and anytime-valid risk wealth) and decides whether to commit, smoothly damp, project, roll back, or quarantine, with zero regex or keyword heuristics. Sessions are persisted and branchable, like version control for plastic weights.

This is a research sandbox, not a product. It runs in plain PyTorch on an Apple Silicon laptop or a single cloud GPU, and is explicit about what is proved, what is measured, and what remains open.


Four contributions in Plastic v2

Plastic v2 redesigns all three pillars from first principles. To keep priority claims honest (per AGENTS.md), each section below separates adopted 2024–2026 primary literature from what plastic v2 adds. Across the four pieces, norm-bounded per-prefix SwiGLU reads (Pillar A2) is the strongest algorithmic priority claim, and the transactional fast-weight safety harness (Pillar C) is the strongest systems contribution.

Pillar A1 — Endpoint-Capable Rank-2 Householder DeltaProduct with Uniform Boundedness

  • Adopted foundation: Negative-eigenvalue generalized Householders (Grazzi et al., ICLR 2025, arXiv:2411.12537), rank-$m$ Householder products (DeltaProduct, Siems et al., NeurIPS 2025, arXiv:2502.10297), decoupled erase/write gating (Gated DeltaNet-2, Hatamizadeh et al., Nov 2026, arXiv:2605.22791), and decay-regulated residual writing with an $O(\sqrt{T})$ state bound (Stable Gated DeltaNet-2, Zhang et al., Nov 2026, arXiv:2611.34051). The $\cot(\pi / 4n)$ operator norm of the unit-lower-triangular matrix below (yielding $\cot^2(\pi / 4n)$ via its alternating-sign inverse) is a classic theorem of Davies & Simon (2006) (J. Approx. Theory 141(2):189–213; mp_arc 06-50).

  • What plastic v2 adds (plastic/model/deltaproduct.py, tests/test_memory_v2.py):

    1. Length-independent uniform boundedness alongside exact orthogonal reflections. Standard signed DeltaProduct couples the additive write to $\beta_{t,r} \in [0, 2]$, which suffers linear resonant pumping ($\lvert S_t \rvert = 2t$ at $\beta=2, \alpha=1, v_t=(-1)^t$) and rotating-key $\Theta(\sqrt{T})$ norm growth even at $\beta=1, \alpha=1$. Whereas Stable Gated DeltaNet-2 (arXiv:2611.34051) couples writes to decay with an $O(\sqrt{T})$ bound, plastic v2's stricter decoupled gate (stability_mode="coupled_iss") trades stopping writes at full retention ($\alpha = 1 \implies \gamma = 0$) for a length-independent constant bound while permitting exact orthogonal reflections:

St,r=αt,r(I−βt,rkt,r⊤kt,r)St,r−1+γt,rkt,r⊤v^t,r,∥v^t,r∥2≤R, S_{t,r} = \alpha_{t,r}\bigl(I - \beta_{t,r} k_{t,r}^\top k_{t,r}\bigr) S_{t,r-1} + \gamma_{t,r} k_{t,r}^\top \hat{v}_{t,r}, \qquad \|\hat{v}_{t,r}\|_2 \le R,

γt,r=gt,r⋅min⁡ ⁣(1−∣1−βt,r∣,  1−αt,r),∥St∥F≤max⁡(∥S0∥F,  R)∀t≥0. \gamma_{t,r} = g_{t,r} \cdot \min\!\bigl(1 - |1 - \beta_{t,r}|,\; 1 - \alpha_{t,r}\bigr), \qquad \|S_t\|_F \le \max\bigl(\|S_0\|_F,\; R\bigr) \quad \forall t \ge 0.

(Terminology note: this is uniform boundedness, not Sontag input-to-state stability, because the exact identity/reflection mode $\alpha_{t,r}=1, \gamma_{t,r}=0$ deliberately preserves $S_0$ forever without decay under zero input.) For associative-recall workloads needing 1-shot writes at $\alpha \approx 1$, stability_mode="ball_retract" applies $\gamma_{t,r} = g_{t,r}(1 - \lvert 1 - \beta_{t,r}\rvert)$ with exact 1-Lipschitz Frobenius-ball retraction $\Pi_{B_R}$.

2. Endpoint-capable gates + optimal Job B initialization. Hard-clipped gates attain exact $\beta \in {0, 1, 2}$ (necessary so $m=2$ can realize odd $S_3$ transpositions via $\beta_1=2, \beta_2=0$ as well as planar rotations via $\beta_1=\beta_2=2$) and exact $\alpha=1$ at finite logits, initialized at $\beta=1$ to eliminate the 41% sample-efficiency penalty of sigmoid(0) = 0.5 under $c(\beta) = 2 / (2\beta - \beta^2)$.

3. Identifying repeated-key WY conditioning limits. For virtual chunk length $n = mL$ at $\alpha=1, \beta=2$ with identical keys, the unit-lower-triangular WY matrix $T = I + A$ reduces to the Davies–Simon (2006) matrix with exact inverse entries $(T^{-1})_{ij} = 2(-1)^{i-j}$ ($i > j$) and exact 2-norm condition number:

κ2(T)=cot⁡2 ⁣(π4n)∼16n2π2. \kappa_2(T) = \cot^2\!\left(\frac{\pi}{4n}\right) \sim \frac{16 n^2}{\pi^2}.

Recognizing where this matrix arises in repeated-key DeltaProduct WY solves dictates capping virtual chunk length at $n = mL \le 64$ ($L=32$ at $m=2$) and running solve_triangular strictly in fp32 (never Neumann powers or low-precision inversion).

Pillar A2 — Norm-Bounded, Per-Prefix SwiGLU Memory (memory="mlp"; strongest algorithmic priority claim)

  • Adopted foundation: Parallel dual-form prefix reads for nonlinear fast-weight MLPs (TTT-MLP, Sun et al., arXiv:2407.04620) and closed-form chunk-end momentum/decay on SwiGLU fast weights with chunk-start reads ($E^2$-TTT, Zhong et al., Nov 2026, arXiv:2608.21308).
  • What plastic v2 adds (plastic/model/swiglu_memory.py, plastic/model/memory.py): Replaces the unimplemented memory="mlp" (NotImplementedError in v1) and stale chunk-start reads (chunk_rule.py) with per-prefix reads of all three updated SwiGLU matrices $(W_1, W_2, W_3)$ under an in-prefix Frobenius norm cap without materializing $O(L d^2)$ per-token weight copies. For $f_W(x) = W_2 [\operatorname{SiLU}(W_1 x) \odot (W_3 x)]$, evaluating per-token inner gradients $G_i = \nabla_W \ell_i(W_c)$ at the chunk-start base $W_c$ yields rank-1 factors for all three matrices, giving exact evaluation of the stated common-base rule at every causal prefix weight $W_t = \rho_t Z_t$:

Zt=Wc−∑i≤tηiGi,Wt=ρtZt,ρt=min⁡ ⁣(1,  RW∥Zt∥F),∥fWt(q)∥2≤RW3Q2, Z_t = W_c - \sum_{i \le t} \eta_i G_i, \qquad W_t = \rho_t Z_t, \qquad \rho_t = \min\!\left(1,\; \frac{R_W}{\|Z_t\|_F}\right), \qquad \|f_{W_t}(q)\|_2 \le R_W^3 Q^2,

where $|Z_t|F$ is computed in closed form from causal Gram matrices of the rank-1 factors, and chunk-end momentum/decay uses division-free log-space $E^2$-TTT accumulation. *(Scope note: "exact" applies strictly to this stated common-base rule with gradients evaluated at chunk start $W_c$, not sequential SGD through evolving weights $W{t-1}$.)*

Pillar B — 3-Way Epistemic Separation & Cue-Indexed On-Policy Sleep Consolidation

  • Adopted foundation: Google's SLEEP framework (Language Models Need Sleep, Behrouz et al., arXiv:2606.03979) for offline weight consolidation via Knowledge Seeding and generated practice/dreaming; offline consolidation and memory-admission filtering against planted/contaminated memories (Auto-Dreamer, Zhao et al., NeurIPS 2026, arXiv:2605.20616; A-MAC, Zhang, Zhao et al., arXiv:2603.04549; ConsistencyGate, Zhang & Li, arXiv:2607.22962; DREAM, Liu et al., arXiv:2610.13267); context distillation (Padmanabhan et al., arXiv:2306.09306; DiSC, arXiv:2602.16093); self-study (Cartridges, 2506.06266; SEAL, 2506.10943); and Rao–Blackwellized on-policy reverse-KL self-distillation (SDFT, Shenfeld et al., arXiv:2601.19897v2; BOPD, arXiv:2611.13680).
  • What plastic v2 adds (plastic/sleep/epistemic.py, plastic/sleep/clusters.py, plastic/sleep/consolidation_v2.py, tests/test_sleep_v2.py):
    1. 3-Way Epistemic Separation (Novelty $\neq$ Harm): Fixes v1's surprise-based flagged_policy="exclude" (which dropped 29/30 valid teaching turns) by separating (a) typed scoped evidence records $m = (s, r, o, \kappa, t, \text{speaker}, \text{source}, \text{prov})$ distinguishing user-scoped personal_reports from world_claims; (b) decision-theoretic admission (retain_scoped vs. quarantine on high scoped semantic conflict $C(q; z, z') = \log\frac{\widehat{P}_0(z' \mid q, \kappa)}{\widehat{P}_0(z \mid q, \kappa)}$ without independent corroboration); and (c) separate Fisher behavioral interference $\frac{1}{2}\Delta^\top F_P \Delta$. (Important implementation disclosure: in plastic/sleep/epistemic.py, quarantining the 4/4 planted world contradictions relied on _WORLD_PATTERNS and supplied canonical alternatives in _BUILTIN_WORLD_PRIORS scored alongside the reset model's greedy answer. This demonstrates that the admission policy can act on supplied reference knowledge while admitting all 24 novel personal reports; open-world detection of unfamiliar falsehoods remains open.)
    2. Cue-Indexed Multi-View Study Clusters + Hybrid SDFT + Metric-Projected Trust Region: Eliminates v1's 1-to-24 unindexed dreaming collision (whose exact forward-KL optimum is the mixture $p^\star(y \mid q) = \sum_i w_i p_i(y)$) by building entity/relation-indexed views (forward_qa, paraphrase_qa, identifiable reverse_qa, entailment_qa), trained via hybrid supervised + forward-KL + Rao–Blackwellized on-policy reverse-KL SDFT across dual targets (W0 + slow MLP LoRA) under the local metric-projected trust-region step:

PM=I−M−1C⊤(CM−1C⊤)†C,v=PMM−1g,Δ⋆=−ρvv⊤Mv,ηavail=∥PMM−1g∥M∥M−1g∥M. P_M = I - M^{-1} C^\top (C M^{-1} C^\top)^\dagger C, \qquad v = P_M M^{-1} g, \qquad \Delta^\star = -\rho \frac{v}{\sqrt{v^\top M v}}, \qquad \eta_{\text{avail}} = \frac{\|P_M M^{-1} g\|_M}{\|M^{-1} g\|_M}.

Pillar C — Transactional Fast-Weight Safety Harness & Frozen-Anchor Minimax Training (strongest systems contribution)

  • Adopted foundation: Whole-trajectory conformal calibration (Zhou, Lindemann, & Sesia, ICML 2024, PMLR v235), Predictive Rank Martingales (PRM, arXiv:2609.00536), non-partitioned e-detectors (Saha & Ramdas, arXiv:2607.28322), Conformal Policy Control (CPC, Prinster et al., ICML 2026, arXiv:2603.02196), rotating safety-Fisher subspaces (SafeAnchor, arXiv:2604.17691), and second-order curvature-coupling collapse (Springer et al., arXiv:2602.15799).

  • What plastic v2 adds (plastic/harness/, plastic/train/adversarial.py, plastic/redteam/attack.py, tests/test_harness_v2.py):

    1. Dependence-Honest Sequential Control + Orthogonal Deterministic Budget. Naive split-conformal e-processes violate Ville's inequality under finite calibration reuse (exact 11.1% violation at $n_{\text{cal}}=1$ for nominal 1%) and Markov state dependence. Harness v2 combines Route-C Closed-Loop Full-Trajectory Session Calibration (which provides a finite-horizon false-alarm guarantee $\Pr_0(\text{any intervention} \le T) \le \alpha$ specifically for the stated horizon $T$ and exchangeable benign sessions), a live innovation-whitened strided PRM weighted-SR e-process $Z_t$ driving smooth CPC write authority $\gamma_t \in [0, 1]$ (replacing binary permanent latching), and an orthogonal deterministic full-state path budget $\sum_t |S_t - S_{t-1}|F \le B{\text{path}}$. On our vocab-128 benchmark (n=200 disjoint 16-chunk sessions), this operating point achieved 0/200 benign sessions flagged alongside 22/64 poison sessions detected (16/16 random, 3/16 repeat-phrase, 3/16 shuffled, 0/16 repeat-token).

    2. Exact I5 Manifold-Aware Scaling & I1-strict Atomic Tuple Rollback. Fixes v1's 4× scaling paradox (beta_scale=0.5 leaving decay unscaled) via exact complete-transition interpolation for Euclidean states and exact chord-contracting angle reparameterization for Householder reflections $H(u) = I - 2uu^\top$:

Sγ=Scomm+γ(Swork−Scomm),θγ=arcsin⁡(γsin⁡θ)    ⟹    ∥H(uγ)−H(u)∥F=γ∥H(v)−H(u)∥F. S_\gamma = S_{\text{comm}} + \gamma\bigl(S_{\text{work}} - S_{\text{comm}}\bigr), \qquad \theta_\gamma = \arcsin(\gamma \sin\theta) \;\implies\; \|H(u_\gamma) - H(u)\|_F = \gamma \|H(v) - H(u)\|_F.

3. Multi-Constraint Woodbury Curvature QCQP + Frozen-Reference Minimax Training. Replaces hardcoded project_eps_cos=0.02 with a calibrated second-order proposal generator (corrected conservative poison sign $-g_p^\top \Delta + \frac{\kappa_p}{2}|\Delta|2^2 \le \tau_p$, SafeAnchor incremental-SVD subspace tracking, and mandatory finite canary recheck), and replaces v1's unclamped after - before adversarial loss with a **frozen-reference $\theta{\text{ref}}$ constrained minimax objective** over fluent discrete GCG/ST attacks paired with an explicit retained-write utility floor $U_{\text{write}}(\theta) \ge U_{\min}$.


v1 vs. v2 Verified Empirical Results

Every number below is read directly from committed raw benchmark outputs and reports (experiments/exp_v2_core/results/, experiments/exp_v2_sleep/REPORT.md, experiments/exp_v2_harness/REPORT.md).

Pillar & Benchmark Metric Plastic v1 Plastic v2 Source & Verification
A1. State Tracking (S3, train 8–32) Accuracy at $L=32 / 64 / 128 / 256 / 512 / 1024$ (2 seeds) 0.327 / 0.245 / 0.209 / 0.185 / 0.178 / 0.171 1.000 / 1.000 / 0.971 / 0.814 / 0.598 / 0.413 state_tracking.json, test_memory_v2.py
A1. State Tracking (mod3, train 8–32) Accuracy at $L=32 / 64 / 128 / 256 / 512 / 1024$ (2 seeds) 0.838 / 0.593 / 0.466 / 0.398 / 0.365 / 0.351 1.000 / 1.000 / 1.000 / 1.000 / 0.897 / 0.611 state_tracking.json
A1. State Tracking (parity, train 8–32) Accuracy at $L=32 / 64 / 128 / 256$ (2 seeds) 0.763 / 0.636 / 0.570 / 0.532 1.000 / 0.993 / 0.844 / 0.679 state_tracking.json
A1. Job B Precision Scaling ($d=128$) Slope (theory opt 2.0) / median samples to $10^{-6}$ 2.805 / 4,961 1.982 / 3,505 (-29.4% samples) job_b_mqar.json
A1. MQAR Recall (500 steps) Final eval accuracy (ball_retract vs coupled_iss*) 0.239 0.271 (coupled_iss: 0.154*) job_b_mqar.json
A2. Nonlinear Recall (memory="mlp") Eval MSE / $R^2$ (800 steps) 0.1448 / 0.160 (linear delta) 0.0360 / 0.791 (4.0× lower MSE) swiglu_nonlinear.json
B. Sleep on 760M TTT-MLP (A100, full reset, 1 seed) Taught verbatim recall / unseen paraphrase (/24) 0/24 (0.0%) / 0/24 (0.0%) 20/24 (83.3%) / 15/24 (62.5%) exp_v2_sleep/REPORT.md, summary_760m.json vs summary_760m_v1_baseline.json
B. Sleep 760M Epistemic & Locality Admission / plants quarantined§ / NLL $\Delta$ / cluster share 0/24 admitted / Moon collapse / -0.171 / 0.143 24/24 admitted / 4/4 quarantined§ / +0.0131 / 0.0714 summary_760m.json, test_sleep_v2.py
C. Harness Operating Point ($n=200$ benign + $64$ poison, 16 chunks) Benign ANY-intervention [95% CI] / Poison sessions caught (random) 200/200 = 100.0% (78.2% ch; Exp 3 WT103: 47.8%) / 62/64 (16/16) **0/200 = 0.00% [0.00%, 1.88%] / 22/64 (16/16 random)**† exp_v2_harness/REPORT.md, results.json, test_harness_v2.py
C. Adversarial Training (Minimax) Held-out NLL / write utility $U_{\text{write}}$ / PGD / Fluent GCG dmg 3.201 / +0.145 / -0.435‡ / -0.126‡ 3.138 / +0.152 / +0.198 / +0.137 (vs base +0.718 / +0.500) exp_v2_harness/REPORT.md, results.json

Honest footnotes on measured tradeoffs & scope:

  • * coupled_iss vs. ball_retract on MQAR: Strictly coupling write amplitude to $1 - \alpha_t$ (coupled_iss) trades away 1-shot associative write strength at high retention (0.154 vs 0.239); ball_retract preserves 1-shot MQAR writes (0.271) while maintaining the Frobenius-ball norm bound.
  • § Supplied canonical alternatives in epistemic.py: The 4/4 quarantined planted contradictions matched _WORLD_PATTERNS and used supplied canonical alternatives in _BUILTIN_WORLD_PRIORS (plastic/sleep/epistemic.py) alongside reset-model scoring—showing the policy acts on supplied knowledge while open-world detection of unfamiliar falsehoods remains open. The main empirical result is the single-seed post-reset recall (20/24 verbatim, 15/24 unseen paraphrase) at +0.0131 NLL drift.
  • † Harness v2 full operating point: On the vocab-128 benchmark (experiments/exp_v2_harness/REPORT.md), holding benign session intervention at 0/200 = 0.00% (0/3,200 chunks) detected 22/64 = 34.4% of poison sessions (16/16 = 100.0% random, 3/16 = 18.8% repeat_phrase, 3/16 = 18.8% shuffled, 0/16 = 0.0% repeat_token), whereas v1's 62/64 came at 200/200 = 100% benign session flagging. Low-loss repetition poisons require explicit low-entropy/compression features or a higher recall operating point.
  • ‡ v1 unclamped adversarial loss artifact: Negative PGD/GCG damage (-0.435, -0.126) under v1 reflects its unclamped after - before objective rewarding perturbations that lower coherence loss relative to a moving baseline rather than strictly bounding worst-case drift against a frozen anchor $\theta_{\text{ref}}$.
  • Scope caveats: State tracking ran 2 seeds on CPU (not yet the 8-seed GPU sweep); 760M Sleep v2 ran 1 seed on the 24 historical facts (general knowledge probes moved 3/7, 4/7 -> 2/7, 2/7; the 200-fact / 300-plant 5-seed confirmatory battery and Exp 4 v2 composition benchmark remain next).

Where the research stands

The core question is whether experience can change a model's weights so that it performs better on unseen situations after the conversation and fast-weight state are gone, with the benefit disappearing when weights are restored, and while refusing wrong or adversarial lessons. See current status for the complete timeline.

  • Sleep v2 broke the 0/24 barrier on the published 760M TTT-MLP checkpoint (single seed): On NVIDIA A100, sleep_v2_dual raised post-reset taught recall from 0/24 (verbatim and unseen paraphrase) to 20/24 verbatim (83.3%) and 15/24 unseen paraphrase (62.5%) with +1.126 nats/tok answer log-prob lift, +0.0131 held-out SmolTalk NLL drift, and 0.0714 reply cluster share (experiments/exp_v2_sleep/REPORT.md). The admission policy admitted 24/24 novel personal reports and quarantined 4/4 planted contradictions using supplied canonical alternatives in epistemic.py (open-world detection of unfamiliar falsehoods remains open). Multi-seed and 200-fact / 300-plant confirmatory runs are next.
  • Fast-weight core v2 solved $S_3$/mod3/parity in-distribution & mid-horizon extrapolation, removed the Job B sample penalty, and shipped norm-bounded per-prefix SwiGLU fast memory (experiments/exp_v2_core/, tests/test_memory_v2.py).
  • Harness v2 eliminated benign session lockout (0/200 benign flagged alongside 22/64 poison detected, 16/16 random, vs. v1's 200/200 benign flagged), passed I1-strict and I5 (including Householder chord-contracting scaling), and fixed adversarial minimax training (experiments/exp_v2_harness/REPORT.md, tests/test_harness_v2.py).
  • Live Workbench v2 is deployed at plastic.dtmont.com (Cloudflare Worker + Cloud Run) alongside the repaired CPU-PyTorch Hugging Face Space (huggingface.co/spaces/dmontgomery40/plastic), with live counterfactual inspection (adapted vs. frozen vs. unguarded), v2 wealth/authority telemetry, and interactive Sleep Lab (tests/test_api_v2.py).
  • Archived Sept 2026 baselines (retained as evidence): On the text rule task, 20 steps on W0 improved second-answer format adaptation (0.31 -> 1.0) but failed first-answer wrong-name controls (corrected runs); the experimental coordinate block matched the v1 delta baseline on physics on one seed.

Install and run

uv sync --extra dev --extra pretrained   # pretrained: transformers, for the TTT and Qwen backends; add --extra jev for Jev grading
npm --prefix dashboard ci
uv run pytest                            # full test suite (incl. test_*_v2.py)
uv run plastic --help
./start.sh                               # API on :13579, dashboard on :5173

Python 3.12, PyTorch 2.12 or newer. MPS on Apple Silicon, CUDA on Hugging Face Jobs / Cloud Run.

The from-scratch model (PlasticCore)

One block, stacked four times for text and three for physics, all in plain PyTorch on CPU, MPS, and CUDA.

A selective state-space branch provides activation-level context: a gated linear recurrence with per-channel input-dependent decay computed by a chunked log-space scan whose pairwise decay ratios lie in $(0, 1]$ (exact against a sequential reference to within $2 \times 10^{-5}$).

A fast-weight memory branch implements the test-time-training layer behind one interface (plastic/model/memory.py) supporting four rules/memories:

  • rule="delta" (v1 baseline): single-step gated delta rule with $\beta_t \in (0, 1)$:

et=vt−kt(αtSt−1),St=αtSt−1+βtkt⊤et,mt=qtSt. e_t = v_t - k_t(\alpha_t S_{t-1}), \qquad S_t = \alpha_t S_{t-1} + \beta_t k_t^\top e_t, \qquad m_t = q_t S_t.

  • rule="chunk" (v1 mini-batch): chunk-level updates with Titans momentum and optional Newton–Schulz orthogonalization.
  • rule="deltaproduct" (v2 Pillar A1, plastic/model/deltaproduct.py): endpoint-capable rank-2 Householder DeltaProduct ($\beta_{t,r} \in [0, 2]$, $\alpha_t \in [\alpha_{\min}, 1]$) with decoupled uniform boundedness (coupled_iss) or Frobenius-ball retraction (ball_retract) and exact fp32 virtual-chunk WY solves ($n = mL \le 64$).
  • memory="mlp" (v2 Pillar A2, plastic/model/swiglu_memory.py): norm-bounded per-prefix SwiGLU memory (exact for the common-base rule) with closed-form Gram-matrix norm capping and $E^2$-TTT chunk-end momentum/decay.

Meta-training runs sequences from initial fast state $S_0$ and backpropagates ordinary next-token loss through every inner update. Both delta and deltaproduct have closed-form chunk-parallel WY forms matching their recurrent inference paths; swiglu prefix memory evaluates exact causal rank-1 updates in parallel.

The pretrained TTT chat model

plastic/backends/ttt_lm/ runs the 760M TTT-MLP under the same harness. Its inner loop's reconstruction error (surprise), learned per-token step size, and exact per-token write norm are transaction signals, and freezing holds fast weights bit-identically. The base chat checkpoint was fine-tuned for 250 steps on SmolTalk (evaluation) and serves as the 760M substrate for the Sleep v2 consolidation benchmark above.

The safety harness

Every input chunk is a transaction against three copies of the session state: committed, working, and the pending chunk. At each chunk boundary the harness computes signals entirely from the model and decides what to do with the update.

Signal What it is
chunk loss the model's own confusion on the chunk (out-of-distribution proxy)
surprise the inner-loop prediction error $\lVert e_t \rVert_2$, independent of the write rate
write rate $\beta$ the learned gate the model applied to each token
update norm & path budget actual representable state delta $\lVert S_t - S_{t-1} \rVert_F$, cumulative path $\sum d_t \le B_{\text{path}}$, and Fisher-weighted size
canary suites a coherence set whose loss must not rise, a poison set whose loss must not fall
curvature & alignment canary gradient alignment, multi-constraint Woodbury QCQP residual, and rotating safety-Fisher quadratic form $\frac{1}{2}\Delta^\top F_P \Delta$
sequential risk wealth v2 Route-C closed-loop trajectory calibration + whitened strided PRM weighted-SR e-process $Z_t$ $\to$ smooth CPC write authority $\gamma_t \in [0, 1]$ (plus v1 two-sided CUSUM for comparison)

Decisions are commit, scale (smooth CPC risk damping or budget scaling using exact complete-transition interpolation / Householder chord-contracting angle scaling), project (multi-constraint curvature QCQP proposal + mandatory finite canary recheck), rollback (atomic I1-strict restore of fast state + pending chunk stats, reading frozen without learning), or read-only / quarantine (spent deterministic budget or hard wealth threshold requiring verification). There is no regex, no keyword list, and no string inspection anywhere in the harness.

These signals measure how the model responds to an update; none proves that an arbitrary statement is true. The shipped chat canaries are 12 public true statements, 12 public contradictions, and three repetition probes: a small public specification of what to preserve, not protection for behavior outside it.

Domains and testbeds

Text. Byte-level BPE, wikitext-103 (or fineweb-edu). Next-token prediction, MQAR recall probes, and writes-enabled vs. writes-disabled comparisons.

Physics. A 2D point mass with an unobserved friction coefficient ([observation, action, reset flag] $\to$ next observation delta). On a laptop the adaptive model reaches MSE 0.0008 where the frozen-memory model sits at 1.04 (while an analytic causal estimator knowing the simulator equation reaches 2.8e-5). Physics stays an internal benchmark; the public workbench serves text.

Learning testbeds. A physics mechanism testbed (six hidden mechanisms) and a text rule task (named decorations of a word list) separate lasting weight updates from temporary in-context adaptation.

Sessions, red team, and sleep

Sessions persist their plastic weights, harness state, and full transaction log, and can branch (plastic session fork|reset|resume|show). plastic redteam attacks a model on the real discrete token path (including v2 fluency-constrained GCG/ST discrete attacks) and re-validates payloads through the guarded transaction runner. plastic train --adversarial meta-trains the write gate under the frozen-reference minimax objective. plastic sleep consolidates accepted session experience into durable weights behind both epistemic admission (Sleep v2) and post-reset verification gates.

Usage

# data and training
uv run plastic data prepare --corpus wikitext --out artifacts/data/wikitext
uv run plastic train text --data artifacts/data/wikitext --steps 3000 --device mps
uv run plastic train physics --steps 3000 --layers 3 --device mps
uv run plastic models

# a GPU run on Hugging Face Jobs (exports committed HEAD; uncommitted edits are not included)
scripts/hf_jobs/launch_text.sh l4x1 6000 BATCH=16 MODEL_ID=lm_wikitext_l4
hf jobs logs -f dmontgomery40/<job_id>
hf buckets sync hf://buckets/dmontgomery40/plastic-runs/artifacts/models/<id> artifacts/models/<id>

# calibrate the harness, then open a session
uv run plastic calibrate <model_id> --data artifacts/data/wikitext
uv run plastic session new --model <model_id>
uv run plastic chat <session_id> "your prompt here"
uv run plastic physics <session_id> --steps 256 --mu 0.12

# attack and consolidate
uv run plastic redteam <model_id> --data artifacts/data/wikitext --record
uv run plastic sleep <model_id> --core artifacts/data/wikitext

# v2 verification & benchmarks
uv run pytest tests/test_memory_v2.py tests/test_sleep_v2.py tests/test_harness_v2.py tests/test_api_v2.py
uv run python experiments/exp_v2_core/bench_state_tracking.py
uv run python experiments/exp_v2_harness/benchmark_v1_vs_v2.py

Layout

plastic/
  model/        selective scan, delta rule, v2 deltaproduct, v2 swiglu_memory, chunk rule, coordinate block, blocks, models, state
  backends/     PlasticCore, pretrained 760M TTT-MLP, Qwen (observational)
  data/         wikitext/fineweb pipeline, MQAR recall probes, hidden-mu physics, mechanism testbed, text rules
  train/        outer loop, LR schedule, Muon/AdamW split, v2 frozen-reference minimax adversarial training
  harness/      signals, PRM/e-process stats, Route-C calibration, canaries, Fisher, Woodbury QCQP projection, CPC policy, transaction runner
  eval/         learning contracts and learners
  session/      persisted, branchable sessions
  redteam/      discrete token-path attacker (PGD + fluent GCG) validated through the harness
  sleep/        v1 replay/distill/anchor/dream + v2 epistemic admission, cue-indexed clusters, hybrid SDFT consolidation
  api/          FastAPI service with ephemeral sandboxes and live counterfactual endpoints
  store.py      models, sessions, transactions, forks, signatures
  cli.py        the `plastic` command
dashboard/      React workbench (`plastic.dtmont.com` & HF Space)
experiments/    exp1–exp4 baselines + exp_v2_core, exp_v2_sleep, exp_v2_harness
scripts/        Hugging Face Jobs launchers, training, experiments
docs/           design specs, research notes and surveys, archived results

Archived v1 Experiments (Baselines Retained as Evidence)

  • Exp 1 & 2 (Eigenvalue ablation & rollback leakage): report/REPORT.md, experiments/gpu/REPORT.md. Showed v1 $\beta \in (0, 1)$ fails $S_3$ (0.324 at $L=32$) and drops to chance by $L=128$, while Job B established the $c(\beta) = 2/(2\beta - \beta^2)$ slope and the 41% penalty of sigmoid(0).
  • Exp 3 (v1 harness invariants & policy-level FPR): experiments/exp3_invariants/README.md. Exposed the 47.78% benign session intervention rate under v1's resetting CUSUM latch and uncapped project_eps_cos=0.02, plus minimal counterexamples for I1-strict and I5 (now resolved in v2).
  • Exp 4b/4c (First-answer composition of group actions, 60k–83k GPU steps): experiments/exp4_compose/REPORT_4b.md. Demonstrated content-dependent fast-weight composition through depths 2–3 (and partial depth 4 on one seed) against deranged-name content nulls, motivating v2's iterative readout and nonlinear fast memory.

Honest limits

  • PlasticCore is small (~6M parameters on wikitext); it demonstrates fast-weight dynamics, recall, and safety-harness behavior, not frontier language quality. The 760M TTT-MLP chat checkpoint is briefly fine-tuned (250 steps) and still makes general factual errors.
  • The 760M Sleep v2 result (20/24 verbatim, 15/24 unseen paraphrase) is a single-seed Phase-0 result on the 24 historical facts (with general knowledge moving 3/7, 4/7 -> 2/7, 2/7); its 4/4 quarantined planted contradictions used supplied canonical alternatives in plastic/sleep/epistemic.py (open-world falsehood detection remains open), and multi-seed 200-fact / 300-plant confirmatory validation plus Exp 4 v2 composition runs remain next.
  • Harness v2's 0/200 benign session FPR (22/64 poison sessions caught; 16/16 random) on the vocab-128 benchmark holds at the calibrated horizon for exchangeable benign sessions and trades recall on low-loss repetition poisons (repeat_token 0/16); any statistical detector can be evaded by a benign-mimicking adversary, which is why hard worst-case damage bounds rest on the orthogonal deterministic path budget $B_{\text{path}}$ and finite canary rechecks.
  • Every architectural primitive we built upon (generalized Householders, DeltaProduct, Stable Gated DeltaNet-2, Davies–Simon 2006, TTT-MLP, $E^2$-TTT, Google SLEEP, Auto-Dreamer, SDFT, DiSC, whole-trajectory conformal calibration, PRM, CPC, SafeAnchor) is credited prior work; plastic v2's clearest priority claims are norm-bounded per-prefix SwiGLU reads (algorithmic) and the transactional fast-weight safety harness (systems).

License

See LICENSE. Research and educational use.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using dmontgomery40/plastic 1

Papers for dmontgomery40/plastic