mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-10-26 16:35:05 +00:00
24 lines
886 B
Python
24 lines
886 B
Python
from __future__ import annotations
|
||
|
||
from pathlib import Path
|
||
|
||
from deepinfer import AttrDict
|
||
|
||
|
||
def load_model_config(model: str) -> AttrDict:
|
||
"""加载 V4.1 的 model_cfg(AttrDict)。
|
||
|
||
`model` 必须指向 HF 目录;配置与权重来自同一目录。
|
||
|
||
返回的 model_cfg 至少包含:
|
||
- model_cfg.architecture:HF architectures 中声明且通过注册表校验的架构名
|
||
- model_cfg.gpt:模型结构(num_attention_heads / hidden_size / vocab_size / kv_lora_rank ...)
|
||
- model_cfg.vl_aligner:必需的 HF 视觉/投影结构
|
||
"""
|
||
# HF 配置解析只处理数据,不导入模型实现。
|
||
from deepinfer.hugging_face import load_hf_model_config
|
||
|
||
model_cfg = load_hf_model_config(Path(model) / "config.json")
|
||
assert "vl_aligner" in model_cfg, "Only multimodal HF models with vl_aligner are supported"
|
||
return model_cfg
|