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 from model_config, a supplied config_path, or an experiment directory next to a raw checkpoint. model_type can override the registry type for the constructed output model. model_cls can construct an explicit Python class instead of using the registry. Extra model_kwargs override config fields before construction.

prefix/remove_prefix and key_mapping mirror load_pretrained so exported pretraining checkpoints can be loaded into a different model shape, for example key_mapping={"student.backbone.": "backbone."}. By default, from_pretrained drops keys that do not match key_mapping; pass keep_unmapped_keys=True to preserve them.