Model artifact
Model artifact
Bridges training and inference.
trained state + inference-critical preprocessing/config
immutable packaged artifact URI
The artifact is the durable handoff from model development to deployment.
Mental model
What this means before worrying about syntax.
Training produces persisted model files and related preprocessing assets, typically stored in S3 and later consumed for registration and deployment.
- Artifact is the durable handoff from training to serving.
- It must contain all fitted state required to reproduce inference.
- Artifact, endpoint and training job are separate lifecycle objects.
training job -> /opt/ml/model -> packaged artifact -> S3
Implementation anatomy
The sequence you would actually build or configure.
- 1
Write model/preprocessing assets to /opt/ml/model.
- 2
Persist label/config metadata.
- 3
Let SageMaker package/upload to S3.
- 4
Treat the artifact URI as immutable for a registered version.
Concrete example
A real model-development or production flow.
model.joblib = fitted LogisticRegression
vectorizer.joblib = fitted TF-IDF
labels.json = class mapping
metadata.json = model/code version
packaged model.tar.gz stored in S3
Implementation lab
Concrete code, data manipulation and configuration for this lifecycle step.
Inspect what you intend to package
# /opt/ml/model after training
#
# pipeline.joblib
# model_metadata.json
# requirements-lock.txt (optional but useful)
# inference_schema.json (optional)
#
# SageMaker packages the model directory into the training output artifact.
Load-test the artifact contract locally
Before deployment, prove the artifact alone can reconstruct inference behavior.
import json
import joblib
from pathlib import Path
artifact_dir = Path("model_artifact_unpacked")
model = joblib.load(artifact_dir / "pipeline.joblib")
metadata = json.loads(
(artifact_dir / "model_metadata.json").read_text()
)
sample = ["I did not make this debit card purchase"]
proba = model.predict_proba(sample)[0]
print(model.classes_[proba.argmax()], proba.max())
print("threshold:", metadata["confidence_threshold"])
Design decisions that matter
- Single sklearn Pipeline vs separate objects.
- Keep independently changing business rules outside the model artifact when appropriate.
Common failure modes
- Saving only the estimator can make inference impossible.
- An artifact is not automatically a deployable endpoint.
- Loader/runtime version incompatibility can fail deployment.
Production readiness check
Items to close before treating this step as production-ready.