File size: 817 Bytes
c125a8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from model import HelloWorldModel, HelloWorldConfig
from transformers import PreTrainedTokenizerFast
import torch

print("Loading configuration...")
config = HelloWorldConfig.from_pretrained(".")

print("Loading model...")
model = HelloWorldModel(config)
model.load_state_dict(torch.load("pytorch_model.bin", map_location="cpu", weights_only=True))
model.eval()

print("Loading tokenizer...")
tokenizer = PreTrainedTokenizerFast(tokenizer_file="tokenizer.json")

print("\nTesting model generation...")
output = model.generate_hello_world()
print(f"Model output: {output}")

print("\nTesting tokenization...")
text = "Hello World"
tokens = tokenizer.encode(text)
print(f"Tokenized '{text}': {tokens}")

decoded = tokenizer.decode(tokens)
print(f"Decoded back: {decoded}")

print("\nModel test completed successfully!")