This is Chapter 1 of the AWS AI and ML series.

These are the concepts and service distinctions I kept returning to while working with AWS AI services. Writing them down in one place made the concepts stick.


Different types of ML algorithms

Three broad families, each suited to a different class of problem.

Supervised learning - trains on labelled input-output pairs. Two sub-types:

  • Classification - predicts a category (spam/not spam, image labels). Algorithms: logistic regression, decision trees, random forests, SVM, neural networks.
  • Regression - predicts a continuous value (house price, demand forecast). Algorithms: linear regression, gradient boosting, neural networks.

Unsupervised learning - finds structure in unlabelled data:

  • Clustering - groups similar items (K-means, hierarchical clustering)
  • Dimensionality reduction - compresses features while preserving signal (PCA)
  • Anomaly detection - identifies outliers (Isolation Forest, autoencoders)

Reinforcement learning - an agent learns by trial and error, optimising for a reward signal. Well suited to sequential decision problems: game playing, robotics, recommendation systems.

Deep learning - neural networks with many layers. Not a separate family, but a technique applicable across all three: deep CNNs for image classification (supervised), autoencoders for anomaly detection (unsupervised), deep RL for complex control tasks.


Algorithm selection guide

Problem typeDataAlgorithm family
Predict a categoryLabelledSupervised - classification
Predict a numberLabelledSupervised - regression
Find natural groupsUnlabelledUnsupervised - clustering
Reduce feature dimensionsUnlabelledUnsupervised - dimensionality reduction
Detect outliersUnlabelledUnsupervised - anomaly detection
Learn from sequential decisionsReward signalsReinforcement learning
Image, audio, or text at scaleLabelled or unlabelledDeep learning
Use a general-purpose pre-trained modelNone (prompting)Foundation models / generative AI

ML performance metrics

Classification metrics

MetricWhat it measuresWhen to use it
AccuracyCorrect predictions / total predictionsBalanced classes only
PrecisionTrue positives / (true positives + false positives)When false positives are costly (spam filter)
RecallTrue positives / (true positives + false negatives)When false negatives are costly (cancer detection)
F1Harmonic mean of precision and recallImbalanced classes
AUC-ROCArea under the ROC curveRanking models by discrimination ability

For imbalanced datasets (e.g. fraud detection where 99% of transactions are legitimate), accuracy is misleading - a model predicting “not fraud” every time scores 99%. F1 or AUC-ROC gives a truer picture.

Regression metrics

MetricWhat it measures
MAEAverage absolute error - interpretable in the same units as the target
MSEPenalises large errors more than MAE
RMSESquare root of MSE - back in the target’s units, sensitive to outliers
Proportion of variance explained by the model (1.0 = perfect)

Amazon AI services and their usage

ServiceWhat it does
Amazon SageMakerFull ML lifecycle - build, train, evaluate, deploy, and monitor custom models
Amazon BedrockManaged API access to foundation models from AWS and third-party providers
Amazon RekognitionImage and video analysis - object detection, facial analysis, content moderation
Amazon ComprehendNLP - entity recognition, sentiment analysis, key phrase extraction, PII detection
Amazon TextractExtracts text and structured data from documents and forms
Amazon TranscribeSpeech-to-text; Transcribe Medical for clinical audio
Amazon PollyText-to-speech with neural voices
Amazon LexConversational AI for building chatbots (same engine as Alexa)
Amazon PersonalizeReal-time personalisation and recommendations
Amazon ForecastTime series forecasting
Amazon KendraIntelligent enterprise search with ML-powered relevance
Amazon TranslateNeural machine translation
Amazon Augmented AI (A2I)Human review workflows for ML predictions

Different types of inference

Inference typeWhat it isUse it forAWS
Real-timeSynchronous, low-latency - request goes in, response comes back immediatelyUser-facing features, APIsSageMaker real-time endpoints, Bedrock on-demand
BatchProcess a large dataset offline, results written to storage, no latency requirementOvernight scoring jobs, bulk document processingSageMaker Batch Transform
AsyncClient submits a request, gets a job ID, polls or receives a callback when doneInference takes minutes (large inputs, complex models)SageMaker Async Inference
ServerlessNo always-on endpoint; infrastructure scales from zero, cold start on first request after idleIntermittent or unpredictable traffic where you don’t want to pay for idle capacitySageMaker Serverless Inference
EdgeModel runs on-device, no round trip to the cloudLatency, connectivity, or data residency rules out cloud inferenceSageMaker Edge Manager, AWS Greengrass

