Views
No views yet
por_Latn.| 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 | 4,830 |
| Training tokens | ~2.53 B |
| Final val bpb | 0.9487 (PT-Latn validation shard) |
| Training time | 12.2 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
7# Download repo to local cache (~760 MB, cached after first run)
8local_dir = snapshot_download(repo_id="pbarcelos1/nanochat-pt-latn-d12")
9os.environ["NANOCHAT_BASE_DIR"] = local_dir # needed for tokenizer lookup
10
11device = torch.device("cuda:0")
12step = find_last_step(local_dir)
13model, tokenizer, meta = build_model(local_dir, step, device, phase="eval")
14
15engine = Engine(model, tokenizer)
16tokens = tokenizer("Era uma vez,", prepend="<|bos|>")
17samples, _ = engine.generate_batch(tokens, num_samples=1, max_tokens=200, temperature=0.8)
18print(tokenizer.decode(samples[0]))