Deploy & inference
ModelBuilder
Central V3 abstraction for creating a deployable model configuration.
trained model/resource/package + serving schema/image
SageMaker Model resource and deployable Endpoint
I think ModelTrainer on the training side and ModelBuilder on the deployment side.
Mental model
What this means before worrying about syntax.
ModelBuilder can take a framework model, inference specification or registered model package, build serving artifacts/configuration and deploy it.
- ModelBuilder is the V3 serving-side abstraction that turns a model/inference specification into deployable serving resources.
- Training artifact and inference contract meet here.
- Request/response schema and preprocessing are part of production design.
trained or registered model -> ModelBuilder.build() -> deployable model -> deploy() -> endpoint
Implementation anatomy
The sequence you would actually build or configure.
- 1
Identify model source.
- 2
Define schema/serialization as needed.
- 3
Select serving image and compute.
- 4
Build serving configuration.
- 5
Deploy.
- 6
Smoke-test representative requests and capture endpoint/version identity.
Concrete example
A real model-development or production flow.
Input JSON contains complaint text
Inference loads vectorizer + classifier
Transforms text then predict_proba
Response returns category, probability, model_version
Application applies 0.75 routing threshold
Implementation lab
Concrete code, data manipulation and configuration for this lifecycle step.
Build and deploy from a trained object/resource
Current V3 ModelBuilder returns core Model/Endpoint resources rather than the old Predictor abstraction.
from sagemaker.serve.model_builder import ModelBuilder
builder = ModelBuilder(
model=trained_model_or_model_package,
role_arn=SAGEMAKER_ROLE_ARN,
sagemaker_session=session,
instance_type="ml.m5.xlarge",
)
model_resource = builder.build(
model_name="complaint-classifier-v17"
)
endpoint = builder.deploy(
endpoint_name="complaint-classifier-prod",
initial_instance_count=2,
)
Invoke the returned Endpoint resource
payload = {
"text": "I do not recognize this debit card purchase"
}
result = endpoint.invoke(data=payload)
print(result)
Design decisions that matter
- Serving mode and compute.
- Explicit request/output contract.
- Dependency packaging.
- Where feature retrieval/business rules live.
Common failure modes
- Local load success does not guarantee serving-image dependency compatibility.
- Opaque feature retrieval inside model code creates coupling.
- A model package still needs a valid serving contract.
Production readiness check
Items to close before treating this step as production-ready.