sagemaker.serve.spec.inference_spec#

Implements class that holds custom load and invoke function of a model

Classes

InferenceSpec()

Abstract base class for holding custom load, invoke and prepare functions.

class sagemaker.serve.spec.inference_spec.InferenceSpec[source]#

Bases: ABC

Abstract base class for holding custom load, invoke and prepare functions.

Provides a skeleton for customization to override the methods load, invoke and prepare.

get_model()[source]#

Return HuggingFace model name for inference spec

abstract invoke(input_object: object, model: object)[source]#

Given model object and input, make inference and return the result.

Parameters:
  • input_object (object) – The input to model

  • model (object) – The model object

abstract load(model_dir: str)[source]#

Loads the model stored in model_dir and return the model object.

Parameters:

model_dir (str) – Path to the directory where the model is stored.

postprocess(predictions: object)[source]#

Custom post-processing function

prepare(*args, **kwargs)[source]#

Custom prepare function

preprocess(input_data: object)[source]#

Custom pre-processing function