RetNet-0.5B - from-scratch training line
Collection
From-scratch 0.5B RetNet (21.6 B tokens): epoch 1-3, repair v21.1, long-context v21.2, chat v21.3-chat, 16k/8k research exports. β’ 18 items β’ Updated
Bilingual ZH+EN chat and controllable-thinking checkpoint (SFT v3) trained from scratch on top of Ayaka157/SWA-RetNet-v2-0.5B-Base.
| Spec | Value |
|---|---|
| Parameters | 513,081,852 (tied embeddings) |
| Architecture | 24 layers = 19 Multi-Scale Gated Delta-Retention + 5 Local SWA GQA ([4, 9, 14, 19, 23], W=512) |
| Width | d_model=1280, 10 heads (head_dim=128, kv_heads=2), SwiGLU 3200, depthwise conv k=4 |
| Vocabulary / Context | 32,768 bilingual BPE (tokenizer_32k.json) / 4,096 context |
| Inference memory | O(1) recurrent state + W=512 ring buffer (no global KV cache) |
| Precision | model.safetensors stored in fp32; load in bf16 for inference |
SHA256 (model.safetensors) |
a87f34ce85fb6dc1087cfa0f817e7268a7db22ea27ced9ee659e78f7febd9a5d |
SWA-RetNet-v2-0.5B-Base (5.45B unique bilingual tokens, 4k val CE 2.6035).132,919 clean bilingual conversations (97.10M supervised tokens), including 16,370 open-domain bilingual CoT rows mapped to reserved special tokens 8:<|think|> / 9:<|/think|>, 5,000 short-turn predicate-switch anti-echo dialogues, 11,681 long-context update/correction trajectories with filler turns masked out (code=2), and 12,000 4k pretrain replay rows.5,600 steps (64 seq/step, 2ΓRTX PRO 6000 DDP, BF16, cosine 3e-5 -> 2.5e-6).step 0 -> 5,600): weighted 2.6619 -> 1.6366, dialogue 2.3847 -> 1.7677, tide 2.6582 -> 1.7376, memory 3.5924 -> 0.0168, lm 2.6101 -> 2.6420.512 vs 4096 on final 256 tokens): EN Ξ_marginal = +0.0565 (95% CI [+0.0236, +0.1025]), ZH Ξ_marginal = +0.0254 ([+0.0112, +0.0445]).Special token IDs in tokenizer_32k.json: 1:<|bos|>, 2:<|eos|>, 3:<|im_start|>, 4:<|im_end|>, 5:<|system|>, 6:<|user|>, 7:<|assistant|>, 8:<|think|>, 9:<|/think|>.
Append one control tag to the system prompt to select thinking depth:
[ζθοΌε
³ι] / [Thinking: off] β direct answer (mask token 8 during decoding)[ζθοΌθͺε¨] / [Thinking: auto] β direct on casual chat, concise <|think|> on reasoning/updates[ζθοΌθ½»] / [Thinking: low] β brief reasoning (β€160 tok)[ζθοΌδΈ] / [Thinking: medium] β multi-step reasoning (β€420 tok)[ζθοΌζ·±] / [Thinking: high] β thorough derivation (β€1024 tok)Load with modeling_retnet_v2.py (included in this repo and at github.com/Ayaka157/RetNet):
import torch
from tokenizers import Tokenizer
from modeling_retnet_v2 import RetNetV2ForCausalLM
tok = Tokenizer.from_file("tokenizer_32k.json")
model = RetNetV2ForCausalLM.from_pretrained(".", use_fla=False, use_liger=False, use_flex_swa=False)
model = model.to("cuda", dtype=torch.bfloat16).eval()
For full streaming chat and 5-mode thinking guardrails, see serve/v2_runtime.py in the GitHub repository.
W=512 stays low; semantic multi-turn fact updates and role corrections across 1kβ2.5k tokens work reliably.