1. Deployment
  2. Amazon SageMaker

Use this path if you want a managed AWS endpoint with the Hugging Face SageMaker SDK.

The Hugging Face deploy snippet currently warns that it is not yet compatible with sagemaker >= 3.0.0. If you follow this exact example, pin sagemaker<3.0.0.

1

Install a compatible SDK

pip install "sagemaker<3.0.0"
2

Deploy the model

import boto3
import sagemaker
from sagemaker.huggingface import HuggingFaceModel

try:
    role = sagemaker.get_execution_role()
except ValueError:
    iam = boto3.client("iam")
    role = iam.get_role(RoleName="sagemaker_execution_role")["Role"]["Arn"]

hub = {
    "HF_MODEL_ID": "CohereLabs/North-Mini-Code-1.0",
    "HF_TASK": "text-generation",
}

huggingface_model = HuggingFaceModel(
    transformers_version="4.51.3",
    pytorch_version="2.6.0",
    py_version="py312",
    env=hub,
    role=role,
)

predictor = huggingface_model.deploy(
    initial_instance_count=1,
    instance_type="ml.m5.xlarge",
)

response = predictor.predict(
    {
        "inputs": "Write a Python function that removes duplicates from a list while preserving order."
    }
)

print(response)
3

Right-size the instance

Start with a development-sized instance for bring-up, then size for real traffic and model memory after benchmarking.

Use SageMaker when you want AWS-managed endpoints and IAM-centric operations. If your target hardware is Inferentia2 or Trainium, also review /deployment/aws-neuron.