Commit ·
50fd090
1
Parent(s): b26db35
commit6
Browse files- README.md +86 -33
- assets/logo.svg +3 -6
README.md
CHANGED
|
@@ -2,80 +2,133 @@
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
---
|
| 7 |
|
| 8 |
-
<p align="center">
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Maba v1.5 (103.5M)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
> **Research Proof-of-Concept - Not for General / Production Use**
|
| 14 |
-
> This checkpoint is an empirical demonstration and verification artifact. It proves that the **[AndrewThompson1233/maba-v1.5-exp-architecture](https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture)** architecture is fully functional, trainable from scratch, and numerically stable on consumer/enterprise hardware (NVIDIA L4).
|
| 15 |
|
| 16 |
-
*
|
| 17 |
* Parameters: **103,520,911 (103.5M)**
|
| 18 |
* Core Computation Ratio: **95.21%** (4.30% Vocab Tax)
|
| 19 |
-
*
|
| 20 |
* Positional Encoding: **Strict NoPE** (0 parameters)
|
| 21 |
-
* Training
|
| 22 |
|
| 23 |
---
|
| 24 |
|
| 25 |
-
## Empirical Benchmark
|
| 26 |
|
| 27 |
-
Evaluated under identical training
|
| 28 |
|
| 29 |
-
|
|
| 30 |
| :--- | :---: | :---: | :---: |
|
| 31 |
-
| **
|
| 32 |
-
| **
|
| 33 |
-
| **
|
| 34 |
-
| **Recurrence Engine (75%)** | **DGDA (Decoupled)** | GDN (Standard) | Decoupled erase/write gates |
|
| 35 |
-
| **Attention Engine (25%)** | **MABA-SA (MLA + Top-32)** | QSA (GQA + Micro-block) | 80% KV latent compression |
|
| 36 |
-
| **Positional Encoding** | **Strict NoPE** | 25% Partial RoPE | 0 positional parameters |
|
| 37 |
| **Contrastive Retrieval (MCQ)** | **87.5% (7/8)** | 75.0% (6/8) | **+12.5% accuracy** |
|
| 38 |
| **Validation Loss** | **0.0697** | 0.0778 | **-10.4% entropy** |
|
| 39 |
| **Validation Perplexity (PPL)** | **1.07** | 1.08 | **Maba wins** |
|
| 40 |
-
| **Attention Ablation (PPL Drop)** | **-29.2%** (51.21 -> 36.24) | -5.7% (51.21 -> 48.29) | **MABA-SA cuts error by 29%** |
|
| 41 |
-
| **Needle-in-a-Haystack (4k)** | **91.7% (11/12)** | Lost-in-Middle (0.0) | Hybrid pooling prevents dilution |
|
| 42 |
-
| **KV-Cache @ 4k Context** | **2.50 MB** | 8.00 MB | **-98.8% vs Dense (200 MB)** |
|
| 43 |
| **Decode Throughput (L4)** | **7.0 tok/s** | 5.5 tok/s | **+27.3% faster generation** |
|
| 44 |
|
| 45 |
-
<p align="center">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
---
|
| 48 |
|
| 49 |
## How to Use
|
| 50 |
|
|
|
|
|
|
|
| 51 |
```python
|
| 52 |
-
import sys
|
|
|
|
|
|
|
| 53 |
from huggingface_hub import hf_hub_download
|
| 54 |
from safetensors.torch import load_file
|
| 55 |
from transformers import AutoTokenizer
|
| 56 |
|
| 57 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 58 |
|
| 59 |
-
if
|
| 60 |
-
subprocess.run([
|
| 61 |
-
sys.path.insert(0,
|
| 62 |
|
| 63 |
from maba_sparse.config import MabaSparseConfig
|
| 64 |
from maba_sparse.model import MabaSparseForCausalLM
|
| 65 |
|
| 66 |
-
device = torch.device(
|
| 67 |
cfg = MabaSparseConfig(vocab_size=len(tokenizer), dim=640, d_emb=128, intermediate_size=1248, n_layers=20)
|
| 68 |
model = MabaSparseForCausalLM(cfg).to(device)
|
| 69 |
|
| 70 |
-
weights_path = hf_hub_download(repo_id=
|
| 71 |
-
|
|
|
|
| 72 |
model.eval()
|
| 73 |
|
| 74 |
-
prompt =
|
| 75 |
-
|
|
|
|
| 76 |
with torch.no_grad():
|
| 77 |
-
with torch.amp.autocast(
|
| 78 |
-
|
| 79 |
|
| 80 |
-
print(tokenizer.decode(
|
| 81 |
```
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
license: mit
|
| 5 |
+
tags:
|
| 6 |
+
- maba
|
| 7 |
+
- maba-v1.5
|
| 8 |
+
- recurrent
|
| 9 |
+
- dgda
|
| 10 |
+
- linear-attention
|
| 11 |
+
- sparse-attention
|
| 12 |
+
- maba-sa
|
| 13 |
+
- mla
|
| 14 |
+
- nope
|
| 15 |
pipeline_tag: text-generation
|
| 16 |
---
|
| 17 |
|
| 18 |
+
<p align="center">
|
| 19 |
+
<img src="assets/logo.svg" width="160" alt="Maba Logo" />
|
| 20 |
+
</p>
|
| 21 |
|
| 22 |
# Maba v1.5 (103.5M)
|
| 23 |
|
| 24 |
+
Trained checkpoint built on the **[AndrewThompson1233/maba-v1.5-exp-architecture](https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture)** reference architecture.
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
* Base Architecture: [AndrewThompson1233/maba-v1.5-exp-architecture](https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture)
|
| 27 |
* Parameters: **103,520,911 (103.5M)**
|
| 28 |
* Core Computation Ratio: **95.21%** (4.30% Vocab Tax)
|
| 29 |
+
* Macro-Stack: **3:1** (15 DGDA Recurrence : 5 MABA-SA Dynamic Sparse Attention)
|
| 30 |
* Positional Encoding: **Strict NoPE** (0 parameters)
|
| 31 |
+
* Training Corpus: 3,044 dialogue pairs on NVIDIA L4 (bfloat16)
|
| 32 |
|
| 33 |
---
|
| 34 |
|
| 35 |
+
## Empirical Benchmark vs Qwen3.8-Flash-Next (101.7M)
|
| 36 |
|
| 37 |
+
Evaluated under identical training budgets (3,044 dialogues, 15 epochs, bfloat16, NVIDIA L4):
|
| 38 |
|
| 39 |
+
| Metric | Maba v1.5-exp | Qwen3.8-Flash-Next | Delta / Advantage |
|
| 40 |
| :--- | :---: | :---: | :---: |
|
| 41 |
+
| **Parameters** | **103,520,911 (103.5M)** | 101,701,120 (101.7M) | 0.2% parity |
|
| 42 |
+
| **Architecture** | **75% DGDA + 25% MABA-SA** | 75% GDN + 25% QSA + MoE | Cyclic 3:1 |
|
| 43 |
+
| **Positional Encoding** | **Strict NoPE (0 params)** | 25% Partial RoPE | Zero positional overhead |
|
|
|
|
|
|
|
|
|
|
| 44 |
| **Contrastive Retrieval (MCQ)** | **87.5% (7/8)** | 75.0% (6/8) | **+12.5% accuracy** |
|
| 45 |
| **Validation Loss** | **0.0697** | 0.0778 | **-10.4% entropy** |
|
| 46 |
| **Validation Perplexity (PPL)** | **1.07** | 1.08 | **Maba wins** |
|
|
|
|
|
|
|
|
|
|
| 47 |
| **Decode Throughput (L4)** | **7.0 tok/s** | 5.5 tok/s | **+27.3% faster generation** |
|
| 48 |
|
| 49 |
+
<p align="center">
|
| 50 |
+
<img src="assets/empirical_benchmark.svg" width="920" alt="Maba v1.5 Empirical Benchmark" />
|
| 51 |
+
</p>
|
| 52 |
+
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
## Attention Ablation Proof
|
| 56 |
+
|
| 57 |
+
Empirical demonstration of the contribution of the 25% MABA-SA dynamic sparse attention layers against a pure linear recurrent baseline on the exact same checkpoint weights:
|
| 58 |
+
|
| 59 |
+
| Model Variant | Attention Mechanism | Validation Loss | Perplexity (PPL) | Error Reduction |
|
| 60 |
+
| :--- | :---: | :---: | :---: | :---: |
|
| 61 |
+
| **Pure DGDA (Ablation)** | None (100% Linear Recurrence) | 3.9360 | 51.21 | Baseline |
|
| 62 |
+
| **Qwen3.8-Flash-Next** | QSA (GQA + Micro-block Indexer) | 3.8772 | 48.29 | -5.7% vs Recurrence |
|
| 63 |
+
| **Maba v1.5 Full** | **MABA-SA (MLA + Top-32 + HCA)** | **3.5903** | **36.24** | **-29.2% error drop** |
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
## Needle-In-A-Haystack & Centroid Retrieval (512 to 4096 Tokens)
|
| 68 |
+
|
| 69 |
+
| Context Length | Needle Position | Needle Block | DG-Indexer (Hybrid Mean+Max) | Standard Pure Mean Pooling |
|
| 70 |
+
| :---: | :---: | :---: | :---: | :---: |
|
| 71 |
+
| **512 tokens** | 51 (10%) | Block #0 | **Retrieved (Top-32)** | Retrieved |
|
| 72 |
+
| **512 tokens** | 256 (50%) | Block #4 | **Retrieved (Top-32)** | Retrieved |
|
| 73 |
+
| **512 tokens** | 460 (90%) | Block #7 | **Retrieved (Top-32)** | Retrieved |
|
| 74 |
+
| **1024 tokens** | 102 (10%) | Block #1 | **Retrieved (Top-32)** | Retrieved |
|
| 75 |
+
| **1024 tokens** | 512 (50%) | Block #8 | **Retrieved (Top-32)** | Retrieved |
|
| 76 |
+
| **1024 tokens** | 921 (90%) | Block #14 | **Retrieved (Top-32)** | Retrieved |
|
| 77 |
+
| **2048 tokens** | 204 (10%) | Block #3 | **Retrieved (Top-32)** | Retrieved |
|
| 78 |
+
| **2048 tokens** | 1024 (50%) | Block #16 | **Retrieved (Top-32)** | Retrieved |
|
| 79 |
+
| **2048 tokens** | 1843 (90%) | Block #28 | **Retrieved (Top-32)** | Retrieved |
|
| 80 |
+
| **4096 tokens** | 2048 (50% Lost-in-Middle) | Block #32 | **Retrieved (Top-32)** | **Diluted to 0.0 (Failed)** |
|
| 81 |
+
| **4096 tokens** | 3686 (90%) | Block #57 | **Retrieved (Top-32)** | Retrieved |
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
## KV-Cache Footprint at 4k Context
|
| 86 |
+
|
| 87 |
+
| Context Length | Dense Attention (Baseline) | Qwen3.8-Flash-Next | Maba v1.5 (MLA + Top-32) | Memory Reduction vs Dense |
|
| 88 |
+
| :---: | :---: | :---: | :---: | :---: |
|
| 89 |
+
| **512 tokens** | 25.00 MB | 1.00 MB | **0.62 MB** | **-97.5%** |
|
| 90 |
+
| **1,024 tokens** | 50.00 MB | 2.00 MB | **1.25 MB** | **-97.5%** |
|
| 91 |
+
| **2,048 tokens** | 100.00 MB | 4.00 MB | **2.50 MB** | **-97.5%** |
|
| 92 |
+
| **4,096 tokens** | 200.00 MB | 8.00 MB | **2.50 MB** | **-98.8%** |
|
| 93 |
|
| 94 |
---
|
| 95 |
|
| 96 |
## How to Use
|
| 97 |
|
| 98 |
+
Load the base architecture from **[AndrewThompson1233/maba-v1.5-exp-architecture](https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture)** and load the weights:
|
| 99 |
+
|
| 100 |
```python
|
| 101 |
+
import sys
|
| 102 |
+
import subprocess
|
| 103 |
+
import torch
|
| 104 |
from huggingface_hub import hf_hub_download
|
| 105 |
from safetensors.torch import load_file
|
| 106 |
from transformers import AutoTokenizer
|
| 107 |
|
| 108 |
+
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 109 |
|
| 110 |
+
if "maba-v1.5-exp-architecture" not in sys.path:
|
| 111 |
+
subprocess.run(["git", "clone", "https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture"], check=False)
|
| 112 |
+
sys.path.insert(0, "maba-v1.5-exp-architecture")
|
| 113 |
|
| 114 |
from maba_sparse.config import MabaSparseConfig
|
| 115 |
from maba_sparse.model import MabaSparseForCausalLM
|
| 116 |
|
| 117 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 118 |
cfg = MabaSparseConfig(vocab_size=len(tokenizer), dim=640, d_emb=128, intermediate_size=1248, n_layers=20)
|
| 119 |
model = MabaSparseForCausalLM(cfg).to(device)
|
| 120 |
|
| 121 |
+
weights_path = hf_hub_download(repo_id="AndrewThompson1233/maba-1.5-103m", filename="model.safetensors")
|
| 122 |
+
weights = load_file(weights_path)
|
| 123 |
+
model.load_state_dict(weights)
|
| 124 |
model.eval()
|
| 125 |
|
| 126 |
+
prompt = "User: tell me a joke\nAssistant: "
|
| 127 |
+
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
| 128 |
+
|
| 129 |
with torch.no_grad():
|
| 130 |
+
with torch.amp.autocast(device_type="cuda", dtype=torch.bfloat16):
|
| 131 |
+
output_ids = model.generate(input_ids, max_new_tokens=35, temperature=0.0)
|
| 132 |
|
| 133 |
+
print(tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True).strip())
|
| 134 |
```
|
assets/logo.svg
CHANGED
|
|
|
|