添加模型服务 Dockerfile 与启动脚本

This commit is contained in:
luganyuan
2026-08-19 10:45:00 +08:00
parent 8013a6e1aa
commit cd825fc6cf
4 changed files with 113 additions and 0 deletions

18
detect_tokenizer.py Normal file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env python3
# 检测 tokenizer 是否需要修复
import json
import os
MODEL_DIR = os.environ.get("MODEL_DIR", "/model")
cfg_path = os.path.join(MODEL_DIR, "tokenizer_config.json")
if not os.path.exists(cfg_path):
print("no tokenizer_config.json")
raise SystemExit(0)
with open(cfg_path, "r", encoding="utf-8") as f:
cfg = json.load(f)
if cfg.get("tokenizer_class") in {"TokenizersBackend", "TiktokenTokenizer"}:
print("need_fix")
elif isinstance(cfg.get("extra_special_tokens"), list):
print("need_fix")
else:
print("ok")