Bedrock vs SageMaker

BedrockSageMaker
What you bringPrompts and dataTraining data and model code
ModelPre-trained foundation model from a providerCustom model you train or bring your own
TrainingNone - model weights are fixed (unless fine-tuning via Bedrock)Full training and retraining control
DeploymentManaged by AWS, no infrastructure to configureYou configure and manage endpoints
Use caseConsume a general-purpose model with prompting, RAG, or agentsBuild, train, and host a custom model for a specific task
Skill requirementPrompt engineering, RAG patternsML engineering, MLOps

The key distinction: Bedrock is for consuming foundation models; SageMaker is for building and operating your own.


Bedrock vs SageMaker inference mapping

Inference typeBedrockSageMaker
Real-time (on-demand)On-demand throughput - pay per token, no reservationReal-time endpoints - always-on, pay per hour
Provisioned / reservedProvisioned Throughput - reserve model units for guaranteed capacityProvisioned endpoints with auto scaling
BatchBatch inference via S3Batch Transform
AsyncNot natively - wrap with Lambda or Step FunctionsAsync Inference endpoints
ServerlessOn-demand behaves serverless for most Bedrock use casesServerless Inference endpoints
EdgeNot applicableSageMaker Edge Manager / Greengrass

Foundation model customisation approaches

In order of increasing cost, complexity, and control:

ApproachWhat it doesCost/complexityAWS
Prompt engineeringNo model changes, just better instructions. Worth exhausting before reaching for anything elseZero, beyond inference-
RAG (Retrieval-Augmented Generation)Inject relevant context at inference time from an external knowledge base. Keeps knowledge fresh without retraining; best for factual, updatable knowledgeLowBedrock Knowledge Bases
Continued pre-trainingTrain a base model further on domain-specific unlabelled text. Adapts the model’s language to a specialised domain (medical, legal, financial) without supervised examplesHigh - significant data and compute-
Fine-tuningTrain the model on labelled input-output examples to adjust its behaviour or output style. Better than RAG for consistent tone, format, or domain-specific task performanceMedium-highBedrock fine-tuning, SageMaker
RLHF (Reinforcement Learning from Human Feedback)Refine model behaviour using human preference signals - the technique used to align foundation modelsProvider-side - not typically something you run yourself-
Pre-train from scratchBuild a foundation model on your own data from the ground upHighest - only viable with the data and compute budget of a foundation model provider-

Responsible AI tools

ToolWhat it does
Amazon SageMaker ClarifyDetects bias in training data and model predictions; explains model decisions via feature importance
Amazon Bedrock GuardrailsFilters content, denies specified topics, redacts PII from model inputs and outputs
Amazon Augmented AI (A2I)Routes low-confidence predictions to human reviewers for validation
SageMaker Model MonitorDetects data drift and model quality degradation in production endpoints
SageMaker Model CardsDocuments model purpose, training data, evaluation results, and intended use

Prompt engineering techniques

TechniqueHow it works
Zero-shotInstruction only, no examples. Works for well-understood tasks the model has seen in training.
Few-shotInclude two to five examples of the desired input-output format before the actual query. Useful for consistent formatting or domain-specific phrasing.
Chain-of-thoughtAsk the model to reason step by step before giving a final answer. Improves accuracy on multi-step reasoning and maths problems.
ReActInterleave reasoning and tool use: the model reasons, takes an action (e.g. search), observes the result, then reasons again. Basis for agentic workflows.
System promptSet the model’s persona, role, and constraints at the top of the conversation. Applied before the user message and influences all subsequent responses.

Notes

  1. This chapter doubles as the concept reference behind my AIF-C01 study notes - the same algorithm types, metrics, and service distinctions come up across that exam.
  2. AWS AI services move fast, particularly Bedrock model availability and features - treat the service-specific sections as a snapshot, not a permanent reference.