Views
No views yet
| Architecture | Decoder-only transformer (relu² FFN, RoPE, GQA, RMSNorm) |
| Layers | 12 |
| d_model | 768 |
| Attention heads | 6 (KV heads: 6) |
| Sequence length | 2048 |
| Vocabulary | 32,768 (byte-level BPE, PT-trained) |
| Trained steps | 572 |
| Final val bpb | 0.6753 |
| Training time | 0.9 h on 1× NVIDIA RTX A6000 |
1import os
2import torch
3from huggingface_hub import snapshot_download
4from nanochat.checkpoint_manager import build_model, find_last_step
5from nanochat.engine import Engine
6
7local_dir = snapshot_download(repo_id="pbarcelos1/nanochat-pt-latn-d12-midtrain")
8os.environ["NANOCHAT_BASE_DIR"] = local_dir
9
10device = torch.device("cuda:0")
11step = find_last_step(local_dir)
12model, tokenizer, meta = build_model(local_dir, step, device, phase="eval")
13
14engine = Engine(model, tokenizer)
15tokens = tokenizer("Era uma vez,", prepend="<|bos|>")
16samples, _ = engine.generate_batch(tokens, num_samples=1, max_tokens=200, temperature=0.8)
17print(tokenizer.decode(samples[0]))