model_type: The unique ID for the model type. Models with the same model_type share the same architectures, template, get_function, etc.
(model_meta: ModelMeta, *, exist_ok: bool = False)
| 29 | |
| 30 | |
| 31 | def register_model(model_meta: ModelMeta, *, exist_ok: bool = False) -> None: |
| 32 | """ |
| 33 | model_type: The unique ID for the model type. Models with the same model_type share |
| 34 | the same architectures, template, get_function, etc. |
| 35 | """ |
| 36 | from .model_arch import get_model_arch |
| 37 | model_type = model_meta.model_type |
| 38 | if not exist_ok and model_type in MODEL_MAPPING: |
| 39 | raise ValueError(f'The `{model_type}` has already been registered in the MODEL_MAPPING.') |
| 40 | if model_meta.model_arch: |
| 41 | model_meta.model_arch = get_model_arch(model_meta.model_arch) |
| 42 | MODEL_MAPPING[model_type] = model_meta |
| 43 | |
| 44 | |
| 45 | def load_by_unsloth(args): |
no test coverage detected