You are viewing documentation about an older version (1.2.0). View latest version

snowflake.ml.model.HuggingFacePipelineModel

class snowflake.ml.model.HuggingFacePipelineModel(task: Optional[str] = None, model: Optional[str] = None, *, revision: Optional[str] = None, token: Optional[str] = None, trust_remote_code: Optional[bool] = None, model_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Any)

Bases: object

Utility factory method to build a wrapper over transformers [Pipeline]. When deploying, this wrapper will create a real pipeline object and loading tokenizers and models.

For pipelines docs, please refer: https://huggingface.co/docs/transformers/en/main_classes/pipelines#transformers.pipeline

Args:
task: The task that pipeline will be used. If None it would be inferred from model.

For available tasks, please refer Transformers’s documentation. Defaults to None.

model: The model that will be used by the pipeline to make predictions. This can only be a model identifier

currently. If not provided, the default for the task will be loaded. Defaults to None.

revision: When passing a task name or a string model identifier: 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. Defaults to None.

token: The token to use as HTTP bearer authorization for remote files. Defaults to None. trust_remote_code: Whether or not to allow for custom code defined on the Hub in their own modeling,

configuration, tokenization or even pipeline files. This option should only be set to True for repositories you trust and in which you have read the code, as it will execute code present on the Hub. Defaults to None.

model_kwargs: Additional dictionary of keyword arguments passed along to the model’s from_pretrained(…,.

Defaults to None.

kwargs: Additional keyword arguments passed along to the specific pipeline init (see the documentation for

the corresponding pipeline class for possible values).

Return:

A wrapper over transformers [Pipeline].

Raises:

RuntimeError: Raised when the input argument cannot determine the pipeline. ValueError: Raised when the pipeline contains remote code but trust_remote_code is not set or False. ValueError: Raised when having conflicting arguments.