Views
No views yet
1import torch
2from src.model import GPT, GPTConfig
3
4# Load the configuration and initialize the model
5config = GPTConfig(
6 block_size=256,
7 n_layer=4,
8 n_head=4,
9 n_kv_head=2,
10 n_embd=128,
11 n_experts=8,
12 num_experts_per_tok=2
13)
14model = GPT(config)
15
16# Load the weights from the safetensors file
17from safetensors.torch import load_file
18state_dict = load_file("model.safetensors")
19model.load_state_dict(state_dict)
20
21model.eval()
22model.to('cuda' if torch.cuda.is_available() else 'cpu')
23
24# You can now generate text using the `model.generate` method
25# (assuming you have the tokenizer loaded from the original repo)