code
Browse files
app.py
CHANGED
|
@@ -4,7 +4,8 @@ import torch
|
|
| 4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
os.
|
|
|
|
| 8 |
|
| 9 |
from safetensors.torch import load_file, save_file
|
| 10 |
|
|
@@ -30,7 +31,8 @@ def merge_safetensors(input_dir, output_file):
|
|
| 30 |
input_dir = "./phi-4/phi-4" # 包含分片文件的目录
|
| 31 |
output_file = "./phi-4/phi-4/model.safetensors" # 合并后的文件路径
|
| 32 |
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
# 加载 phi-4 模型和 tokenizer
|
| 36 |
torch.random.manual_seed(0)
|
|
|
|
| 4 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
if not os.path.exists("./phi-4"):
|
| 8 |
+
os.system('huggingface-cli download matteogeniaccio/phi-4 --local-dir ./phi-4 --include "phi-4/*"')
|
| 9 |
|
| 10 |
from safetensors.torch import load_file, save_file
|
| 11 |
|
|
|
|
| 31 |
input_dir = "./phi-4/phi-4" # 包含分片文件的目录
|
| 32 |
output_file = "./phi-4/phi-4/model.safetensors" # 合并后的文件路径
|
| 33 |
|
| 34 |
+
if not os.path.exists(output_file):
|
| 35 |
+
merge_safetensors(input_dir, output_file)
|
| 36 |
|
| 37 |
# 加载 phi-4 模型和 tokenizer
|
| 38 |
torch.random.manual_seed(0)
|