MODL (25M) — Modular, Offloaded, Dynamic, Looped Transformer

GitHub Hugging Face License Android 14 Latency Rust Runtime Languages

Code, Rust Runtime & Android App  |  Held-Out Evals  |  Benchmarks  |  Files & Adapters  |  Limitations & License

1. Model Introduction

MODL (Modular, Offloaded, Dynamic, Looped) is a Transformer architecture designed to work around the strict RAM limits that larger models cannot fit into, combining looped depth, zero-RAM flash memory offloading, dynamic widths, and hot-swappable adapters to avoid the severe quality and capability loss of simply shrinking a dense model.

MODL (25M) is an end-to-end 25.8M active-parameter (+ 16.8M flash-offloaded) English + Arabic proof of concept trained from random initialization and verified natively on a 4 GB Android 14 environment.

Proof of Concept → Scale-Invariant Blueprint

While this release validates MODL at an extreme 25.76M active-parameter scale (11.4–14.3 MiB INT4), each of its four pillars is scale-invariant. Because looped depth (Ouro, 1.4B–2.6B) and offloaded Engram memory (DeepSeek Engram, up to 27B) have independently rivaled 3–4× larger dense models at billion-parameter scale, we hypothesize that scaling MODL to 150M–1B active parameters (paired with gigabyte-scale zero-RAM flash Engram tables) will close the gap with substantially larger dense models inside mobile RAM budgets — a scaling curve left for direct future verification.

MODL (25M) Architecture — Modular, Offloaded, Dynamic, Looped

2. Benchmarks

2.1 Standard Public Benchmarks & Frozen Cross-Domain BPB

Below are benchmarks comparing MODL (25M) against other open models, showing how it holds up with far fewer parameters and pre-training tokens:

MODL (25M) — Public Benchmarks (lm-eval, 0-shot)
MODL (25M) — Frozen Cross-Domain BPB

MODL Base (25M) is the untouched 2.0B-token pretrain checkpoint; MODL (25M) Shield is fine-tuned for on-device security tasks. All models were tested under the same conditions, and gains reflect the full training recipe (architecture, optimizer, and curated data) rather than architecture alone.

Full 8-Task Public Benchmark & 6-Domain BPB Tables

Official lm-evaluation-harness 0.4.13 (0-Shot, Full Splits, bf16)

Model Params Tokens PIQA ARC-Easy SciQ HellaSwag WinoGrande ARC-Chal BoolQ MMLU
MODL Base (25M) 25.8M (+16.8M Flash) 2.0B 57.5 41.8 62.6 27.4 50.9 21.6 44.6 23.7
MODL (25M) (Shield) 25.8M (+16.8M Flash) 2.0B 57.8 36.9 57.7 27.1 51.0 25.4 46.7 25.3
Pythia (31M) 30.5M 2.1B 53.8 30.2 26.1 25.5 49.9 21.0 37.9 22.9
Pythia (70M) 70.4M 2.1B 56.3 30.8 44.7 25.8 50.0 21.1 41.0 23.0
Pythia (160M) 162.3M 2.1B 55.0 30.7 42.1 26.5 50.5 21.5 60.4 23.0
Ettin (32M) 32.1M 8.5B 57.6 29.8 —* 26.7 52.1 24.7 37.8 22.9
Ettin (32M) 32.1M 2T 57.4 33.2 —* 28.4 51.5 23.8 37.8 22.9
SmolLM2 (135M) 134.5M 2T 68.4 64.5 84.3 43.2 52.0 29.4 60.5 24.3

Frozen 6-Domain Bits-per-Byte (BPB = Bits-per-Byte, Lower Is Better, 150 Unseen Docs + UAE-32)

