pimm.from_pretrained#
- from_pretrained(pretrained_model_name_or_path: str | Path, *, model_config: Mapping[str, Any] | None = None, model_type: str | None = None, model_cls: Type[Module] | None = None, config_path: str | Path | None = None, cache_dir: str | Path | None = None, revision: str | None = None, device: str | device | None = 'cpu', strict: bool = True, prefix: str | None = None, remove_prefix: bool = True, key_mapping: Dict[str, str] | None = None, keep_unmapped_keys: bool = False, filter_fn: Callable[[Dict[str, Any], Module], Dict[str, Any]] | None = None, return_metadata: bool = False, **model_kwargs: Any)[source]#
Load a pimm model from a local export, Hub repo, or raw checkpoint.
Exports are bare weights (
model.safetensors/model.bin) and carry no config, so the model config must come frommodel_config, a suppliedconfig_path, or an experiment directory next to a raw checkpoint.model_typecan override the registrytypefor the constructed output model.model_clscan construct an explicit Python class instead of using the registry. Extramodel_kwargsoverride config fields before construction.prefix/remove_prefixandkey_mappingmirrorload_pretrainedso exported pretraining checkpoints can be loaded into a different model shape, for examplekey_mapping={"student.backbone.": "backbone."}. By default,from_pretraineddrops keys that do not matchkey_mapping; passkeep_unmapped_keys=Trueto preserve them.