復習シート
ML Model and Foundation Model (FM) Development
この分野の要点を数画面にまとめました。試験の前に読み返すためのものです。
この復習シートは今のところ英語で表示しています。
2.1Approach and algorithm
- Effort ladder: AI service, then built-in algorithm or AutoML, then custom code. Climb only as high as needed.
- FM side: Bedrock model and prompts, then RAG for your facts, then fine-tune only when that is not enough.
- Strict explanation or regulation → traditional ML: linear model or single decision tree.
- Top accuracy on a table → gradient boosting such as XGBoost. A boosted tree often beats a network on a small table.
- Images → CNN. Language and long sequences → transformer. An RNN reads step by step and is slow on long text.
- Small data set: a simple model or transfer learning, not a deep network from scratch.
2.1Approach and algorithm
- Activations: ReLU in hidden layers, sigmoid for a yes or no output, softmax for one of many classes.
- JumpStart: pre-trained models and templates. Canvas: no code, for analysts. Autopilot: AutoML with a leaderboard.
Tabular data, every decision must be explained
- Linear model or single decision tree
Tabular data, top accuracy
- Gradient boosting: XGBoost, LightGBM, CatBoost
Group similar rows
- K-Means (you choose k with the elbow)
Unusual points, no labels
- Random Cut Forest (score per point)
Demand for thousands of related series
- DeepAR
Click prediction on sparse data
- Factorization Machines (recordIO-protobuf)
Images
- CNN, or Image Classification and Object Detection
| Problem | Pick |
|---|---|
| Tabular data, every decision must be explained | Linear model or single decision tree |
| Tabular data, top accuracy | Gradient boosting: XGBoost, LightGBM, CatBoost |
| Group similar rows | K-Means (you choose k with the elbow) |
| Unusual points, no labels | Random Cut Forest (score per point) |
| Demand for thousands of related series | DeepAR |
| Click prediction on sparse data | Factorization Machines (recordIO-protobuf) |
| Images | CNN, or Image Classification and Object Detection |
1 / 2
Tabular data, every decision must be explained
- Linear model or single decision tree
Tabular data, top accuracy
- Gradient boosting: XGBoost, LightGBM, CatBoost
Group similar rows
- K-Means (you choose k with the elbow)
Unusual points, no labels
- Random Cut Forest (score per point)
| Problem | Pick |
|---|---|
| Tabular data, every decision must be explained | Linear model or single decision tree |
| Tabular data, top accuracy | Gradient boosting: XGBoost, LightGBM, CatBoost |
| Group similar rows | K-Means (you choose k with the elbow) |
| Unusual points, no labels | Random Cut Forest (score per point) |
2 / 2
Demand for thousands of related series
- DeepAR
Click prediction on sparse data
- Factorization Machines (recordIO-protobuf)
Images
- CNN, or Image Classification and Object Detection
| Problem | Pick |
|---|---|
| Demand for thousands of related series | DeepAR |
| Click prediction on sparse data | Factorization Machines (recordIO-protobuf) |
| Images | CNN, or Image Classification and Object Detection |
2.1AI services
- Textract: DetectDocumentText for lines. AnalyzeDocument for forms, tables, queries. AnalyzeExpense for receipts.
- Textract AnalyzeID reads passports and licenses. Multi-page files use async jobs: S3, SNS, then a Get call.
- Rekognition: images are synchronous, stored video is async with SNS. Face search needs a collection first.
- Rekognition Custom Labels finds your own objects. You pay while the model runs, so stop it when idle.
- Comprehend: sentiment, entities, key phrases, PII. Custom classification and entity recognition for your labels.
- A Comprehend custom endpoint is billed while it exists. Large sets that can wait use an async job from S3.
2.1AI services
- Transcribe: custom vocabulary fixes words, diarization labels speakers, Call Analytics adds sentiment and metrics.
- Translate: custom terminology. Polly: SSML and lexicons. Lex: intents, slots, Lambda fulfillment.
- Personalize: recommendations. Comprehend Medical: conditions and PHI. HealthLake: FHIR data store.
2.1Foundation models and RAG
- Model card fields: modality, context window, price per token, languages, Regions, customization.
- Not sure which FM → a Bedrock evaluation job on your own prompts. Choose the smallest model that passes.
- Model not in your Region → cross-Region inference profile.
- Families: Claude for reasoning and long documents. Nova for low price and speed. Llama has open weights.
- Cohere and Titan offer embedding models. Cohere also offers a reranker.
- Naive RAG: embed, retrieve the top chunks, generate. Advanced RAG adds rewriting, hybrid search and reranking.
- GraphRAG links facts across documents. Agentic RAG lets an agent plan searches. Multimodal RAG indexes images and audio.
2.1Foundation models and RAG
- Managed Knowledge Bases first. A custom RAG pipeline only for a control the managed service lacks.
Better instructions or examples
- Use
- Prompt engineering
- Data it needs
- None
Fresh or private facts
- Use
- RAG
- Data it needs
- Your documents
Task, tone or format
- Use
- Fine-tuning
- Data it needs
- Labeled prompt and response pairs
Deep vocabulary of one field
- Use
- Continued pre-training
- Data it needs
- Large unlabeled text
Lower cost and latency on one task
- Use
- Distillation
- Data it needs
- Prompts, teacher answers
Large model, little GPU memory
- Use
- PEFT: LoRA or QLoRA
- Data it needs
- Labeled examples
| Need | Use | Data it needs |
|---|---|---|
| Better instructions or examples | Prompt engineering | None |
| Fresh or private facts | RAG | Your documents |
| Task, tone or format | Fine-tuning | Labeled prompt and response pairs |
| Deep vocabulary of one field | Continued pre-training | Large unlabeled text |
| Lower cost and latency on one task | Distillation | Prompts, teacher answers |
| Large model, little GPU memory | PEFT: LoRA or QLoRA | Labeled examples |
1 / 2
Better instructions or examples
- Use
- Prompt engineering
- Data it needs
- None
Fresh or private facts
- Use
- RAG
- Data it needs
- Your documents
Task, tone or format
- Use
- Fine-tuning
- Data it needs
- Labeled prompt and response pairs
| Need | Use | Data it needs |
|---|---|---|
| Better instructions or examples | Prompt engineering | None |
| Fresh or private facts | RAG | Your documents |
| Task, tone or format | Fine-tuning | Labeled prompt and response pairs |
2 / 2
Deep vocabulary of one field
- Use
- Continued pre-training
- Data it needs
- Large unlabeled text
Lower cost and latency on one task
- Use
- Distillation
- Data it needs
- Prompts, teacher answers
Large model, little GPU memory
- Use
- PEFT: LoRA or QLoRA
- Data it needs
- Labeled examples
| Need | Use | Data it needs |
|---|---|---|
| Deep vocabulary of one field | Continued pre-training | Large unlabeled text |
| Lower cost and latency on one task | Distillation | Prompts, teacher answers |
| Large model, little GPU memory | PEFT: LoRA or QLoRA | Labeled examples |
2.1Cost, time and latency
- Per-second billing: twice the hardware for half the time costs about the same, until scaling efficiency drops.
- Managed Spot saves cost, not time. Jobs can be interrupted, so checkpoint to S3.
- Early stopping, a data sample and transfer learning cut time and cost. Set the quality bar first.
- Smaller model first. Route hard requests to a larger one.
- Streaming shows text sooner. The total time and cost stay the same.
- Prompt caching: a repeated prompt start costs less and answers sooner. It needs a minimum prefix, not for batch.
- Intelligent prompt routing: two models of one family on one endpoint. Tuned for English prompts.
2.1Cost, time and latency
- Batch inference: cheaper work that can wait. Provisioned throughput: steady, high traffic. On demand: uneven traffic.
2.2Built-in algorithms
- Linear Learner: simple, scalable, explainable. XGBoost: strong default. LightGBM: speed. CatBoost: categorical columns.
- Factorization Machines needs recordIO-protobuf, not CSV. IP Insights takes CSV only.
- k-NN: closest labeled examples. AutoGluon-Tabular stacks many models. TabTransformer: a transformer on tables.
- K-Means: choose k with the elbow. PCA: fewer columns that keep the variance.
- Random Cut Forest: a high score is unusual. About three standard deviations is a common cutoff.
- BlazingText: Word2vec or supervised with __label__ prefixes. Seq2Seq: translation and summarization.
2.2Built-in algorithms
- LDA and NTM find topics, and you set how many. Object2Vec: embeddings for pairs.
- DeepAR: ranges for many related series, and it helps new series with little history.
- Image Classification: a label. Object Detection: boxes. Semantic Segmentation: a class per pixel. Train on GPU.
2.2Training jobs and tuning
- Three ways to bring the algorithm: built-in, script mode in a framework container, or your own container.
- Script mode: read data from SM_CHANNEL_<NAME>. Write the model to SM_MODEL_DIR. It is packed as model.tar.gz to S3.
- Hyperparameters arrive as arguments and as SM_HP_ variables. You pay only while the job runs.
- Automatic model tuning: a range per hyperparameter, an objective metric and limits.
- Use logarithmic scaling for ranges across powers of ten, such as a learning rate.
- Your own script needs a metric definition: a name and a regular expression on the logs.
2.2Training jobs and tuning
- Warm start reuses earlier tuning results. You pay for every job, so max jobs times one job caps the cost.
- Epoch: one pass. Step: one batch. A bigger batch needs more memory and a higher learning rate.
Bayesian (default)
- Pick it when
- Few jobs, learn from earlier results
- Remember
- Many parallel jobs give it less to learn from
Random
- Pick it when
- Many independent jobs at once
- Remember
- Samples each job on its own
Grid
- Pick it when
- Exact combinations to try
- Remember
- Categorical values only
Hyperband
- Pick it when
- Neural network that reports its metric each step
- Remember
- Stops weak jobs early. Leave early stopping off
| Strategy | Pick it when | Remember |
|---|---|---|
| Bayesian (default) | Few jobs, learn from earlier results | Many parallel jobs give it less to learn from |
| Random | Many independent jobs at once | Samples each job on its own |
| Grid | Exact combinations to try | Categorical values only |
| Hyperband | Neural network that reports its metric each step | Stops weak jobs early. Leave early stopping off |
1 / 2
Bayesian (default)
- Pick it when
- Few jobs, learn from earlier results
- Remember
- Many parallel jobs give it less to learn from
Random
- Pick it when
- Many independent jobs at once
- Remember
- Samples each job on its own
Grid
- Pick it when
- Exact combinations to try
- Remember
- Categorical values only
| Strategy | Pick it when | Remember |
|---|---|---|
| Bayesian (default) | Few jobs, learn from earlier results | Many parallel jobs give it less to learn from |
| Random | Many independent jobs at once | Samples each job on its own |
| Grid | Exact combinations to try | Categorical values only |
2 / 2
Hyperband
- Pick it when
- Neural network that reports its metric each step
- Remember
- Stops weak jobs early. Leave early stopping off
| Strategy | Pick it when | Remember |
|---|---|---|
| Hyperband | Neural network that reports its metric each step | Stops weak jobs early. Leave early stopping off |
2.2Speed, scale and fit
- Idle GPUs mean slow data loading. Fix the input, not the instance size.
- Mixed precision: 16-bit numbers, faster steps, less memory. Early stopping ends a run that stopped improving.
- Data parallel splits the batch. Model parallel splits layers (pipeline) or the math inside layers (tensor).
- Try data parallel first. EFA gives low-latency links between nodes.
- HyperPod: health checks, node replacement, resume from the latest checkpoint. Slurm or EKS.
- Overfitting: training loss low, validation high. Underfitting: both high, so a bigger model or more features.
- L1 can zero out weights. L2 shrinks them. Dropout switches neurons off during training.
2.2Speed, scale and fit
- Ensembles: bagging cuts variance, boosting cuts bias, stacking uses a meta-model.
- Inference pipeline: 2 to 15 containers on one endpoint. Cascade: a cheap model first, a large one when unsure.
Training starts late, 2 TB copied first
- FastFile or Pipe mode
Many short jobs waste start-up time
- Managed warm pools
Model too big for one GPU
- Model parallelism or sharded data parallelism
Large data, model fits one GPU
- Data parallelism
Weeks-long FM training must survive failures
- SageMaker HyperPod
Training 99 percent, validation 70 percent
- More data, L1 or L2, dropout, early stopping
Fine-tuned model lost general skills
- Data replay, LoRA, lower learning rate
| Symptom | Fix |
|---|---|
| Training starts late, 2 TB copied first | FastFile or Pipe mode |
| Many short jobs waste start-up time | Managed warm pools |
| Model too big for one GPU | Model parallelism or sharded data parallelism |
| Large data, model fits one GPU | Data parallelism |
| Weeks-long FM training must survive failures | SageMaker HyperPod |
| Training 99 percent, validation 70 percent | More data, L1 or L2, dropout, early stopping |
| Fine-tuned model lost general skills | Data replay, LoRA, lower learning rate |
1 / 2
Training starts late, 2 TB copied first
- FastFile or Pipe mode
Many short jobs waste start-up time
- Managed warm pools
Model too big for one GPU
- Model parallelism or sharded data parallelism
Large data, model fits one GPU
- Data parallelism
| Symptom | Fix |
|---|---|
| Training starts late, 2 TB copied first | FastFile or Pipe mode |
| Many short jobs waste start-up time | Managed warm pools |
| Model too big for one GPU | Model parallelism or sharded data parallelism |
| Large data, model fits one GPU | Data parallelism |
2 / 2
Weeks-long FM training must survive failures
- SageMaker HyperPod
Training 99 percent, validation 70 percent
- More data, L1 or L2, dropout, early stopping
Fine-tuned model lost general skills
- Data replay, LoRA, lower learning rate
| Symptom | Fix |
|---|---|
| Weeks-long FM training must survive failures | SageMaker HyperPod |
| Training 99 percent, validation 70 percent | More data, L1 or L2, dropout, early stopping |
| Fine-tuned model lost general skills | Data replay, LoRA, lower learning rate |
2.2Customizing foundation models
- Bedrock fine-tuning: prompt and completion pairs as JSONL in S3. Continued pre-training: unlabeled text.
- Bedrock also offers distillation and reinforcement fine-tuning with a reward function in Lambda.
- You set epochs, batch size and learning rate. Only some models can be customized, by Region.
- Run the job in your VPC and encrypt the custom model with your KMS key.
- Bedrock bills tokens times epochs plus monthly storage. Serve with Provisioned Throughput or an on-demand deployment.
- FM fine-tuning: a low learning rate and few epochs, or a small data set overfits.
- PEFT freezes the base model and trains a small adapter. QLoRA adds a 4-bit base so a large model fits one GPU.
2.2Customizing foundation models
- Weights memory is about parameters times bytes: 7 billion at 16-bit is about 14 GB.
- Distillation: teacher and student, prompts in S3. Invocation logs can supply prompts and teacher answers.
2.2Prompts and retrieval tuning
- Few-shot examples fix format. Chain of thought helps multi-step reasoning. Prompt chaining splits a big task.
- System prompt holds the role and rules. Ask for JSON in a stated schema, then validate it.
- Low temperature for extraction and facts. Change temperature or top-p, not both.
- Keep prompts in Bedrock Prompt Management and test versions on a fixed example set.
- Chunking: small is precise, large keeps context. Knowledge Bases default is about 300 tokens, top-k of 5.
- Hierarchical chunking searches small child chunks and returns the larger parent. Semantic chunking costs more.
2.2Prompts and retrieval tuning
- Exact terms missed → hybrid search. One product or year only → metadata filter.
- Use the same embedding model for ingestion and queries. Titan Text Embeddings V2: 256, 512 or 1,024 dimensions.
- Measure retrieval recall on a test set. Change one setting at a time.
2.3Tracking, drift and live tests
- Managed MLflow: log parameters, metrics and artifacts per run. Artifacts go to S3 in your account.
- Tracking server sizes: Small 25 users (default), Medium 50, Large 100. Connect with the ARN and IAM.
- To repeat a run, log seed, data version, code commit, container image and settings.
- Baseline job on training data writes statistics and suggested constraints. Data capture saves live traffic to S3.
- Model quality needs ground truth, merged by inference ID, so it arrives later than data drift.
- Model Monitor output: a violations file and CloudWatch metrics for alarms. Closed to new customers since July 30, 2026.
2.3Tracking, drift and live tests
- Weights split traffic. Change them live with UpdateEndpointWeightsAndCapacities, no redeploy.
- Shadow test: sampling percentage, 7 day default, 30 day maximum, one shadow variant per endpoint.
- Shadow does not work with serverless, asynchronous, multi-model or multiple-container endpoints.
Live inputs differ from training data
- Data quality monitor
Accuracy fell, inputs look normal
- Model quality monitor (needs ground truth)
Ranking of important features changed
- Feature attribution drift
New model on live traffic, no user effect
- Shadow variant
Send 10 percent of users to a new model
- Production variant weights (A/B test)
Send one request to a chosen model
- TargetVariant
Why was this applicant refused
- Local explanation: SHAP
How the price changes as size grows
- Partial dependence plot
| Clue | Use |
|---|---|
| Live inputs differ from training data | Data quality monitor |
| Accuracy fell, inputs look normal | Model quality monitor (needs ground truth) |
| Ranking of important features changed | Feature attribution drift |
| New model on live traffic, no user effect | Shadow variant |
| Send 10 percent of users to a new model | Production variant weights (A/B test) |
| Send one request to a chosen model | TargetVariant |
| Why was this applicant refused | Local explanation: SHAP |
| How the price changes as size grows | Partial dependence plot |
1 / 2
Live inputs differ from training data
- Data quality monitor
Accuracy fell, inputs look normal
- Model quality monitor (needs ground truth)
Ranking of important features changed
- Feature attribution drift
New model on live traffic, no user effect
- Shadow variant
| Clue | Use |
|---|---|
| Live inputs differ from training data | Data quality monitor |
| Accuracy fell, inputs look normal | Model quality monitor (needs ground truth) |
| Ranking of important features changed | Feature attribution drift |
| New model on live traffic, no user effect | Shadow variant |
2 / 2
Send 10 percent of users to a new model
- Production variant weights (A/B test)
Send one request to a chosen model
- TargetVariant
Why was this applicant refused
- Local explanation: SHAP
How the price changes as size grows
- Partial dependence plot
| Clue | Use |
|---|---|
| Send 10 percent of users to a new model | Production variant weights (A/B test) |
| Send one request to a chosen model | TargetVariant |
| Why was this applicant refused | Local explanation: SHAP |
| How the price changes as size grows | Partial dependence plot |
2.3Metrics, explanation and debugging
- Precision = TP / (TP + FP). Recall = TP / (TP + FN). F1 is the harmonic mean.
- Raise the threshold: precision up, recall down. Choose it from the cost of each error, not 0.5.
- RMSE punishes big misses. MAE resists outliers. MAPE fails near zero. R squared can be negative.
- Cross-validation for small data. Stratify imbalanced classes. Time series: split in time order, never shuffle.
- BLEU: n-gram precision, translation. ROUGE: recall, summaries. Perplexity needs no reference.
- SHAP scores are signed and add up to the prediction minus the baseline prediction.
2.3Metrics, explanation and debugging
- Clarify and Debugger: closed to new customers since July 30, 2026. Profiler: AWS ends support on June 30, 2027. The exam can still name them.
- Loss flat: rate too low or bad data. Up or NaN: rate too high or exploding gradients.
- Vanishing gradients: ReLU-type activations, residual connections, batch normalization.
- Debugger rule loss_not_decreasing stops a stuck job. TensorBoard shows gradient and weight histograms.
Missing a positive is costly
- Recall, lower the threshold
False alarms are costly
- Precision, raise the threshold
Only 1 percent positives
- PR AUC and F1, not ROC AUC
Large misses hurt most
- RMSE
Outliers in the target
- MAE
Machine translation
- BLEU
Summary, word order counts
- ROUGE-L
A paraphrase should still score well
- BERTScore or semantic similarity
| The question | Metric |
|---|---|
| Missing a positive is costly | Recall, lower the threshold |
| False alarms are costly | Precision, raise the threshold |
| Only 1 percent positives | PR AUC and F1, not ROC AUC |
| Large misses hurt most | RMSE |
| Outliers in the target | MAE |
| Machine translation | BLEU |
| Summary, word order counts | ROUGE-L |
| A paraphrase should still score well | BERTScore or semantic similarity |
1 / 2
Missing a positive is costly
- Recall, lower the threshold
False alarms are costly
- Precision, raise the threshold
Only 1 percent positives
- PR AUC and F1, not ROC AUC
Large misses hurt most
- RMSE
| The question | Metric |
|---|---|
| Missing a positive is costly | Recall, lower the threshold |
| False alarms are costly | Precision, raise the threshold |
| Only 1 percent positives | PR AUC and F1, not ROC AUC |
| Large misses hurt most | RMSE |
2 / 2
Outliers in the target
- MAE
Machine translation
- BLEU
Summary, word order counts
- ROUGE-L
A paraphrase should still score well
- BERTScore or semantic similarity
| The question | Metric |
|---|---|
| Outliers in the target | MAE |
| Machine translation | BLEU |
| Summary, word order counts | ROUGE-L |
| A paraphrase should still score well | BERTScore or semantic similarity |
2.3Evaluating generative AI and RAG
- Bedrock evaluation job types: automatic, judge, human and RAG.
- Automatic: one task type, scores accuracy, robustness and toxicity. Judge: an evaluator model scores the answers.
- Dataset: JSONL in S3, up to 1,000 prompts. Keys: prompt, referenceResponse, category. Built-in sets hold 100.
- Model outside Bedrock → bring your own inference responses.
- Human job: up to 2 models, 1 to 3 workers per prompt, own team or AWS-managed. The output bucket needs CORS.
- A2I triggers: a confidence threshold or a random sample percentage. Closed to new customers since July 30, 2026.
- Judge: faithfulness is the hallucination check. Up to 10 custom metrics, each with a rating scale.
2.3Evaluating generative AI and RAG
- Calibrate the judge against human ratings on a sample. Pick a judge at least as strong, from another family.
- Golden set: fixed questions and reference answers. Rerun it after every change.
Retrieval: did the right chunks come back
- Context relevance, context coverage, precision at k, recall at k, MRR
Generation: is the answer good
- Faithfulness, correctness, completeness, helpfulness, citations
Text against a reference
- BLEU, ROUGE, BERTScore. Perplexity needs none
| Stage | Metrics |
|---|---|
| Retrieval: did the right chunks come back | Context relevance, context coverage, precision at k, recall at k, MRR |
| Generation: is the answer good | Faithfulness, correctness, completeness, helpfulness, citations |
| Text against a reference | BLEU, ROUGE, BERTScore. Perplexity needs none |
試験のひっかけ
- “Product facts change every week” → RAG, not fine-tuning
- “Fixed company format, 5,000 labeled examples” → fine-tuning, not RAG
- “Large archive of unlabeled documents” → continued pre-training, not fine-tuning
- “Cut cost and latency of a large model on one task” → distillation, not prompt routing
- “Same 20-page document sent with every question” → prompt caching, not streaming
- “Reduce cost of a restartable training job” → managed Spot with checkpoints, not a bigger instance
試験のひっかけ
- “Model too large for one GPU” → model parallelism, not data parallelism
- “Adapt a large model with limited GPU memory” → LoRA or QLoRA, not full fine-tuning
- “Missing a fraud case is costly” → recall, not accuracy
- “1 percent positives, which curve” → precision-recall, not ROC
- “Test a new model with no effect on users” → shadow variant, not an A/B test
- “Answers include facts not in the retrieved text” → low faithfulness, not low context relevance