Model Tokens EN-Edu Code Math TechQA 4D EN/Tech Avg AR-MSA Emirati 6D Avg UAE-32
MODL Base (25M) 2.0B 0.992 0.219 1.102 1.186 0.875 0.675 1.209 0.897 1.778
MODL (25M) (Shield) 2.0B 1.407 0.434 1.724 1.676 1.310 0.825 1.480 1.258 2.451
Pythia (31M) 2.1B 1.593 1.690 2.013 1.592 1.722 2.095 2.255 1.873 2.568
Pythia (70M) 2.1B 1.390 1.235 1.690 1.424 1.435 1.730 1.938 1.568 2.434
Pythia (160M) 2.1B 1.357 1.191 1.667 1.401 1.404 1.779 2.001 1.566 2.523
Ettin (32M) 8.5B 1.096 0.823 1.373 1.206 1.124 1.676 1.858 1.339 2.223
Ettin (32M) 2T 0.975 0.666 1.195 1.135 0.993 1.482 1.734 1.198 2.146
SmolLM2 (135M) 2T 0.688 0.401 0.944 0.977 0.752 1.260 1.573 0.974 1.897

(* Ettin (32M) omitted on SciQ due to a ModernBertDecoder / lm-eval scoring quirk. Bold marks best score per column. Benchmarks above ran in PyTorch bf16; on-device mobile binaries are 14.25 MiB Q4_0 in RAM + 18.0 MiB on-disk INT8 .engram flash tables. Raw JSON archived in data/eval/reports/modl_25m_peer_eval_suite.json.)

2.2 Why This Model Punches Above Its Weight

What makes a 25M model this competitive? Three foundations working together:

Three Foundations of MODL (25M) — Architecture, Pretraining Optimization, and Curated Data
  1. MODL Architecture — One shared 14.3 MiB parent base (18 effective layers across 6 looped blocks) paired with 16.8M flash-offloaded parameters at 0 MB RAM, dynamic 50% Lite width, and Ready-To-Swap (RTS) adapters.
  2. Pretraining Optimization — Muon + Warmup-Stable-Decay cut validation perplexity by 63.0% in controlled tests and drove the full 2.0B-token run down to 19.11 perplexity in 4h 53m on a single GPU (~$17).
  3. Curated Data — 2.0B clean open-commercial tokens across 21 vetted English and Arabic sources (zero unvetted spam crawls, unit-test-verified code, LLM-audited Emirati Arabic) plus cross-family auditing for downstream skills.
Metric Earlier 16.5M Prototype MODL (25M) Improvement
Cross-Domain BPB (150 unseen docs, lower is better) 1.458 0.901 −38.2%
Validation Perplexity (lower is better) 46.57 19.11 −59.0%
Public Zero-Shot Benchmarks (n=100 quick suite, higher is better) 34.9% 39.1% +4.2 pts

2.3 Live 4 GB Android 14 Telemetry (Pure Rust AVX2/NEON)

Measured natively inside Android 14 (Linux 6.1.23, 4 GB RAM, zero GPU) via kernel /proc/self/status VmHWM with both 9 MiB flash tables, tokenizer, and active adapter loaded:

Android 14 Metric MODL Lite (11.41 MiB) MODL Full (14.25 MiB)
Standalone Peak RAM (kernel VmHWM) 19.5 – 27.0 MB 25.3 – 32.1 MB
24/7 Isolated Background Service RAM (Total PSS) — 33.9 MB (22.5 MB native, 0.65 MB Dalvik)
Flash Memory RAM Cost (16.8M params on disk) 0.0 MB 0.0 MB
Cold Load Time 16.9 ms 10.5 ms
Flash Read per Message (offset-sorted pread()) 7.3 – 14.6 KB 7.3 – 14.6 KB
Classification Latency (p50) 40.9 – 55.7 ms 65.3 – 74.6 ms
Single-Token Intent Routing / Settings (p50, cached adapter) 49.2 / 63.9 ms 74.0 / 95.0 ms
Autoregressive Decode (24 tok) — 99.0 tok/s (242 ms, 22.8 MB RSS)
Deterministic Rule-Based Pre-Filter (Punycode / homoglyphs) 0.02 ms 0.02 ms
Evaluation Footnotes & Detailed Breakdown (Optimizer Ablation, Per-Domain BPB)
  • Controlled Optimizer Ablation (16.4M tokens, identical seed on A100): AdamW + Cosine (381.96 PPL) → AdamW + WSD (262.52, −31.3%) → MuonAdamW + WSD (141.17, −63.0%) at +1.7% wall-time and 0 MB mobile RAM cost.
  • 2.0B Pretraining Progression: WSD annealing on curated data dropped validation PPL from 21.72 → 19.17; averaging the final 5% checkpoints (Checkpoint Averaging / Model Soup) reached 19.11.
  • 6-Domain Bits-per-Byte (150 locked unseen documents): English 1.002, Arabic MSA 0.678, Emirati/Gulf 1.214, Code 0.220, Math 1.099, Technical Q&A 1.192 → 0.901 average (vs. 1.458 earlier 16.5M prototype, 1.383 13.0M baseline).
  • Raw JSON reports and leakage-free held-out evaluation sets live in github.com/N71-AE/MODL-1-25M/tree/main/data/eval.

