Views
No views yet
| Parameters | 315,758,848 |
| d_model | 1024 |
| Layers | 24 |
| Query heads | 16 |
| KV heads | 4 (GQA, 4:1) |
| Attention | Differential Attention |
| QK-Norm | Yes |
| Position encoding | RoPE |
| Normalization | RMSNorm, Pre-LN |
| Feed-forward | SwiGLU |
| Context length | 1024 |
| Vocab size | 50,304 (tiktoken GPT-2 BPE, padded) |
| Optimizer | Muon (2D matrices) + AdamW (rest) |
| Tied embeddings | Yes |
1from huggingface_hub import snapshot_download
2from safetensors.torch import load_file
3import sys
4
5local_dir = snapshot_download("JohnEnev/modern-llm-v2-sft")
6sys.path.insert(0, local_dir)
7
8from modeling.gpt import GPT, GPTConfig
9
10# GPTConfig() defaults may drift over time — set the V2 shape explicitly.
11config = GPTConfig(
12 vocab_size=50304, d_model=1024, n_layers=24, n_heads=16, n_kv_heads=4,
13 max_seq_len=1024, use_flash=True, tie_weights=True,
14 use_qk_norm=True, use_diff_attn=True, use_mhc=False,
15)
16model = GPT(config)
17
18state_dict = load_file(f"{local_dir}/model.safetensors")
19model.load_state_dict(state_dict, strict=False) # lm_head re-tied below
20model.lm_head.weight = model.token_embeddings.weight
21model.eval()1import torch, tiktoken
2
3enc = tiktoken.get_encoding("gpt2")
4input_ids = torch.tensor([enc.encode("The meaning of life is")])
5output = model.generate(input_ids, max_new_tokens=50, temperature=0.8, top_k=50)
6print(enc.decode(output[0].tolist()))modern-llm-v2-base — the pretrained base this was fine-tuned from