Add authentic research paper preprint DOI citation (Zenodo: 10.5281/zenodo.22747827)
Browse files
README.md
CHANGED
|
@@ -1,159 +1,166 @@
|
|
| 1 |
-
---
|
| 2 |
-
language:
|
| 3 |
-
- en
|
| 4 |
-
license: mit
|
| 5 |
-
tags:
|
| 6 |
-
- pytorch
|
| 7 |
-
- causal-lm
|
| 8 |
-
- 1b
|
| 9 |
-
- edge-ai
|
| 10 |
-
- hypergqe
|
| 11 |
-
- dynamic-attention
|
| 12 |
-
- grouped-query-attention
|
| 13 |
-
- text-generation
|
| 14 |
-
pipeline_tag: text-generation
|
| 15 |
-
inference: false
|
| 16 |
-
---
|
| 17 |
-
|
| 18 |
-
# Maria-1B (20B Tokens Pretrained from Scratch)
|
| 19 |
-
|
| 20 |
-
**Maria-1B** is a compact 1.07B parameter causal language model pretrained from scratch on a **20 Billion token budget**. It introduces **HyperGQE** (Dynamic Query Adaptation), a novel sparse attention architecture that breaks the traditional trade-off between KV-cache compression and query representational collapse.
|
| 21 |
-
|
| 22 |
-
Unlike static Grouped Query Experts (GQE) which permanently drop unselected query heads, Maria dynamically conditions query projections using a lightweight context hypernetwork. This enables the model to achieve **higher throughput and lower memory usage than Dense GQA** while **surpassing Dense GQA in classification accuracy and STEM reasoning**.
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
| 32 |
-
|
|
| 33 |
-
| **
|
| 34 |
-
| **
|
| 35 |
-
| **
|
| 36 |
-
| **
|
| 37 |
-
| **
|
| 38 |
-
| **
|
| 39 |
-
| **
|
| 40 |
-
| **
|
| 41 |
-
| **
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
| 55 |
-
|
|
| 56 |
-
|
|
| 57 |
-
|
|
| 58 |
-
|
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
| 66 |
-
|
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
| 82 |
-
|
|
| 83 |
-
|
| 84 |
-
*
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
|
| 94 |
-
|
|
| 95 |
-
| **MMLU:
|
| 96 |
-
| **MMLU:
|
| 97 |
-
| **MMLU:
|
| 98 |
-
| **
|
| 99 |
-
| **
|
| 100 |
-
| **
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
## Quantization & Edge Deployment
|
| 142 |
-
|
| 143 |
-
Because Maria has dense FFNs and structured query sparsity, it is an optimal model for on-device and mobile deployment:
|
| 144 |
-
* **4-bit Quantization (GGUF / Q4_K_M)**: Compresses the model to **~650 MB**.
|
| 145 |
-
* **RAM Requirement**: Requires only **~800 MB of RAM**, running at 45–60 tokens/sec on mobile Snapdragon/MediaTek/Apple Silicon chips with zero cloud API costs.
|
| 146 |
-
|
| 147 |
-
---
|
| 148 |
-
|
| 149 |
-
## Citation
|
| 150 |
-
|
| 151 |
-
If you use Maria or the HyperGQE architecture in your research, please cite:
|
| 152 |
-
|
| 153 |
-
```bibtex
|
| 154 |
-
@article{maria2026hypergqe,
|
| 155 |
-
title={HyperGQE: Dynamic Query Adaptation for Knowledge Recovery in Compressed Attention Models},
|
| 156 |
-
author={Yadki Zahid Ahmed and Contributors},
|
| 157 |
-
year={2026}
|
| 158 |
-
}
|
| 159 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
+
tags:
|
| 6 |
+
- pytorch
|
| 7 |
+
- causal-lm
|
| 8 |
+
- 1b
|
| 9 |
+
- edge-ai
|
| 10 |
+
- hypergqe
|
| 11 |
+
- dynamic-attention
|
| 12 |
+
- grouped-query-attention
|
| 13 |
+
- text-generation
|
| 14 |
+
pipeline_tag: text-generation
|
| 15 |
+
inference: false
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Maria-1B (20B Tokens Pretrained from Scratch)
|
| 19 |
+
|
| 20 |
+
**Maria-1B** is a compact 1.07B parameter causal language model pretrained from scratch on a **20 Billion token budget**. It introduces **HyperGQE** (Dynamic Query Adaptation), a novel sparse attention architecture that breaks the traditional trade-off between KV-cache compression and query representational collapse.
|
| 21 |
+
|
| 22 |
+
Unlike static Grouped Query Experts (GQE) which permanently drop unselected query heads, Maria dynamically conditions query projections using a lightweight context hypernetwork. This enables the model to achieve **higher throughput and lower memory usage than Dense GQA** while **surpassing Dense GQA in classification accuracy and STEM reasoning**.
|
| 23 |
+
|
| 24 |
+
* **Research Paper Preprint**: [https://doi.org/10.5281/zenodo.22747827](https://doi.org/10.5281/zenodo.22747827)
|
| 25 |
+
* **Author**: Yadki Zahid Ahmed
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## Model Specifications
|
| 30 |
+
|
| 31 |
+
| Parameter | Value |
|
| 32 |
+
| :--- | :--- |
|
| 33 |
+
| **Total Instantiated Parameters** | **1,073,515,904 (1.074 Billion)** |
|
| 34 |
+
| **Active Parameters per Token** | **1,016,878,976 (1.017 Billion)** |
|
| 35 |
+
| **Sparsity per Block** | 12 out of 16 query expert heads dropped per layer (56.6M inactive params) |
|
| 36 |
+
| **Pretraining Token Budget** | **20 Billion Tokens** (Trained from scratch) |
|
| 37 |
+
| **Hidden Dimension ($d_{\text{model}}$)** | 2,048 |
|
| 38 |
+
| **Number of Layers** | 18 Transformer Blocks |
|
| 39 |
+
| **Query Heads ($N_{\text{heads}}$)** | 16 (4 groups $\times$ 4 expert heads per group) |
|
| 40 |
+
| **Key-Value Heads ($N_{\text{kv}}$)** | 4 (Grouped-Query Attention 4:1 compression) |
|
| 41 |
+
| **Intermediate Size (FFN)** | 5,632 (SwiGLU gating) |
|
| 42 |
+
| **Vocabulary Size** | 128,256 (Llama-3 BPE Tokenizer) |
|
| 43 |
+
| **Context Length ($L_{\text{max}}$)** | 8,192 tokens with RoPE ($\theta = 500,000$) |
|
| 44 |
+
| **Weight Precision** | `bfloat16` (~2.1 GB storage / ~650 MB quantized Q4_K_M) |
|
| 45 |
+
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
## Hardware Profiling & Latency Benchmarks
|
| 49 |
+
|
| 50 |
+
Measured on identical NVIDIA hardware comparing **Maria (HyperGQE)** against **Dense GQA** and **Static GQE**:
|
| 51 |
+
|
| 52 |
+
### Throughput & Latency Comparison
|
| 53 |
+
|
| 54 |
+
| Batch Size ($b$) | Sequence Length ($s$) | Dense GQA Latency | Static GQE Latency | **Maria (HyperGQE)** Latency | **Maria vs. Dense GQA Speedup** |
|
| 55 |
+
| :---: | :---: | :---: | :---: | :---: | :---: |
|
| 56 |
+
| 1 | 512 | 103.50 ms | 90.47 ms | **106.55 ms** | Competitive |
|
| 57 |
+
| 1 | 1024 | 227.76 ms | 161.53 ms | **204.36 ms** | **+10.3% faster** |
|
| 58 |
+
| 8 | 512 | 763.26 ms | 591.01 ms | **716.07 ms** | **+6.2% faster** |
|
| 59 |
+
| 8 | 1024 | 1,750.23 ms | 1,161.57 ms | **1,421.50 ms** | **+18.8% faster** |
|
| 60 |
+
| 16 | 512 | 1,475.45 ms | 1,114.95 ms | **1,361.72 ms** | **+7.7% faster** |
|
| 61 |
+
| **16** | **1024 (Heavy Load)** | **3,526.88 ms** | **2,333.79 ms** | **3,049.37 ms** | **+13.5% FASTER** |
|
| 62 |
+
|
| 63 |
+
### VRAM & Throughput (Heavy Load: $b=16, s=1024$)
|
| 64 |
+
|
| 65 |
+
| Architecture | Peak VRAM | Throughput | Theoretical FLOPs |
|
| 66 |
+
| :--- | :---: | :---: | :---: |
|
| 67 |
+
| **Dense GQA Baseline** | 4,181.55 MB | 4,645 tokens/s | $3.60 \times 10^{13}$ |
|
| 68 |
+
| **Static GQE (Sparse)** | 2,456.19 MB | 7,020 tokens/s | $3.31 \times 10^{13}$ |
|
| 69 |
+
| **Maria (HyperGQE)** | **3,354.19 MB** *(827 MB less)* | **5,372 tokens/s** *(+15.6% higher)* | **$3.60 \times 10^{13}$** |
|
| 70 |
+
|
| 71 |
+
> **Key Hardware Takeaway:** Under maximum sequence and batch workloads, Maria is **13.5% faster** than Dense GQA while consuming **827 MB less VRAM**, maintaining an identical FLOP budget.
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## Downstream Accuracy Benchmarks
|
| 76 |
+
|
| 77 |
+
While static query routing (GQE) suffers from severe information loss due to hard-dropping query heads, Maria's dynamic hypernetwork compensates for unselected heads:
|
| 78 |
+
|
| 79 |
+
### 1. Fine-Tuned Sentiment Classification (SST-2)
|
| 80 |
+
|
| 81 |
+
| Architecture | Total Parameters | Active Parameters | SST-2 Accuracy | Margin vs. Dense |
|
| 82 |
+
| :--- | :---: | :---: | :---: | :---: |
|
| 83 |
+
| **GQE (Static Sparse)** | 875.39 M | 875.39 M | 75.92% | -4.24% *(Degradation)* |
|
| 84 |
+
| **Dense GQA Baseline** | 946.04 M | 946.04 M | 80.16% | Baseline |
|
| 85 |
+
| **Maria (HyperGQE)** | **924.13 M** | **843.35 M** | **80.85%** | **+0.69% HIGHER** |
|
| 86 |
+
|
| 87 |
+
*Maria completely eliminates the 4.24% sparsity collapse of static GQE and pushes past the dense baseline by +0.69%.*
|
| 88 |
+
|
| 89 |
+
### 2. Zero-Shot STEM Domain Recovery (16 Benchmarks)
|
| 90 |
+
|
| 91 |
+
When compared against static sparse routing, Maria demonstrates pronounced accuracy gains in knowledge-intensive STEM domains:
|
| 92 |
+
|
| 93 |
+
| Domain / Task | Static GQE Accuracy | Maria (HyperGQE) Accuracy | Net Margin ($\Delta$) |
|
| 94 |
+
| :--- | :---: | :---: | :---: |
|
| 95 |
+
| **MMLU: College Chemistry** | 19.0% | **28.0%** | **+9.0%** |
|
| 96 |
+
| **MMLU: College Biology** | 22.2% | **26.3%** | **+4.1%** |
|
| 97 |
+
| **MMLU: High School Biology** | 21.0% | **25.8%** | **+4.8%** |
|
| 98 |
+
| **MMLU: High School Chemistry** | 19.2% | **22.7%** | **+3.5%** |
|
| 99 |
+
| **MMLU: Medical Genetics** | 23.0% | **27.0%** | **+4.0%** |
|
| 100 |
+
| **MMLU: Virology** | 24.1% | **28.3%** | **+4.2%** |
|
| 101 |
+
| **ARC (Challenge)** | 21.8% | **23.3%** | **+1.5%** |
|
| 102 |
+
| **ARC (Easy)** | 41.5% | **42.9%** | **+1.4%** |
|
| 103 |
+
| **BoolQ** | 57.0% | **58.2%** | **+1.2%** |
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## Quickstart Usage
|
| 108 |
+
|
| 109 |
+
You can load and run Maria directly with Hugging Face `transformers` using `trust_remote_code=True`:
|
| 110 |
+
|
| 111 |
+
```python
|
| 112 |
+
import torch
|
| 113 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 114 |
+
|
| 115 |
+
model_id = "your-username/Maria-1B-20Btokens"
|
| 116 |
+
|
| 117 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 118 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 119 |
+
model_id,
|
| 120 |
+
torch_dtype=torch.bfloat16,
|
| 121 |
+
device_map="auto",
|
| 122 |
+
trust_remote_code=True
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
prompt = "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\nYou are Maria, a helpful AI assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>\nWhat is the capital of France?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n"
|
| 126 |
+
|
| 127 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 128 |
+
|
| 129 |
+
with torch.inference_mode():
|
| 130 |
+
outputs = model.generate(
|
| 131 |
+
**inputs,
|
| 132 |
+
max_new_tokens=60,
|
| 133 |
+
temperature=0.15,
|
| 134 |
+
do_sample=True,
|
| 135 |
+
pad_token_id=tokenizer.eos_token_id
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
|
| 139 |
+
# Output: The capital of France is Paris.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
```
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## Quantization & Edge Deployment
|
| 145 |
+
|
| 146 |
+
Because Maria has dense FFNs and structured query sparsity, it is an optimal model for on-device and mobile deployment:
|
| 147 |
+
* **4-bit Quantization (GGUF / Q4_K_M)**: Compresses the model to **~650 MB**.
|
| 148 |
+
* **RAM Requirement**: Requires only **~800 MB of RAM**, running at 45–60 tokens/sec on mobile Snapdragon/MediaTek/Apple Silicon chips with zero cloud API costs.
|
| 149 |
+
|
| 150 |
+
---
|
| 151 |
+
|
| 152 |
+
## Citation
|
| 153 |
+
|
| 154 |
+
If you use Maria-1B or build upon the architecture in your research, please cite the official research paper preprint:
|
| 155 |
+
|
| 156 |
+
`ibtex
|
| 157 |
+
@article{yadki2026sparseattention,
|
| 158 |
+
title={CAN WE IMPROVE THE PERFORMANCE OF SPARSE ATTENTION IN GROUPED QUERY EXPERTS WITHOUT INCREASING EXPERTS?},
|
| 159 |
+
author={Yadki, Zahid Ahmed},
|
| 160 |
+
journal={Zenodo},
|
| 161 |
+
year={2026},
|
| 162 |
+
month={September},
|
| 163 |
+
doi={10.5281/zenodo.22747827},
|
| 164 |
+
url={https://doi.org/10.5281/zenodo.22747827}
|
| 165 |
+
}
|
| 166 |
+
`
|