ggingFaceModelDeployer.get_active_model_deployer()# fetch existing services with same pipeline name, step name and model name

existing_services = model_deployer.find_model_server(

pipeline_name=pipeline_name,

pipeline_step_name=pipeline_step_name,

model_name=model_name,

running=running,

if not existing_services:

raise RuntimeError(

f"No Hugging Face inference endpoint deployed by step "

f"'{pipeline_step_name}' in pipeline '{pipeline_name}' with name "

f"'{model_name}' is currently running."

return existing_services[0]

# Use the service for inference

@step

def predictor(

service: HuggingFaceDeploymentService,

data: str

) -> Annotated[str, "predictions"]:

"""Run a inference request against a prediction service"""

prediction = service.predict(data)

return prediction

@pipeline

def huggingface_deployment_inference_pipeline(

pipeline_name: str, pipeline_step_name: str = "huggingface_model_deployer_step",

):

inference_data = ...

model_deployment_service = prediction_service_loader(

pipeline_name=pipeline_name,

pipeline_step_name=pipeline_step_name,

predictions = predictor(model_deployment_service, inference_data)

For more information and a full list of configurable attributes of the Hugging Face Model Deployer, check out the SDK Docs.

PreviousBentoML

NextDevelop a Custom Model Deployer

Last updated 15 days ago