Add illustrated model card, family links and generation example
Browse files- .gitattributes +1 -0
- README.md +210 -43
- assets/architecture.png +3 -0
- assets/common_sense.png +0 -0
- assets/long_context.png +0 -0
- assets/retrieval.png +0 -0
- benchmark_results.json +88 -0
- config.json +3 -2
- generate.py +42 -0
- manifest.json +28 -4
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
assets/architecture.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,57 +1,224 @@
|
|
| 1 |
---
|
| 2 |
language: en
|
|
|
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
- amor
|
| 5 |
- custom-code
|
| 6 |
- pretrained
|
|
|
|
|
|
|
|
|
|
| 7 |
datasets:
|
| 8 |
- HuggingFaceFW/fineweb-edu
|
| 9 |
---
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
The
|
| 21 |
-
|
| 22 |
-
|
| 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 |
-
Export
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
## License
|
| 56 |
-
The
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
language: en
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
license: mit
|
| 6 |
tags:
|
| 7 |
- amor
|
| 8 |
- custom-code
|
| 9 |
- pretrained
|
| 10 |
+
- research
|
| 11 |
+
- arxiv:2602.13215
|
| 12 |
+
- gateddeltanet
|
| 13 |
datasets:
|
| 14 |
- HuggingFaceFW/fineweb-edu
|
| 15 |
---
|
| 16 |
+
|
| 17 |
+
# AMOR-Gated DeltaNet 1.5B
|
| 18 |
+
### When to think fast and slow?
|
| 19 |
+
|
| 20 |
+
**A complete recurrent backbone, refined by three entropy-gated attention blocks.**
|
| 21 |
+
|
| 22 |
+
[Paper](https://arxiv.org/abs/2602.13215) · [Code](https://github.com/HaoranZhengRaul/AMOR) · [Files](https://huggingface.co/FlyinGodzilla/AMOR-GatedDeltaNet-1.5B/tree/main) · [All checkpoints](#model-family)
|
| 23 |
+
|
| 24 |
+
For a smaller download, see the 180M and 440M checkpoints below.
|
| 25 |
+
|
| 26 |
+
## The idea
|
| 27 |
+
|
| 28 |
+
AMOR (**Adaptive Metacognitive Output Router**) uses the model's predictive
|
| 29 |
+
uncertainty to decide where attention should refine its recurrent representation.
|
| 30 |
+
Each appended block reads normalized output entropy, compares it with a frozen
|
| 31 |
+
threshold at inference, and adds an attention update only where its gate fires.
|
| 32 |
+
|
| 33 |
+
The recurrent backbone and attention blocks are pretrained jointly from scratch.
|
| 34 |
+
“Post-hoc” describes where the attention blocks sit, after the complete backbone.
|
| 35 |
+
Keys and values come from residual-stream projections and are retained at every
|
| 36 |
+
position for future retrieval.
|
| 37 |
+
|
| 38 |
+

|
| 39 |
+
|
| 40 |
+
*Block 0 receives the backbone's final normalized output. Blocks 1 and 2 apply
|
| 41 |
+
their own pre-normalization. A shared, embedding-tied LM head supplies all three
|
| 42 |
+
entropy evaluations and the final output prediction.*
|
| 43 |
+
|
| 44 |
+
This checkpoint uses the **native entropy gate**. Optional distilled
|
| 45 |
+
deployment routers are not included in this release. Training uses dense
|
| 46 |
+
attention with an output mask, so gating does not reduce training attention FLOPs.
|
| 47 |
+
|
| 48 |
+
## This checkpoint
|
| 49 |
+
|
| 50 |
+
| Property | Value |
|
| 51 |
+
|---|---|
|
| 52 |
+
| Backbone | Gated DeltaNet |
|
| 53 |
+
| Parameters | 1,524,025,472 |
|
| 54 |
+
| Recurrent mixer–MLP layers | 24 |
|
| 55 |
+
| Model width | 2048 |
|
| 56 |
+
| Appended attention blocks | 3 |
|
| 57 |
+
| Training corpus | FineWeb-Edu |
|
| 58 |
+
| Training tokens | 30,748,520,448 |
|
| 59 |
+
| Training context | 3,072 tokens |
|
| 60 |
+
| Final training step | 62,558 |
|
| 61 |
+
| Seed | 42 |
|
| 62 |
+
| Tokenizer vocabulary | 128,256 |
|
| 63 |
+
| Checkpoint type | Pretrained base model; not instruction-tuned |
|
| 64 |
+
| Weight format | Safetensors; original checkpoint precision |
|
| 65 |
+
|
| 66 |
+
Detailed settings are in [training_config.json](training_config.json);
|
| 67 |
+
[training_summary.json](training_summary.json) records the completed run.
|
| 68 |
+
|
| 69 |
+
## Results
|
| 70 |
+
|
| 71 |
+
This checkpoint's canonical eight-task common-sense mean is **45.1%**.
|
| 72 |
+
The score uses raw accuracy on LAMBADA, HellaSwag, PIQA, ARC-Easy, ARC-Challenge,
|
| 73 |
+
WinoGrande, OpenBookQA and TruthfulQA-mc2.
|
| 74 |
+
|
| 75 |
+
| Task | Accuracy (%) |
|
| 76 |
+
|---|---:|
|
| 77 |
+
| LAMBADA | 39.1 |
|
| 78 |
+
| HellaSwag | 39.2 |
|
| 79 |
+
| PIQA | 70.6 |
|
| 80 |
+
| ARC-Easy | 66.4 |
|
| 81 |
+
| ARC-Challenge | 30.5 |
|
| 82 |
+
| WinoGrande | 53.7 |
|
| 83 |
+
| OpenBookQA | 24.8 |
|
| 84 |
+
| TruthfulQA-mc2 | 36.9 |
|
| 85 |
+
| **Eight-task mean** | **45.1** |
|
| 86 |
+
|
| 87 |
+
Per-task entries are point estimates; the figure reports evaluation-repeat spread.
|
| 88 |
+
|
| 89 |
+

|
| 90 |
+
|
| 91 |
+
*Research comparison across all three scales; use the **1.5B** panel for this
|
| 92 |
+
checkpoint. Whiskers show the sample SD of five reevaluations of each fixed
|
| 93 |
+
checkpoint, centered on its canonical score. They measure evaluation
|
| 94 |
+
repeatability, not independent-training variation. Axes are zoomed per panel.*
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
### Retrieval and long context
|
| 98 |
+
The 1.5B AMOR variants improve average retrieval over their recurrent backbones;
|
| 99 |
+
serial hybrids retain stronger six-task retrieval averages. LongBench results
|
| 100 |
+
remain close to the recurrent backbones, with lower scores for the serial hybrids
|
| 101 |
+
in this experimental setting.
|
| 102 |
+
|
| 103 |
+

|
| 104 |
+
|
| 105 |
+
*Left: six-task retrieval mean. Right: averages of three single-needle variants
|
| 106 |
+
at each context length; lengths are not pooled.*
|
| 107 |
+
|
| 108 |
+

|
| 109 |
+
|
| 110 |
+
*Unweighted mean of 14 task-native scores. Whiskers are benchmark standard errors
|
| 111 |
+
propagated under task independence, not training-seed variability.*
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
<details>
|
| 115 |
+
<summary>Per-task retrieval and LongBench tables</summary>
|
| 116 |
+
|
| 117 |
+
| Task | Answer-containing outputs (%) |
|
| 118 |
+
|---|---:|
|
| 119 |
+
| SWDE | 47.4 |
|
| 120 |
+
| SQuAD-completion | 36.8 |
|
| 121 |
+
| FDA | 24.9 |
|
| 122 |
+
| TriviaQA | 43.1 |
|
| 123 |
+
| Natural Questions | 10.5 |
|
| 124 |
+
| DROP | 17.4 |
|
| 125 |
+
| **Six-task mean** | **30.0** |
|
| 126 |
+
|
| 127 |
+
Retrieval outputs do not store standard errors.
|
| 128 |
+
|
| 129 |
+
| Task | Score ± benchmark SE |
|
| 130 |
+
|---|---:|
|
| 131 |
+
| NarrativeQA | 1.7 ± 0.17 |
|
| 132 |
+
| Qasper | 4.0 ± 0.35 |
|
| 133 |
+
| MultiFieldQA-en | 11.4 ± 0.87 |
|
| 134 |
+
| HotpotQA | 3.6 ± 0.49 |
|
| 135 |
+
| 2WikiMultihopQA | 7.0 ± 0.74 |
|
| 136 |
+
| MuSiQue | 1.9 ± 0.32 |
|
| 137 |
+
| GovReport | 8.1 ± 0.30 |
|
| 138 |
+
| QMSum | 15.1 ± 0.50 |
|
| 139 |
+
| MultiNews | 10.8 ± 0.43 |
|
| 140 |
+
| TREC | 11.0 ± 2.22 |
|
| 141 |
+
| TriviaQA | 11.8 ± 1.22 |
|
| 142 |
+
| SAMSum | 11.4 ± 0.68 |
|
| 143 |
+
| LCC | 10.1 ± 0.38 |
|
| 144 |
+
| RepoBench-P | 10.3 ± 0.41 |
|
| 145 |
+
| **14-task mean** | **8.4 ± 0.22** |
|
| 146 |
+
|
| 147 |
+
Scores are on a 0–100 scale. The mean SE is propagated under task independence.
|
| 148 |
+
|
| 149 |
+
</details>
|
| 150 |
+
|
| 151 |
+
Per-task values are also available in [benchmark_results.json](benchmark_results.json).
|
| 152 |
+
|
| 153 |
+
## Download and run
|
| 154 |
+
|
| 155 |
+
These are custom PyTorch models. Use the supplied loader and generation script;
|
| 156 |
+
this repository is not a Transformers `AutoModel.from_pretrained` integration,
|
| 157 |
+
a hosted chat endpoint, or a GGUF/PocketPal package.
|
| 158 |
+
|
| 159 |
+
A Linux machine with a compatible NVIDIA GPU is the intended accelerated setup.
|
| 160 |
+
Install a CUDA-enabled PyTorch build appropriate for your driver first
|
| 161 |
+
([PyTorch installation](https://pytorch.org/get-started/locally/)).
|
| 162 |
+
Then, in a fresh Python environment:
|
| 163 |
+
|
| 164 |
+
```bash
|
| 165 |
+
python -m pip install huggingface_hub
|
| 166 |
+
hf download FlyinGodzilla/AMOR-GatedDeltaNet-1.5B --local-dir AMOR-GatedDeltaNet-1.5B
|
| 167 |
+
cd AMOR-GatedDeltaNet-1.5B
|
| 168 |
+
python -m pip install "transformers==4.51.3" safetensors einops
|
| 169 |
+
python -m pip install flash-linear-attention
|
| 170 |
+
python generate.py --prompt "The Eiffel Tower is" --max-new-tokens 32
|
| 171 |
```
|
| 172 |
|
| 173 |
+
For the tested CPU reference path, use PyTorch 2.6.0 and Transformers 4.51.3.
|
| 174 |
+
Mamba2 has a slow CPU fallback (`--device cpu`); Gated DeltaNet requires its
|
| 175 |
+
compatible accelerated kernels. GPU kernel versions must match the PyTorch/CUDA
|
| 176 |
+
environment; the release's fresh CUDA validation is not yet complete.
|
| 177 |
+
|
| 178 |
+
`generate.py` performs cached greedy text completion. It is intentionally a
|
| 179 |
+
plain-prompt example: these checkpoints were not trained as chat assistants.
|
| 180 |
+
The tokenizer is referenced from
|
| 181 |
+
[teknium/Llama-3.1-AlternateTokenizer](https://huggingface.co/teknium/Llama-3.1-AlternateTokenizer)
|
| 182 |
+
and pinned in `config.json` to the release-packaging revision. The original
|
| 183 |
+
training-time tokenizer revision was not recorded.
|
| 184 |
+
|
| 185 |
+
### Verification
|
| 186 |
+
Exact weight export is verified. A fresh CUDA loading/generation check for this package is pending.
|
| 187 |
|
| 188 |
+
Every exported tensor was compared exactly with its training checkpoint,
|
| 189 |
+
including the entropy gate's frozen buffers. The tied embedding/head matrix is
|
| 190 |
+
stored once and restored by the loader. Optimizer state is excluded.
|
| 191 |
+
[Export metadata](export_metadata.json) records provenance and actual validation;
|
| 192 |
+
[manifest.json](manifest.json) lists file hashes.
|
| 193 |
+
|
| 194 |
+
## Model family
|
| 195 |
+
| Backbone | 180M | 440M | 1.5B |
|
| 196 |
+
|---|---|---|---|
|
| 197 |
+
| Mamba2 | [180M](https://huggingface.co/FlyinGodzilla/AMOR-Mamba2-180M) | [440M](https://huggingface.co/FlyinGodzilla/AMOR-Mamba2-440M) | [1.5B](https://huggingface.co/FlyinGodzilla/AMOR-Mamba2-1.5B) |
|
| 198 |
+
| Gated DeltaNet | [180M](https://huggingface.co/FlyinGodzilla/AMOR-GatedDeltaNet-180M) | [440M](https://huggingface.co/FlyinGodzilla/AMOR-GatedDeltaNet-440M) | [1.5B](https://huggingface.co/FlyinGodzilla/AMOR-GatedDeltaNet-1.5B) |
|
| 199 |
+
|
| 200 |
+
All six checkpoints use the three-block canonical AMOR layout. Choose a backbone
|
| 201 |
+
and scale to match your experiment; larger models require more memory.
|
| 202 |
+
The cards use a snapshot of the research figures and do not automatically track
|
| 203 |
+
later manuscript revisions.
|
| 204 |
+
|
| 205 |
+
## Intended use and limitations
|
| 206 |
+
Research on recurrent–attention hybrids, uncertainty-based routing, and pretrained
|
| 207 |
+
language-model behavior. Outputs can be incorrect and may inherit training-data
|
| 208 |
+
biases. Entropy measures predictive uncertainty; it cannot detect every confidently
|
| 209 |
+
wrong prediction. Inference fire rates depend on the workload, and attention KV
|
| 210 |
+
storage still grows with context. Training context is 3,072 tokens; long-context
|
| 211 |
+
experiments do not establish reliable performance on every domain.
|
| 212 |
|
| 213 |
## License
|
| 214 |
+
The code and model weights are released under the MIT license; see [LICENSE](https://huggingface.co/FlyinGodzilla/AMOR-GatedDeltaNet-1.5B/blob/main/LICENSE).
|
| 215 |
+
|
| 216 |
+
## Citation
|
| 217 |
+
```bibtex
|
| 218 |
+
@article{zheng2026amor,
|
| 219 |
+
title={When to Think Fast and Slow? AMOR: Adaptive Entropy Gate for Hybrid Models},
|
| 220 |
+
author={Zheng, Haoran and Shani, Chen},
|
| 221 |
+
journal={arXiv preprint arXiv:2602.13215},
|
| 222 |
+
year={2026}
|
| 223 |
+
}
|
| 224 |
+
```
|
assets/architecture.png
ADDED
|
Git LFS Details
|
assets/common_sense.png
ADDED
|
assets/long_context.png
ADDED
|
assets/retrieval.png
ADDED
|
benchmark_results.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"common_sense": {
|
| 3 |
+
"metric": "acc,none",
|
| 4 |
+
"scores_percent": {
|
| 5 |
+
"lambada_openai": 39.06462254997089,
|
| 6 |
+
"hellaswag": 39.22525393347939,
|
| 7 |
+
"piqa": 70.5658324265506,
|
| 8 |
+
"arc_easy": 66.37205387205387,
|
| 9 |
+
"arc_challenge": 30.46075085324232,
|
| 10 |
+
"winogrande": 53.67008681925809,
|
| 11 |
+
"openbookqa": 24.8,
|
| 12 |
+
"truthfulqa_mc2": 36.88509420492328
|
| 13 |
+
},
|
| 14 |
+
"mean_percent": 45.13046183243481
|
| 15 |
+
},
|
| 16 |
+
"retrieval": {
|
| 17 |
+
"metric": "contains,none",
|
| 18 |
+
"scores_percent": {
|
| 19 |
+
"swde": 47.434743474347435,
|
| 20 |
+
"squad_completion": 36.79624664879357,
|
| 21 |
+
"fda": 24.863883847549907,
|
| 22 |
+
"based_triviaqa": 43.06872037914692,
|
| 23 |
+
"based_nq": 10.484637313905607,
|
| 24 |
+
"based_drop": 17.441303306181123
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
"longbench": {
|
| 28 |
+
"metric": "score,none",
|
| 29 |
+
"scores_and_benchmark_se": {
|
| 30 |
+
"longbench_2wikimqa": {
|
| 31 |
+
"score": 6.9862030554896855,
|
| 32 |
+
"se": 0.7400626382964874
|
| 33 |
+
},
|
| 34 |
+
"longbench_gov_report": {
|
| 35 |
+
"score": 8.1067315936474,
|
| 36 |
+
"se": 0.2996812096482549
|
| 37 |
+
},
|
| 38 |
+
"longbench_hotpotqa": {
|
| 39 |
+
"score": 3.601733488122564,
|
| 40 |
+
"se": 0.48652116456134414
|
| 41 |
+
},
|
| 42 |
+
"longbench_lcc": {
|
| 43 |
+
"score": 10.108000000000004,
|
| 44 |
+
"se": 0.3765158700517174
|
| 45 |
+
},
|
| 46 |
+
"longbench_multi_news": {
|
| 47 |
+
"score": 10.82613523432961,
|
| 48 |
+
"se": 0.4334510042700067
|
| 49 |
+
},
|
| 50 |
+
"longbench_multifieldqa_en": {
|
| 51 |
+
"score": 11.440405273363387,
|
| 52 |
+
"se": 0.873931250965908
|
| 53 |
+
},
|
| 54 |
+
"longbench_musique": {
|
| 55 |
+
"score": 1.9269241806002015,
|
| 56 |
+
"se": 0.31723867802237216
|
| 57 |
+
},
|
| 58 |
+
"longbench_narrativeqa": {
|
| 59 |
+
"score": 1.7129816044409905,
|
| 60 |
+
"se": 0.1700376232571283
|
| 61 |
+
},
|
| 62 |
+
"longbench_qasper": {
|
| 63 |
+
"score": 3.9705291693063844,
|
| 64 |
+
"se": 0.35192468874955485
|
| 65 |
+
},
|
| 66 |
+
"longbench_qmsum": {
|
| 67 |
+
"score": 15.073444382452749,
|
| 68 |
+
"se": 0.4991732169644108
|
| 69 |
+
},
|
| 70 |
+
"longbench_repobench-p": {
|
| 71 |
+
"score": 10.266,
|
| 72 |
+
"se": 0.40655758034042955
|
| 73 |
+
},
|
| 74 |
+
"longbench_samsum": {
|
| 75 |
+
"score": 11.406380004969085,
|
| 76 |
+
"se": 0.6823319787201269
|
| 77 |
+
},
|
| 78 |
+
"longbench_trec": {
|
| 79 |
+
"score": 11.0,
|
| 80 |
+
"se": 2.2180166793668974
|
| 81 |
+
},
|
| 82 |
+
"longbench_triviaqa": {
|
| 83 |
+
"score": 11.759775857882689,
|
| 84 |
+
"se": 1.2207354573497748
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
}
|
config.json
CHANGED
|
@@ -24,10 +24,11 @@
|
|
| 24 |
"offset_k": 0.2
|
| 25 |
},
|
| 26 |
"tokenizer": "teknium/Llama-3.1-AlternateTokenizer",
|
| 27 |
-
"tokenizer_revision":
|
| 28 |
"training_context_length": 3072,
|
| 29 |
"tied_weights": {
|
| 30 |
"lm_head.weight": "embed.weight"
|
| 31 |
},
|
| 32 |
-
"note": "Use load_model.py; not compatible with Transformers AutoModel or GGUF."
|
|
|
|
| 33 |
}
|
|
|
|
| 24 |
"offset_k": 0.2
|
| 25 |
},
|
| 26 |
"tokenizer": "teknium/Llama-3.1-AlternateTokenizer",
|
| 27 |
+
"tokenizer_revision": "5590cc63198b0f111f4289daf006da0a12044173",
|
| 28 |
"training_context_length": 3072,
|
| 29 |
"tied_weights": {
|
| 30 |
"lm_head.weight": "embed.weight"
|
| 31 |
},
|
| 32 |
+
"note": "Use load_model.py; not compatible with Transformers AutoModel or GGUF.",
|
| 33 |
+
"tokenizer_revision_provenance": "Pinned at release packaging; original training-time revision not recorded."
|
| 34 |
}
|
generate.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Cached greedy completion for the custom AMOR release."""
|
| 2 |
+
import argparse
|
| 3 |
+
from contextlib import nullcontext
|
| 4 |
+
import json
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import torch
|
| 7 |
+
from transformers import AutoTokenizer
|
| 8 |
+
from load_model import load_model
|
| 9 |
+
from amor_decode import AMORDecodeWrapper
|
| 10 |
+
|
| 11 |
+
def main():
|
| 12 |
+
p=argparse.ArgumentParser(description=__doc__)
|
| 13 |
+
p.add_argument("--prompt",required=True)
|
| 14 |
+
p.add_argument("--max-new-tokens",type=int,default=32)
|
| 15 |
+
p.add_argument("--device",choices=["cuda","cpu"],default="cuda")
|
| 16 |
+
p.add_argument("--model-dir",type=Path,default=Path(__file__).resolve().parent)
|
| 17 |
+
a=p.parse_args()
|
| 18 |
+
if a.max_new_tokens<1:p.error("--max-new-tokens must be positive")
|
| 19 |
+
config=json.loads((a.model_dir/"config.json").read_text())
|
| 20 |
+
if a.device=="cuda" and not torch.cuda.is_available():
|
| 21 |
+
p.error("CUDA is unavailable; install a CUDA-enabled PyTorch build, or use --device cpu for Mamba2.")
|
| 22 |
+
if a.device=="cpu" and config["model_kwargs"]["backbone"]=="gdn":
|
| 23 |
+
p.error("This Gated DeltaNet implementation requires compatible GPU kernels.")
|
| 24 |
+
tokenizer=AutoTokenizer.from_pretrained(config["tokenizer"],revision=config.get("tokenizer_revision"))
|
| 25 |
+
model=load_model(a.model_dir,device=a.device,dtype=torch.float32)
|
| 26 |
+
ids=tokenizer(a.prompt,return_tensors="pt")["input_ids"].to(a.device)
|
| 27 |
+
if not ids.shape[1]:p.error("Prompt must tokenize to at least one token")
|
| 28 |
+
wrapper=AMORDecodeWrapper(model)
|
| 29 |
+
cast=torch.autocast("cuda",dtype=torch.bfloat16) if a.device=="cuda" else nullcontext()
|
| 30 |
+
generated=[]
|
| 31 |
+
with torch.inference_mode(),cast:
|
| 32 |
+
logits,cache=wrapper.prefill(ids)
|
| 33 |
+
for i in range(a.max_new_tokens):
|
| 34 |
+
scores=logits[:,-1] if logits.ndim==3 else logits
|
| 35 |
+
token=scores.argmax(-1,keepdim=True)
|
| 36 |
+
value=int(token.item())
|
| 37 |
+
if value==tokenizer.eos_token_id:break
|
| 38 |
+
generated.append(value)
|
| 39 |
+
if i+1<a.max_new_tokens:
|
| 40 |
+
logits,cache,_=wrapper.decode_step(token,cache,step_idx=ids.shape[1]+i)
|
| 41 |
+
print(a.prompt+tokenizer.decode(generated,skip_special_tokens=True))
|
| 42 |
+
if __name__=="__main__":main()
|
manifest.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
| 4 |
"sha256": "1d0dde41ece0f9620937f1a81a67e295ace0eae180c009d862006e8f3b288458"
|
| 5 |
},
|
| 6 |
"README.md": {
|
| 7 |
-
"bytes":
|
| 8 |
-
"sha256": "
|
| 9 |
},
|
| 10 |
"amor.py": {
|
| 11 |
"bytes": 25015,
|
|
@@ -16,8 +16,8 @@
|
|
| 16 |
"sha256": "9c3f27f8fe58d6a9b138c9303e732a1af89ed970cafbceb956a4047b1fb4adb7"
|
| 17 |
},
|
| 18 |
"config.json": {
|
| 19 |
-
"bytes":
|
| 20 |
-
"sha256": "
|
| 21 |
},
|
| 22 |
"export_metadata.json": {
|
| 23 |
"bytes": 935,
|
|
@@ -42,5 +42,29 @@
|
|
| 42 |
"training_summary.json": {
|
| 43 |
"bytes": 544,
|
| 44 |
"sha256": "ddc33c8ad60ec53ef5ca374dedc3bf7f49241fe414188e3d3c5bb8dc2db126fa"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
}
|
|
|
|
| 4 |
"sha256": "1d0dde41ece0f9620937f1a81a67e295ace0eae180c009d862006e8f3b288458"
|
| 5 |
},
|
| 6 |
"README.md": {
|
| 7 |
+
"bytes": 8788,
|
| 8 |
+
"sha256": "be8cac7a94f1286444e3f4702d08f6294d8bb4613449bfc44fe5aab27ef955e8"
|
| 9 |
},
|
| 10 |
"amor.py": {
|
| 11 |
"bytes": 25015,
|
|
|
|
| 16 |
"sha256": "9c3f27f8fe58d6a9b138c9303e732a1af89ed970cafbceb956a4047b1fb4adb7"
|
| 17 |
},
|
| 18 |
"config.json": {
|
| 19 |
+
"bytes": 975,
|
| 20 |
+
"sha256": "6228e38543275305089a569d3b7c29e8b2fcdc20ddb64fe8dbf76a8cbd1b8a43"
|
| 21 |
},
|
| 22 |
"export_metadata.json": {
|
| 23 |
"bytes": 935,
|
|
|
|
| 42 |
"training_summary.json": {
|
| 43 |
"bytes": 544,
|
| 44 |
"sha256": "ddc33c8ad60ec53ef5ca374dedc3bf7f49241fe414188e3d3c5bb8dc2db126fa"
|
| 45 |
+
},
|
| 46 |
+
"generate.py": {
|
| 47 |
+
"bytes": 2138,
|
| 48 |
+
"sha256": "f48ef56ea6966c2c684f034d036b0178e27a9d446504add875b7823bfca184f5"
|
| 49 |
+
},
|
| 50 |
+
"benchmark_results.json": {
|
| 51 |
+
"bytes": 2323,
|
| 52 |
+
"sha256": "9eaa7b751478238cce5bd1d8f3db7bf40b91155e97f5c8ec07f6c2a962a29712"
|
| 53 |
+
},
|
| 54 |
+
"assets/architecture.png": {
|
| 55 |
+
"bytes": 120925,
|
| 56 |
+
"sha256": "ab811b0869810d77486032f866356ffd3cdd401dfe2dfe4ee286de9b0da78858"
|
| 57 |
+
},
|
| 58 |
+
"assets/common_sense.png": {
|
| 59 |
+
"bytes": 57980,
|
| 60 |
+
"sha256": "8b62b20147bca3114cf8d6ea282e35cba5e4ee15ad6d9eba7fb8f8fdbebb2a36"
|
| 61 |
+
},
|
| 62 |
+
"assets/retrieval.png": {
|
| 63 |
+
"bytes": 61226,
|
| 64 |
+
"sha256": "58877f631b1fe95376c799733d943108e371bbab51cc0e3b41be609729dd0a79"
|
| 65 |
+
},
|
| 66 |
+
"assets/long_context.png": {
|
| 67 |
+
"bytes": 38008,
|
| 68 |
+
"sha256": "e34b9340716e4386a149142cff45f43ac8c160025e2c427102a259083dd0ac5f"
|
| 69 |
}
|
| 70 |
}
|