🤗 Optimum provides an optimum.intel.neural_compressor package that enables you to apply magnitude pruning on many model hosted on the 🤗 hub using the Intel Neural Compressor pruning API.
( model: typing.Union[transformers.modeling_utils.PreTrainedModel, torch.nn.modules.module.Module] config_path_or_obj: typing.Union[str, optimum.intel.neural_compressor.configuration.IncPruningConfig] tokenizer: typing.Optional[transformers.tokenization_utils_base.PreTrainedTokenizerBase] = None eval_func: typing.Optional[typing.Callable] = None train_func: typing.Optional[typing.Callable] = None )
( model_name_or_path: str inc_config: typing.Union[optimum.intel.neural_compressor.configuration.IncPruningConfig, str, NoneType] = None config_name: str = None **kwargs ) → pruner
Parameters
str) —
Repository name in the Hugging Face Hub or path to a local directory hosting the model.
Union[IncPruningConfig, str], optional) —
Configuration file containing all the information related to the pruning strategy.
Can be either:IncPruningConfig,IncPruningConfig.from_pretrained.str, optional) —
Name of the configuration file.
str, optional) —
Path to a directory in which a downloaded configuration should be cached if the standard cache should
not be used.
bool, optional, defaults to False) —
Whether or not to force to (re-)download the configuration files and override the cached versions if
they exist.
bool, optional, defaults to False) —
Whether or not to delete incompletely received file. Attempts to resume the download if such a file
exists.
str, optional) —
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so revision can be any
identifier allowed by git.
Callable, optional) —
Evaluation function to evaluate the tuning objective.
Callable, optional) —
Training function which will be combined with pruning.
Returns
pruner
IncPruner object.
Instantiate an IncPruner object from a configuration file which can either be hosted on huggingface.co or from a local directory path.