Transformers predictors

Huggingface Transformers predictors

Module: implementation.predictors



TransformersModel

Transformers model predictor. Subclass of Predictor.

When executed calls provided model.


__init__

Arguments:

  • cfg (TransformersModelConfig): Configuration for predictor.

  • input_class (Type[Input]): Class for input validation.

  • output_class (Type[Output]): Class for output validation.

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.


invoke

Call model

Arguments:

  • input_data (Input): Validated input.

  • evaluator (Evaluator): Evaluator in context of which executed.

Returns:

  • Dict[str, Any]: Result of execution.


config (Any)

Model configuration




TransformersGenerativeModel

Transformers generative model wrapper. Subclass of TransformersModel.

When executed calls generate method of provided model.


invoke

Call generate method of the model

Arguments:

  • input_data (Input): Validated input.

  • evaluator (Evaluator): Evaluator in context of which executed.

Returns:

  • Dict[str, Any]: Result of execution.




TransformersModelConfig

Transformers model configuration. Subclass of Config.


__init__

Arguments:

  • kwargs (Optional[Dict[str, Any]], optional): Extra model parameters.


config (Any)

Model configuration




TransformersPipeline

Transformers pipeline predictor. Subclass of Predictor.


__init__

Arguments:

  • cfg (TransformersPipelineConfig): Configuration for predictor.

  • input_class (Type[Input]): Class for input validation.

  • output_class (Type[Output]): Class for output validation.

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.


invoke

Call pipeline

Arguments:

  • input_data (Input): Validated input.

  • evaluator (Evaluator): Evaluator in context of which executed.

Returns:

  • Dict[str, Any]: Result of execution.


config (Any)

Model configuration




TransformersPipelineConfig

Transformers pipeline configuration. Subclass of Config.


__init__

Arguments:

circle-exclamation
  • torch_dtype (Optional[Union[str, torch.dtype]], optional): Sent directly as model_kwargs (just a simpler shortcut) to use the available precision for this model (torch.float16, torch.bfloat16, … or "auto"). Defaults to None.

  • trust_remote_code (bool, optional): 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 on your local machine. Defaults to False.

  • model_kwargs (Optional[Dict[str, Any]], optional): Additional dictionary of keyword arguments passed along to the model’s from_pretrained(..., **model_kwargs) function. Defaults to None.

  • pipeline_class (Optional[Any], optional): Defaults to None.

  • kwargs (Optional[Dict[str, Any]], optional): Additional keyword arguments passed along to the specific pipeline init (see the documentation for the corresponding pipeline class for possible values). Defaults to None.

For more, see:



Last updated