MODELCATALOG

Model artifact

Model artifact

Model artifact

Bridges training and inference.

Inputs

trained state + inference-critical preprocessing/config

Outputs

immutable packaged artifact URI

Core explanation

The artifact is the durable handoff from model development to deployment.

01

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.
Lifecycle position
training job -> /opt/ml/model -> packaged artifact -> S3
02

Implementation anatomy

The sequence you would actually build or configure.

  1. 1

    Write model/preprocessing assets to /opt/ml/model.

  2. 2

    Persist label/config metadata.

  3. 3

    Let SageMaker package/upload to S3.

  4. 4

    Treat the artifact URI as immutable for a registered version.

Objects / terms worth remembering
model.tar.gzS3 model URIpreprocessing artifact
03

Concrete example

A real model-development or production flow.

1

model.joblib = fitted LogisticRegression

↓
2

vectorizer.joblib = fitted TF-IDF

↓
3

labels.json = class mapping

↓
4

metadata.json = model/code version

↓
5

packaged model.tar.gz stored in S3

04

Implementation lab

Concrete code, data manipulation and configuration for this lifecycle step.

01

Inspect what you intend to package

text
# /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.
02

Load-test the artifact contract locally

python

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.

✓ preprocessing✓ model weights/object✓ label/config mapping✓ artifact version/checksum✓ S3 access✓ loader compatibility