3. Key Highlights & Model Summary

Key Highlights

  • Four Cooperative Pillars:
    • 18 effective layers — 6 physical blocks looped 4×, keeping model weights at 11.4–14.3 MiB.
    • 16.8M lookup table on flash storage — stored on disk (0 MB RAM), reading only 7–15 KB per message.
    • Dynamic 100% / 50% widths — instant Full/Lite switching to trade speed and memory on demand.
    • Ready-To-Swap (RTS) adapters (3.06 MiB) — hot-swap task specialists on top of one shared backbone.
  • Built 100% From Scratch:
    • Custom 32k English + Arabic tokenizer — 1.39 tokens/word on MSA Arabic and 1.34–1.40 tokens/word on Emirati dialect at a 32,768 vocab (6.1× smaller embedding table than 200k-vocab tokenizers like GPT-4o's 1.92–1.95 tok/word).
    • Random-init pretraining on 2.0B curated open-commercial tokens — trained from scratch in 4h 53m on 1 GPU (~$17).
    • Custom compact mobile file formats — lightweight binary formats for weights, flash tables, adapters, and tokenizer (.gslm, .engram, .glora, .gtok).
    • Zero-dependency pure-Rust mobile engine — fast on-device CPU runtime (guardian_rs) with bit-exact Python ↔ Rust parity.
  • Native 4 GB Android 14 Footprint: Runs all 42.5M total parameters inside 19.5–27.0 MB standalone RAM (33.9 MB for the 24/7 background SMS shield service), classifying messages in 41–75 ms and decoding at 99 tok/s.
  • Strong Live On-Device Results:
    • Security & Scam Filtering: 1.000 F1 (0% false alarms) on bilingual phishing, 0.969 F1 on hard Emirati dialect scams, 92.0% on 5-class message filtering, and 91.9% (0% false alarms) on homoglyph attacks.
    • Context & Multi-Turn Understanding: 71.5% on keyword-vs-context conflict and 72.1% 3-way (0.958 threat F1) on multi-turn social engineering.
    • Offline Tool Routing: 83.0% / 95.5% on offline Android 14 settings navigation.
Property Specification
Architecture MODL — Looped Decoder + Dual Flash Engram + MatFormer FFN + FP16 RTS LoRA
Total Capacity 42.54M (25.76M active backbone + 16.78M flash-offloaded Engram)
Physical / Effective Depth 6 physical blocks (1 Entry + 4 Shared × 4 loops + 1 Exit) → 18 effective layers
Hidden / FFN Dimension d_model = 384 · d_ff = 1536 (Full 100%) / 768 (Lite 50% dynamic width)
Attention & Norms 6:2 Grouped-Query Attention (GQA) · RoPE (θ = 10,000) · RMSNorm · SwiGLU · Tied Embeddings
Dual Flash Memory (0 MB RAM) 2 × 9.00 MiB INT8 N-gram hash tables (8 × 65,537 × 16 each) · lossless FP16 w_k/w_v gates · 7.3–14.6 KB/msg via OS pread()
Tokenizer Custom 32,768-vocab EN + AR Byte-Level BPE (.gtok 690 KiB, canonical Arabic folding 32k → 25.7k)
Context Length 512 tokens (0 MB KV cache for 1-pass classification · per-loop KV cache ~0.4–1.5 MB for generation)
Pretraining 2.0B curated tokens (21 open-commercial EN + AR sources) · MuonAdamW + WSD + Checkpoint Averaging (Model Soup)
Mobile Footprint (INT4 Q4_0) 14.25 MiB Full · 11.41 MiB Lite · 19.5–27.0 MB standalone Peak RAM (33.9 MB isolated background service PSS)
Runtime & Formats Zero-dependency Pure Rust (guardian_rs, AVX2+FMA / NEON / JNI / WASM) · Safetensors · PyTorch (.pt) · custom binary formats (.gslm, .engram, .glora, .gtok)
License GPL-3.0 (code & weights) · CC-BY-4.0 (evaluation benchmarks)

Technical Details

  • Quantized Looped Core & Lossless Engram Gates: The 6 physical blocks (1 Entry + 4 Shared × 4 loops + 1 Exit) are quantized to Q4_0 INT4 (14.25 MiB Full / 11.41 MiB Lite), while Flash Engram gate projections (w_k, w_v) stay in compact lossless FP16 (+0.27 MiB) so 4-bit noise does not degrade memory gating.
  • Zero-RAM Dual Flash Engram (pread()): Entry and mid-loop INT8 N-gram hash tables (2 × 9.00 MiB, 8 × 65,537 × 16 each) remain on flash storage (0.0 MB RAM) and are fetched via ascending byte-offset-sorted OS pread() (7.3–14.6 KB/msg).
  • MatFormer Dynamic Widths & Cached FP16 LoRA Adapters: Nested 100% / 50% FFN slices (d_ff = 1536 / 768) share one checkpoint; foreground r=32 FP16 .glora adapters (router_4class.glora, android_ops_18class.glora, 3.06 MiB each) use an in-RAM cache for 0.00 ms repeat hot-swaps and zero adapter overhead during 24/7 background scanning.
  • Custom 32k Bilingual Tokenizer & Pretraining Stack: Character-balanced English + Arabic Byte-Level BPE (1.34–1.40 tok/w on Emirati Arabic vs. 1.92 GPT-4o / 4.00 GPT-4; 6.1× smaller embedding table than 200k-vocab models; canonical Arabic folding 32k → 25.7k; pre-tokenization evasion flags), pretrained from random init (loss 10.40 → 2.95) with MuonAdamW + WSD + Checkpoint Averaging (Model Soup) across four custom binary formats (.gslm, .engram, .glora, .gtok).
  • Zero-Dependency Pure-Rust Engine (guardian_rs) & Android 14 Isolation: Runtime-dispatched AVX2+FMA (x86_64) and NEON (aarch64) Q4_0 kernels, 65,536-entry branchless f16→f32 LUT, spin-before-sleep worker thread pool, 0.02 ms deterministic rule-based pre-filter (NFKC, Punycode, Cyrillic/Greek homoglyphs), bit-exact Python ↔ Rust tokenizer and greedy decode parity, UTF-8 byte[] Android JNI bridge (jni.rs), and an isolated background NotificationListenerService (android:process=":shield", 33.9 MB Total PSS vs. 19.5–27.0 MB standalone kernel VmHWM).

4. Key Engineering Findings

Five practical lessons uncovered while building and testing MODL from scratch:

  • Halving Training VRAM & ~$17 Pretraining — Running the 100% and 50% width training passes sequentially (instead of simultaneously) cut peak GPU memory by 50% with identical math; paired with fixing graph breaks in PyTorch's torch.compile() (2.55× speedup, 113.9k tok/s), the entire 2.0B-token run finished in 4h 53m on a single GPU for ~$17.
  • Why Unused Special Tokens Failed (+47.0 pts Fix) — Special label tokens that never appeared during pretraining drifted until their internal representations became nearly identical (99.95% cosine similarity), capping shared-base adapter accuracy at 47.8%. Mapping verdicts onto ordinary pretrained words (safe, bank, offer, warning, fraud) jumped accuracy to 94.8% (+47.0 pts) without changing a single parent base weight.
  • Fixing Text Stuttering in Looped Decoding — Reusing only the final loop's KV cache during text generation caused stuttering because Pass 1 was reading cached values saved by Pass 4. Keeping a small separate cache per loop (~0.4–1.5 MB for short prompts; 0 MB for single-pass scoring) eliminated stuttering and restored bit-exact output in both Python and Rust.
  • Single-Token Tool Classification Over Free-Text JSON (11% → 95.5%) — At 25.8M, free-text intent generation collapsed onto majority classes and hallucinated invalid Android constants (~2.0 s). Reformulating routing (4-class) and settings navigation (18-class) as single-pass, single-token label classification eliminated syntax errors completely and cut mobile latency to 49–95 ms.
  • Avoiding 4-Bit Multi-Task Interference & Lossless FP16 Engram Gates — Packing 3 competing tasks into one 4-bit full fine-tune caused a −10.0 pt Q4_0 drop on intent routing, whereas pairing a dedicated Q4_0 resident base model (with compact FP16 Engram w_k/w_v gates, +0.27 MiB) with cached FP16 .glora foreground adapters preserved accuracy with 0 background adapter overhead.

5. Model Files

File Size RAM Cost Role
modl_25m.gslm 14.25 MiB 14.3 MB Full 100% 4-bit backbone + lossless FP16 Engram gates (18 effective layers)
modl_25m_lite50.gslm 11.41 MiB 11.4 MB Dynamic 50% Lite 4-bit backbone (1.5–1.6× faster on Android 14)
modl_25m_engram_entry.engram 9.00 MiB 0.0 MB Entry flash lookup table
modl_25m_engram_mid.engram 9.00 MiB 0.0 MB Mid-loop flash lookup table
modl_25m_tokenizer.gtok 0.69 MiB ~1.8 MB Custom 32k English + Arabic mobile tokenizer (Rust binary)
modl_25m_tokenizer.json 2.65 MiB — Full Hugging Face tokenizers JSON definition
adapters/router_4class.glora 3.06 MiB ~3.1 MB r=32 FP16 1-token 4-class intent router
adapters/android_ops_18class.glora 3.06 MiB ~3.1 MB r=32 FP16 1-token 18-class Android 14 settings navigator
model.safetensors 162.79 MiB — Full FP32 model weights (Safetensors, tied embeddings)
modl_25m.pt 210.81 MiB — Weights-only PyTorch checkpoint (ready for .glora fine-tuning)
config.json 0.9 KB — Model architecture hyperparameters
SHA256SUMS.txt 1.3 KB — SHA-256 verification checksums for all artifacts

6. Limitations, License & Citation

Limitations

  • What 25.8M proves today: Always-on < 35 MB background security filtering, multi-turn social engineering detection, dialectal classification, and single-token edge tool routing — while honestly hitting natural 25.8M capacity limits on broad trivia (MMLU ~24–25%), open multi-hop logic (20%), and long open-ended generation.

License

  • Code & Model Weights: GNU GPL-3.0
  • Evaluation Benchmarks (data/eval/): CC-BY-4.0

Citation

@misc{n71ae2026modl25m,
  title={MODL (25M): Modular, Offloaded, Dynamic, Looped Transformers (25.8M Edge Proof of Concept)},
  author={{N71-AE}},
  year={2026},
  howpublished={\url{https://github.com/N71-AE/MODL-1-25M}},
  note={Weights and adapters: https://huggingface.co/N71-AE/MODL-1-25M}
}
Acronym Reference

BPB = Bits-per-Byte · BPE = Byte-Pair Encoding · F1 = Harmonic Mean of Precision & Recall · FFN = Feed-Forward Network · FLOPs = Floating-Point Operations · FP16 / FP32 = 16/32-bit Floating Point · FPR = False-Positive Rate · GQA = Grouped-Query Attention · INT4 / INT8 = 4/8-bit Integer · JNI = Java Native Interface · KV-cache = Key-Value Cache · MiB = Mebibyte (1,048,576 bytes) · MSA = Modern Standard Arabic · NLL = Negative Log-Likelihood · OOD = Out-of-Distribution · PoC = Proof of Concept · PPL = Perplexity · PSS = Proportional Set Size · RTS = Ready-To-Swap · SIMD = Single Instruction, Multiple Data · VmHWM = Virtual Memory High-Water Mark (Linux Kernel Peak RAM) · VRAM = Video RAM · WSD = Warmup-Stable-Decay

Downloads last month
-
Safetensors
Model size
42.6M params
Tensor type
I64
·
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train N71-AE/MODL-1-25M