CARMA v0.3 β Contributor-Aware Residual Memory Transformer
An experimental, 3.79M-parameter causal language model exploring multiple residual-memory lanes, zero-centred adaptive controls, contributor routing, and provenance/trust state tracking.
Research snapshot, not a production-ready or compute-efficient Transformer replacement. In the original recorded TinyStories experiment, CARMA v0.3 reached 16.9589 test perplexity compared with 22.3697 for a parameter-matched vanilla Transformerβapproximately 24.2% lower perplexity. The accompanying microbenchmark also measured approximately 5Γ the batch latency of that vanilla baseline. This is one controlled experiment, not proof of general improvement across datasets, seeds, or compute budgets.
Overview
CARMA (Contributor-Aware Residual Memory Architecture) is a proof-of-concept Transformer variant. Instead of maintaining only one residual stream, v0.3 maintains four lanes: one anchor lane and three auxiliary lanes. Adaptive readers construct an input to each attention/MLP sublayer from these states; zero-centred updaters write the resulting information back to the lanes. Additional differentiable bookkeeping tracks approximate computational provenance (which model sublayer contributed to a representation) and a learned trust state.
The novel part of this particular implementation is the combination of these mechanisms. Individual ingredients such as residual gating, RMSNorm/LayerNorm mixing, and multi-stream representations have precedents. This repository does not establish priority over all related techniques.
Research questions
- Can multiple residual-memory lanes improve small-model language modelling?
- Can zero-initialised, bounded controls permit stable training from a vanilla-equivalent starting point?
- Do adaptive normalisation and residual corrections improve held-out loss at similar parameter count?
- Can the additional memory, provenance and trust-state computation eventually justify its cost?
Architecture
| Parameter | CARMA v0.3 |
|---|---|
| Total parameters | 3,788,279 |
| Vocabulary | 50,257 tokens |
| Maximum context | 256 tokens |
| Transformer blocks | 8 |
| Hidden size | 64 |
| Attention heads | 16 (head dimension 4) |
| Feed-forward dimension | 256 |
| Residual lanes | 4 (1 anchor + 3 auxiliary) |
| Provenance embedding dimension | 8 |
| Lane identity embedding dimension | 4 |
| Controller hidden dimension | 32 |
| Output projection | Tied to the input token embedding |
The backbone uses causal scaled dot-product self-attention, GELU feed-forward blocks and Pre-LN-style residual computation. This is not a drop-in transformers.AutoModelForCausalLM architecture; use carma_v03.py and the loader below.
1. Adaptive reading and normalisation
For each lane state (M_k), the reader blends LayerNorm, the unnormalised state, and RMSNorm:
The gates are bounded, zero-centred tanh outputs of controller networks conditioned on lane state, anchor state, provenance summary, trust, and lane identity. With (k=0) denoting the anchor, the sublayer input is
The route coefficients (r_k) are bounded; the resulting mixture is not required to be a probability distribution and may contain signed contributions.
2. Zero-centred residual-memory updates
After attention or the feed-forward network computes contributor update (C), each lane is updated as
where (b_0=1) for the anchor and (b_k=0) for auxiliary lanes. Equivalently,
The forget, replace, and add controls are bounded zero-centred corrections. Their names describe the update operations; they should not be interpreted as independently validated cognitive mechanisms.
3. Provenance and trust bookkeeping
Each lane carries a differentiable provenance vector over one embedding source and the attention/FFN contributor from each of the eight layers (17 sources in total). The update rule combines absolute coefficient magnitudes with a source one-hot vector. It also maintains a bounded latent trust state for routing.
Important: These are internal computational diagnostics, not factual citations, external evidence provenance, calibrated confidence, or safety guarantees.
4. Vanilla-equivalent initialisation
The contextual controller-output projections and global correction parameters initialise to zero. With the shared vanilla backbone weights, the initial CARMA computation reduces to the vanilla residual update. Recorded preflight.json checks report zero initial logit/loss difference and nonzero controller gradients. These are preflight checks, not a proof that all training trajectories remain equivalent.
Original experimental results
The figures below come directly from final_results.json in the provided v0.3 archive. They are from the original v0.3 experiment, not later CARMA-Alpha experiments or separate follow-up replications.
| Model | Parameters | Validation loss β | Validation perplexity β | Test loss β | Test perplexity β |
|---|---|---|---|---|---|
| Vanilla, exact backbone | 3,632,832 | 3.14147 | 23.13796 | 3.15439 | 23.43874 |
| Vanilla, parameter-matched | 3,789,696 | 3.09463 | 22.07910 | 3.10771 | 22.36975 |
| CARMA v0.3 | 3,788,279 | 2.81691 | 16.72509 | 2.83079 | 16.95888 |
CARMA's original test perplexity is 24.19% lower than the parameter-matched vanilla baseline. This comparison uses approximately the same total parameter count, not identical forward/backward compute, GPU time or inference latency.
Reported training setup
| Item | Recorded configuration |
|---|---|
| Dataset | karpathy/tinystories-gpt4-clean |
| Pinned dataset revision | 0397e27157956705a0260709da3095bb9c43d6a7 |
| Tokenizer source | roneneldan/TinyStories-1M |
| Context length | 256 |
| Training epochs | 2 |
| Microbatch / gradient accumulation | 64 / 4 |
| Learning rate | 3e-4 |
| Weight decay | 0.1 |
| Warmup | 5% of training |
| Gradient clipping | 1.0 |
| Reported data partition | Test: stories 0β9,999; validation: 10,000β19,999; training: 20,000β519,999 |
| Evaluated token counts | Validation: 1,980,330; test: 1,990,785 |
dataset_manifest.json includes dataset and packed-split fingerprints for auditability. The dataset is not included in this repository. The ZIP also does not contain the original executable training/evaluation script or pinned Python environment, so the original result is documented but not fully reproducible from this release alone. Please do not describe it as an independently replicated finding on the basis of this archive.
Efficiency: an important limitation
The recorded benchmark.json batch microbenchmark reports:
| Model | Batch latency β | Tokens/second β |
|---|---|---|
| Vanilla, exact backbone | 8.810 ms | 1,859,675 |
| Vanilla, parameter-matched | 8.787 ms | 1,864,504 |
| CARMA v0.3 | 43.974 ms | 372,586 |
In this microbenchmark, CARMA had roughly 5.0Γ the batch latency and 20% of the throughput of the matched vanilla model. benchmark.json does not identify the full GPU and software environment, so these measurements are provided as original logs rather than portable performance guarantees. No claims about equal-GPU-time superiority or efficient autoregressive decoding should be inferred.
Qualitative samples
generations.json contains example prompts and generations for the tested models. They are illustrative and should not be treated as quantitative evaluation.
Installation
Python 3.10+ and a recent PyTorch build with torch.nn.functional.scaled_dot_product_attention are recommended. Exact package versions used for the historical experiment were not included in the source archive.
python -m pip install torch safetensors transformers
Clone this Hugging Face repository or download the release files and keep model.safetensors, carma_config.json, and carma_v03.py together. The checkpoint is tracked with Git LFS.
Run a generation
python demo_inference.py --prompt "Once upon a time, a small fox" --max-new-tokens 60 --temperature 0.8 --top-k 40
The demo uses the tokenizer from the original public TinyStories tokenizer repository at runtime; it does not load a vanilla/Hugging Face AutoModelForCausalLM. It is a straightforward full-context autoregressive loop without KV caching, so it is intended for demonstration rather than serving performance. Network access is needed for the first tokenizer download unless the tokenizer has already been cached.
Load the checkpoint directly
import json
from pathlib import Path
import torch
from safetensors.torch import load_file
from carma_v03 import CARMAConfig, CARMALM
root = Path(".")
cfg = CARMAConfig(**json.loads((root / "carma_config.json").read_text()))
model = CARMALM(cfg)
model.load_state_dict(load_file(str(root / "model.safetensors"), device="cpu"), strict=True)
model.eval()
with torch.no_grad():
output = model(torch.tensor([[1, 2, 3]], dtype=torch.long))
print(output["logits"].shape) # (1, 3, 50257)
This direct-loader method was validated against the supplied checkpoint: 366 tensor keys matched with no missing/unexpected weights and an example forward pass returned finite logits.
Repository structure
CARMA/
βββ README.md # This model card / research overview
βββ LICENSE # Apache License, Version 2.0
βββ NOTICE # Copyright and third-party notice
βββ CITATION.cff # Citation metadata
βββ carma_v03.py # Reference CARMA v0.3 architecture
βββ carma_config.json # Checkpoint architecture config
βββ architecture.json # CARMA / vanilla model dimensions and parameter counts
βββ model.safetensors # 3.79M-parameter trained checkpoint (Git LFS recommended)
βββ dataset_manifest.json # Dataset revision, splits, fingerprints
βββ experiment.json # Public experiment hyperparameters (sanitised)
βββ final_results.json # Controlled v0.3/vanilla metrics
βββ benchmark.json # Original latency / throughput records
βββ preflight.json # Algebra, init equivalence and gradient diagnostics
βββ carma_v0_3_summary.json # Internal lane/provenance/trust statistics
βββ generations.json # Qualitative generations
βββ demo_inference.py # Minimal CLI inference demo
βββ smoke_test.py # Local weight/forward compatibility check
βββ requirements.txt # Runtime dependencies
βββ .gitignore # Excludes temporary and secret files
βββ .gitattributes # LFS patterns
The public release excludes an uncontrolled historical-model comparison, private repository destinations, and bundled third-party tokenizer files. These exclusions do not change the original CARMA architecture or checkpoint. The repository also does not include the source TinyStories dataset.
Known limitations and responsible interpretation
- Small scale / narrow domain. Results are limited to a 3.79M-parameter English TinyStories experiment and should not be extrapolated to large language models, general reasoning or downstream tasks.
- Compute overhead. Four lanes, controllers, provenance updates and trust-state updates cost substantially more than vanilla computation in the supplied benchmark.
- No robust multi-seed evidence in this ZIP. The original v0.3 result does not establish performance across different random seeds. Subsequent studies are separate work and must be linked and reported independently if published.
- Training reproducibility is incomplete. This release includes architecture, weights, configuration, dataset split identifiers and metrics, but not the complete original training pipeline.
- Numerical/semantic limits. Computed provenance and trust are architectural states, not externally verified attribution or confidence.
- No conventional generation interface. The reference PyTorch class exposes
forward()and optional telemetry;demo_inference.pyimplements a separate, unoptimised sampling loop. - Potential memorisation. As with language models generally, generated text can be inaccurate, repetitive or reflect training examples; avoid using the model for factual or safety-critical decisions.
Research directions
Future work could separately evaluate (a) one auxiliary instead of three, (b) removing redundant routing, (c) adaptive normalisation in a lower-overhead implementation, (d) equal-compute/time comparisons, (e) multiple seeds and larger datasets, and (f) scaling behaviour. These are research directions, not v0.3 results.
Data, tokenizer and attribution
- Dataset:
karpathy/tinystories-gpt4-clean, derived from TinyStories. See the dataset card and Eldan & Li, TinyStories: How Small Can Language Models Be and Still Speak Coherent English?. - Tokenizer:
roneneldan/TinyStories-1M. The supplied archive contained tokenizer files, but this publication candidate references the upstream tokenizer rather than redistributing them pending verification of third-party redistribution terms. - Backbone and implementation: Custom PyTorch reference implementation provided in this repository.
Citation
License and copyright
CARMA v0.3 code, configuration, original documentation and the released model.safetensors checkpoint are made available under the Apache License, Version 2.0, subject to the rights held by the publisher. Copyright Β© 2026 Zain Asad. See NOTICE for attribution information.
Apache-2.0 permits use, modification and redistribution, including commercial use, subject to its conditions. It also contains an express patent licence with defined termination provisions; read the full licence before reuse. The software and checkpoint are provided AS IS, without warranty.
Third-party exclusions: This licence does not relicense the TinyStories dataset, upstream roneneldan/TinyStories-1M tokenizer, third-party packages, linked publications, or their underlying material. The tokenizer is obtained from its own repository when the demo is run. Check those sources' own terms before redistribution or commercial use. This model was trained on a TinyStories-derived corpus, which is not redistributed here.
The CARMA preprint is a separate scholarly publication and its copyright/licence, if deposited on Zenodo, is determined by the preprint's own deposit record, not by this software licence.
Citation
If you use or discuss CARMA v0.3, please cite Zain Asad and this version of the research artefact. The associated preprint is titled CARMA v0.3: Contributor-Aware Residual Memory for Small Causal Transformers. https://doi.org/10.5281/zenodo.24451905
@misc{asad2026carmav03,
author = {Asad, Zain},
title = {CARMA v0.3: Contributor-Aware Residual Memory for Small Causal Transformers},
year = {2026},
howpublished = {Hugging Face model repository, version 0.3 (research preview)},
url = {https://huggingface.co/EphAsad/CARMA-4M-v0.3},
note = {Unreviewed research artefact; original TinyStories experiment}
}
Research status: v0.3 is an experimental research release; results have not been independently reproduced at equal training compute and should not be interpreted as a production claim.
- Downloads last month
- 56