File size: 400 Bytes
0fe9461
 
 
 
 
 
2f6eb09
0fe9461
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import torch
from safetensors.torch import load_file
from transformers import AutoConfig, AutoModel

# Path to your safetensors file
safetensors_path = "model.safetensors"
bin_path = "pytorch_model.bin"

# Load model weights from safetensors
state_dict = load_file(safetensors_path)

# Save as pytorch_model.bin
torch.save(state_dict, bin_path)

print(f"Converted {safetensors_path} to {bin_path}.")