Skip to content

TMT v3.0 — Full Paper, 5 Innovations, 29.4 PPL, 226 Tests

Latest

Choose a tag to compare

@vignesh2027 vignesh2027 released this 07 Jun 08:07
· 4 commits to main since this release

TemporalMesh Transformer v3.0 🕸️

29.4 PPL on WikiText-2 · −30.2% vs baseline · 48% compute · 226 tests passing

This is the largest TMT release: complete paper (v3), expanded benchmarks across 8 datasets, 12 baseline comparisons, 4 real-world case studies, and a live interactive demo.


What is TMT?

TMT is a PyTorch transformer that simultaneously fixes three things every other architecture addresses individually:

Problem Every other model TMT
Quadratic attention $O(S^2)$ Sparse/linear approx Dynamic $k$NN mesh per layer $O(S \cdot k)$
Static attention topology Fixed graph Rebuilt from cosine similarity every layer
Uniform token compute All tokens use all $N$ layers Per-token exit gate, avg 5.8/12 layers

Five innovations in one forward pass

1. Mesh Attention — builds a $k$NN graph from current token representations after every layer. At $k=8$, $S=1024$: 128× fewer attention operations than full attention.

2. Temporal Decay Encoding — multiplies a learned per-head scalar into post-softmax attention weights: $\tilde{\alpha}{ij} = \alpha{ij} \cdot \sigma(w \cdot |t_i - t_j|)$. Attenuates semantically irrelevant tokens beyond what position alone achieves.

3. Adaptive Depth Routing — exit gate $c_i = \sigma(W_g x_i)$ freezes tokens when confidence $> 0.85$. Punctuation exits at layer 2, rare words at layer 12. Average: 5.76 layers out of 12.

4. Dual-Stream FFN — parallel syntax and semantic MLP streams, fused by a sigmoid gate. Interpretable: punctuation heavily weights syntax stream, technical terms weight semantic stream.

5. EMA Memory Anchors — 16 persistent key-value pairs updated by exponential moving average ($\beta=0.99$). Fast-weight cross-sequence recall without recurrence overhead.


Results

Model WT-2 PPL ↓ WT-103 PPL ↓ LongBench ↑ C4 PPL ↓ Compute
Vanilla Transformer 42.1 51.3 41.2 38.4 100%
Longformer 39.6 47.2 49.8 36.1 62%
BigBird 38.9 46.8 48.6 35.8 65%
Performer 40.1 49.4 44.3 37.2 58%
RWKV 33.1 40.9 48.7 29.3 50%
Mamba 31.8 38.4 51.3 30.1 55%
MoE (4×) 34.8 42.1 47.2 31.4 100%
Full TMT 29.4 36.1 53.4 27.4 48%

All models: ~120M parameters. TMT trained 10K steps, AdamW, cosine LR, 3 seeds (42/1337/2024).


The superadditive effect

Component PPL Compute
Vanilla baseline 42.1 100%
+ Mesh only 37.8 62%
+ Decay only 40.3 98%
+ Exit only 39.6 51%
Mesh + Decay 34.2 61%
Mesh + Exit 35.1 50%
All three 29.4 48%

Sum of individual gains = 8.6 PPL. Actual combined gain = 12.7 PPL. Interaction effect = +4.1 PPL from the three innovations reinforcing each other.


Quick start

git clone https://github.com/vignesh2027/TemporalMesh-Transformer
cd TemporalMesh-Transformer
pip install -e '.[dev]'
from tmt.model.config import TMTConfig
from tmt.model.model  import TMTModel
import torch

model = TMTModel(TMTConfig(
    vocab_size=50257, d_model=512, n_heads=8,
    n_layers=12, graph_k=8, exit_threshold=0.85,
))
out = model(torch.randint(0, 50257, (1, 256)))
print(out.logits.shape)       # (1, 256, 50257)
print(out.exit_masks[-1])     # which tokens exited at layer 12
# Train from scratch
python scripts/train.py --dataset wikitext-2 --steps 10000 --lr 3e-4
# Run all 226 tests
pytest tests/ -v
# Zero ruff errors
ruff check tmt/

What's new in v3

  • ✅ Complete 20-page paper with 25 tables, 5 algorithms, 5 TikZ diagrams
  • ✅ Benchmarks on 8 datasets: WT-2, WT-103, C4, The Pile, OpenWebText, LongBench, SCROLLS, PG19
  • ✅ Comparison against 12 baselines including Mamba, RWKV, Hyena, FlashAttention, MoE
  • ✅ 4 real-world case studies: chatbot 100M users, legal 64K tokens, scientific papers, medical records
  • ✅ Full FLOP/memory derivations and GPU utilisation tables
  • ✅ INT8/INT4 quantisation robustness (only +3.7 PPL at INT4 vs +9.1 vanilla)
  • ✅ Cross-domain zero-shot on 6 domains (scientific, legal, medical, code, dialogue, news)
  • ✅ Hierarchical mesh for S > 512 (O(S^4/3) graph build)
  • ✅ Live interactive Gradio demo on HuggingFace Spaces

Links

Resource URL
📄 Paper (Zenodo v3) https://zenodo.org/records/20287390
🔖 DOI 10.5281/zenodo.20287197
🤗 Model (HuggingFace) https://huggingface.co/vigneshwar234/TemporalMesh-Transformer
🎮 Live Demo https://huggingface.co/spaces/vigneshwar234/TemporalMesh-Transformer-Demo
📊 Benchmarks Dataset https://huggingface.co/datasets/vigneshwar234/TMT-Benchmarks

Citation

@misc{vigneshwar2026tmt,
  title  = {TemporalMesh Transformer: Dynamic Graph Attention with
            Temporal Semantic Decay and Per-Token Adaptive Depth Routing},
  author = {Vigneshwar LK},
  year   = {2026},
  doi    = {10.5281/zenodo.20287197},
  url    = {https://zenodo.org/records/20287390}
}