Upload app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,7 @@ class SmolLM(nn.Module):
|
|
| 32 |
|
| 33 |
|
| 34 |
def load_model():
|
| 35 |
-
checkpoint_path = '
|
| 36 |
embed_dim = 512
|
| 37 |
num_heads = 8
|
| 38 |
num_layers = 4
|
|
@@ -43,11 +43,12 @@ def load_model():
|
|
| 43 |
#model = SmolLM(vocab_size, embed_dim, num_heads, num_layers, max_seq_len).to(device)
|
| 44 |
|
| 45 |
#model.load_state_dict(torch.load(checkpoint_path, map_location=torch.device('cpu')))
|
| 46 |
-
checkpoint = torch.load(checkpoint_path, map_location=device)
|
| 47 |
#config = checkpoint['config']
|
| 48 |
-
model = SmolLM(vocab_size, embed_dim, num_heads, num_layers, max_seq_len)
|
| 49 |
-
model.load_state_dict(checkpoint)
|
| 50 |
-
model.
|
|
|
|
| 51 |
model.eval() # Set to evaluation mode
|
| 52 |
|
| 53 |
# Disable gradient computation
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
def load_model():
|
| 35 |
+
checkpoint_path = 'final_checkpoint.pth'
|
| 36 |
embed_dim = 512
|
| 37 |
num_heads = 8
|
| 38 |
num_layers = 4
|
|
|
|
| 43 |
#model = SmolLM(vocab_size, embed_dim, num_heads, num_layers, max_seq_len).to(device)
|
| 44 |
|
| 45 |
#model.load_state_dict(torch.load(checkpoint_path, map_location=torch.device('cpu')))
|
| 46 |
+
#checkpoint = torch.load(checkpoint_path, map_location=device)
|
| 47 |
#config = checkpoint['config']
|
| 48 |
+
#model = SmolLM(vocab_size, embed_dim, num_heads, num_layers, max_seq_len)
|
| 49 |
+
#model.load_state_dict(checkpoint)
|
| 50 |
+
model = torch.load(checkpoint_path, map_location=device, weights_only=False)
|
| 51 |
+
model = model.to(device)
|
| 52 |
model.eval() # Set to evaluation mode
|
| 53 |
|
| 54 |
# Disable gradient computation
|