Add the final 49.152B-token checkpoint
Browse files- README.md +70 -0
- model.safetensors +3 -0
- model_config.json +51 -0
- tokenizer.tiktoken.json +0 -0
README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: pytorch
|
| 3 |
+
pipeline_tag: text-generation
|
| 4 |
+
tags:
|
| 5 |
+
- nexttransformer
|
| 6 |
+
- linear-attention
|
| 7 |
+
- causal-lm
|
| 8 |
+
- pretrained
|
| 9 |
+
- safetensors
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# NextTransformer RetNet
|
| 13 |
+
|
| 14 |
+
This is the final RetNet checkpoint (method `retnet`) from the NextTransformer 49.152B-token comparison. It has 1,410,077,320 parameters and a 2,048-token context. Pretraining used ClimbMix for 46,875 updates at seed 42.
|
| 15 |
+
|
| 16 |
+
Retain memory across several decay timescales.
|
| 17 |
+
|
| 18 |
+
| Final evaluation | Result |
|
| 19 |
+
|---|---:|
|
| 20 |
+
| Validation BPB | 0.6797 |
|
| 21 |
+
| CORE-22 (×100) | 29.36 |
|
| 22 |
+
|
| 23 |
+
Validation BPB was measured on 20,971,520 tokens in a separate evaluation of the final checkpoint. CORE-22 is the mean of the 22 centered task scores.
|
| 24 |
+
|
| 25 |
+
[Architecture](https://github.com/Interactive-Active-AI/NextTransformer/blob/1cc58931aa9db7fd258c982a41d6adcd697bb45b/results/methods/retnet.json) · [Run record](https://github.com/Interactive-Active-AI/NextTransformer/blob/1cc58931aa9db7fd258c982a41d6adcd697bb45b/results/runs/retnet.json) · [Checkpoint audit](https://github.com/Interactive-Active-AI/NextTransformer/blob/1cc58931aa9db7fd258c982a41d6adcd697bb45b/evidence/audits/retnet.json)
|
| 26 |
+
|
| 27 |
+
## Load the weights
|
| 28 |
+
|
| 29 |
+
Install the pinned NextTransformer implementation and the safetensors reader with Python 3.10–3.13.
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
pip install "nexttransformer @ git+https://github.com/Interactive-Active-AI/NextTransformer.git@1cc58931aa9db7fd258c982a41d6adcd697bb45b" safetensors
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
The example uses the PyTorch reference recurrence on CPU. The saved model configuration records the fused recurrence used in training.
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
import base64
|
| 39 |
+
import json
|
| 40 |
+
import os
|
| 41 |
+
from pathlib import Path
|
| 42 |
+
|
| 43 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
| 44 |
+
|
| 45 |
+
import tiktoken
|
| 46 |
+
import torch
|
| 47 |
+
from huggingface_hub import snapshot_download
|
| 48 |
+
from safetensors.torch import load_file
|
| 49 |
+
from nexttransformer.models import build_model, config_from_dict
|
| 50 |
+
|
| 51 |
+
root = Path(snapshot_download("NextTransformer/RetNet-49B-Tokens"))
|
| 52 |
+
raw = json.loads((root / "model_config.json").read_text())
|
| 53 |
+
config = config_from_dict({**raw, "backend": "reference"})
|
| 54 |
+
model = build_model(config, device="cpu")
|
| 55 |
+
model.load_state_dict(load_file(root / "model.safetensors"), strict=True)
|
| 56 |
+
model.set_step(46875)
|
| 57 |
+
model.eval()
|
| 58 |
+
|
| 59 |
+
spec = json.loads((root / "tokenizer.tiktoken.json").read_text())
|
| 60 |
+
encoding = tiktoken.Encoding(
|
| 61 |
+
name=spec["name"],
|
| 62 |
+
pat_str=spec["pat_str"],
|
| 63 |
+
mergeable_ranks={base64.b64decode(b): rank for b, rank in spec["mergeable_ranks"]},
|
| 64 |
+
special_tokens=spec["special_tokens"],
|
| 65 |
+
)
|
| 66 |
+
prompt = [encoding.encode_single_token("<|bos|>")] + encoding.encode_ordinary("The sky is")
|
| 67 |
+
with torch.inference_mode():
|
| 68 |
+
logits = model(torch.tensor([prompt]))
|
| 69 |
+
print(encoding.decode([int(logits[0, -1].argmax())]))
|
| 70 |
+
```
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f7542116b9a36e37085a18e04a1732c7fe53896dda85d36f9633938c5449e437
|
| 3 |
+
size 4331709816
|
model_config.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"method": "retnet",
|
| 3 |
+
"width": 1536,
|
| 4 |
+
"heads": 12,
|
| 5 |
+
"vocab_size": 32768,
|
| 6 |
+
"sequence_len": 2048,
|
| 7 |
+
"mlp_width": 6144,
|
| 8 |
+
"layers": 23,
|
| 9 |
+
"pre_layers": 3,
|
| 10 |
+
"core_layers": 9,
|
| 11 |
+
"post_layers": 3,
|
| 12 |
+
"loops": 2,
|
| 13 |
+
"window_pattern": "SSSL",
|
| 14 |
+
"max_loops": 3,
|
| 15 |
+
"act_epsilon": 0.01,
|
| 16 |
+
"ponder_weight": 0.01,
|
| 17 |
+
"huginn_mean": 3.0,
|
| 18 |
+
"huginn_sigma": 0.5,
|
| 19 |
+
"huginn_backprop_loops": 2,
|
| 20 |
+
"routing_seed": 1729,
|
| 21 |
+
"eval_loops": 3,
|
| 22 |
+
"ouro_entropy_weight": 0.1,
|
| 23 |
+
"ouro_gate_steps": 1024,
|
| 24 |
+
"ouro_exit_quantile": 0.5,
|
| 25 |
+
"sparse_topk": 256,
|
| 26 |
+
"block_size": 128,
|
| 27 |
+
"compression_size": 4,
|
| 28 |
+
"local_window": 512,
|
| 29 |
+
"index_heads": 4,
|
| 30 |
+
"index_dim": 128,
|
| 31 |
+
"index_rope_dim": 64,
|
| 32 |
+
"index_loss_weight": 1.0,
|
| 33 |
+
"burnin_steps": 512,
|
| 34 |
+
"slots": 64,
|
| 35 |
+
"gate_rank": 16,
|
| 36 |
+
"conv_size": 4,
|
| 37 |
+
"reference_chunk": 32,
|
| 38 |
+
"backend": "fla_chunk64",
|
| 39 |
+
"scale": "formal",
|
| 40 |
+
"residual_streams": 4,
|
| 41 |
+
"residual_gate_init": 0.01,
|
| 42 |
+
"sinkhorn_iterations": 20,
|
| 43 |
+
"attnres_groups": 8,
|
| 44 |
+
"sliding_window": 2048,
|
| 45 |
+
"q_rank": 768,
|
| 46 |
+
"kv_rank": 256,
|
| 47 |
+
"qk_nope_dim": 64,
|
| 48 |
+
"qk_rope_dim": 64,
|
| 49 |
+
"v_head_dim": 128,
|
| 50 |
+
"options": []
|
| 51 |
+
}
|
tokenizer.tiktoken.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|