Skip to content

Skill 2.2.1: Apply Amazon SageMaker AI built-in algorithms and common ML libraries.

Task 2.2: ML Model and Foundation Model (FM) Development – Train, fine-tune, and customize models for ML and AI solutions.

Hard rule: Every SageMaker training job is a container + an entry point + hyperparameters + S3 data channels. The only variable is who wrote the training code — AWS (built-in), you on an AWS-managed image (script mode), or you in your own image (BYOC).

Three Routes into a Managed Training Job

Route Who supplies training code Who supplies container When the exam wants it
Built-in algorithm AWS (closed) AWS Standard tabular/text/image/TS task; you want zero ML plumbing
Script mode You (entry_point script) AWS (Deep Learning Container) Custom architecture/loss/data loop in a supported framework; do not want to build Docker
BYOC (bring your own container) You You (ECR) Framework or OS dependency the DLCs don't cover; heaviest to maintain
  • Script mode is the default correct answer whenever the stem says "custom code" + "supported framework" + "no container maintenance."
  • Built-in algorithms run in script mode internally — AWS ships the script for you. Don't let the two terms blur.
  • BYOC is the distractor trap when the constraint is "avoid building/maintaining images."

Built-in Algorithm Selection Matrix

Problem Algorithm Key configuration notes
Tabular classification/regression (general) XGBoost objective (binary:logistic, multi:softmax, reg:squarederror); num_round, eta, max_depth. Supports distributed training. Default first-choice distractor answer
Tabular, linear baseline Linear Learner One algorithm, three modes via predictor_type = regressor / binary_classifier / multiclass_classifier. Built-in normalization; handles unbalanced classes
Tabular, minimal tuning AutoGluon-Tabular AutoML — no feature engineering; LightGBM / CatBoost also available as built-ins
Clustering K-Means k, mini_batch_size; requires RecordIO-Protobuf or CSV
Dimensionality reduction PCA num_components; unsupervised, no labels
Anomaly detection (tabular) Random Cut Forest Unsupervised; outputs anomaly score
Anomaly detection (IP/entity) IP Insights Learns normal IP↔entity access patterns
Sparse / recommendation Factorization Machines Binary classification + regression on sparse one-hot data
Recommendations (neural) Neural Collaborative Filtering (NCF) Implicit/explicit feedback
Time-series forecasting DeepAR (probabilistic) / Prophet (additive) DeepAR needs time_freq, prediction_length; no built-in algorithm is autoregressive-by-hand
Text classification / embeddings BlazingText mode=supervised (classification) or word2vec (cbow/skipgram/batch_skipgram)
Topic modeling LDA / Neural Topic Model Unsupervised; num_topics
Translation / summarization Sequence-to-Sequence Attention-based encoder-decoder
Similarity / embeddings (general) Object2Vec Pairs of inputs → embedding space
Image classification Image Classification ResNet / Inception backbones; transfer learning supported
Object detection Object Detection SSD or Faster R-CNN
Pixel-level labeling Semantic Segmentation FCN, PSP, DeepLabV3
Per-object masks Instance Segmentation Mask R-CNN

Trap: "Rewrite the logic as a built-in algorithm" is wrong whenever the stem describes a custom architecture, custom loss, or a non-standard data loop. Built-ins fit standard task shapes only.

Data Formats, Modes & Channels

Format Used by Note
RecordIO-Protobuf Most built-ins (K-Means, PCA, Linear Learner, image algos) Required for Pipe mode; most efficient
CSV XGBoost, Linear Learner, KNN Simple, but no streaming efficiency
JSON Lines BlazingText, Seq2Seq, Object2Vec Text/NLP algorithms
Augmented Manifest (.lst) Image classification/detection/segmentation Label + S3 path per line; needed for Pipe mode on images
  • File mode — downloads S3 data to EBS before training. Simple; slow start; needs disk.
  • Pipe mode — streams from S3 directly into the container. Faster startup, lower disk, higher throughput.
  • FastFile mode — on-demand read; best when random access is needed and you don't want a full download.
  • Incremental training — many built-ins (XGBoost, Linear Learner, K-Means, image algos) accept prior model artifacts as a channel to continue training on new data.

Script Mode & Common ML Libraries

  • Supported DLC frameworks: PyTorch, TensorFlow, MXNet, Hugging Face, Scikit-learn, XGBoost, Chainer, Keras, Reinforcement Learning.
  • What you provide: the training script (entry_point), a source_dir for supporting modules, and requirements.txt for extra pip dependencies.
  • Hyperparameters are passed into the script as command-line arguments — parse them yourself; they are not injected as globals.
  • Custom metrics are surfaced to CloudWatch only if you define metric_definitions with regex patterns that scrape stdout.
  • framework_version + py_version must be a supported pair — a mismatch fails the job before training starts.
  • Hugging Face estimator wraps a PyTorch/TensorFlow DLC; it is the standard route for transformer fine-tuning outside Bedrock.
  • SageMaker Training Toolkit is the library that makes any container script-mode compatible (relevant only for BYOC).

Gotcha: Scikit-learn's container does not support distributed training — single instance only. If the stem needs scale-out, the answer is a deep-learning framework or a built-in that supports distribution.

Distributed Training — Match the Bottleneck

Technique Splits Use when
Data parallelism The batch across model replicas Model fits on one device, but the dataset is huge / job runs too long
Model parallelism The model across devices Model does not fit in one device's memory
Parameter servers Gradients across workers (built-ins: XGBoost, Linear Learner) Tabular built-ins at scale

Distributed training only wins while inter-node communication stays cheaper than the work it saves. Adding instances to a tiny model makes it slower.

Anti-Patterns & Distractor Traps

  • Assuming a hyperparameter can be computed. It can't — it is searched (AMT) or set by judgment. Any option implying a single-pass analytical optimum is wrong.
  • Confusing "shorten one run" with "shorten the search." Early stopping shortens a run; warm start and AMT reuse a search.
  • Fine-tuning a model to fix bad retrieval. If retrieved passages are irrelevant, the fix is chunking + embedding model + ranking, not the generator.
  • Overfitting vs underfitting vs catastrophic forgetting: strong train / weak held-out = overfit; weak on both = underfit; lost general capability after narrow-domain tuning = catastrophic forgetting (defense: blend broader data into the mixture).
  • Metric direction: error metrics (MSE, RMSE) are minimized; score metrics (AUC, F1, accuracy) are maximized. A tuning job pointed the wrong way optimizes toward a worse model.
  • GPU by reflex. XGBoost, Linear Learner, KNN, PCA, and K-Means are CPU workloads; GPUs belong to the deep-learning and image algorithms.
  • Forgetting the label column. Built-in tabular algorithms expect the target in the first column (XGBoost CSV) — a silent, high-frequency data-prep failure.