-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreload_index.py
More file actions
25 lines (20 loc) · 744 Bytes
/
Copy pathreload_index.py
File metadata and controls
25 lines (20 loc) · 744 Bytes
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
import json
# 读取原始文件
with open('/mnt/wb/models/llama3-8b-reload/model.safetensors.index.json', 'r') as f:
original_data = json.load(f)
# 生成新的结构
new_structure = {
"metadata": {
"total_size": 16064716800 # 这是你提供的 total_size,确保它是正确的
},
"weight_map": {}
}
# 进行格式转换
for safetensor, weights in original_data.items():
for weight in weights:
new_structure["weight_map"][weight] = safetensor
# 生成目标 JSON 文件
output_filename = '/mnt/wb/models/llama3-8b-reload/new_model.safetensors.index.json'
with open(output_filename, 'w') as f:
json.dump(new_structure, f, indent=2)
print(f"Formatted JSON has been written to {output_filename}")