Building Language Models on AWS

Generative AI

Advanced

English

About this course

Amazon SageMaker helps data scientists prepare, build, train, deploy, and monitor machine learning (ML) models. SageMaker brings together a broad set of capabilities, including access to distributed training libraries, open source and foundation models (FMs).

This course introduces experienced data scientists and ML Engineers to the challenges of building small to large language models (LLM). You will learn about the different storage and ingestion options available to process large amount of text. The course also discusses the use of distributed training libraries and Amazon SageMaker Hyperpod to reduce training time by splitting workloads across more than a thousand AI accelerators. You will learn about the different approaches to train LLMs to align with human feedback and how to perform that alignment using SageMaker. The course also discusses the challenges of deploying LLMs and the optimizations available to improve inference performance.

  • Course level: Advanced
  • Duration: 6 hours

Activities

This course includes text instruction, illustrative graphics, knowledge check questions, and video demonstrations of labs you can run in your own Amazon Web Services (AWS) account.

Note: The files used in the video demonstrations in this course are available in the Building Language Models on AWS git repository.

Course objectives

After completing this course, data scientists can confidently build, train, and tune performant language models on AWS using SageMaker.

In this course, you will learn to do the following:

  • Apply best practices for storing and ingesting a large amount of text data to support distributed training
  • Explore data parallelism and model parallelism libraries to support distributed training on SageMaker
  • Explain the options available on SageMaker to improve training performance such as Amazon SageMaker Hyperpod and Elastic Fabric Adapter (EFA)
  • Explore large language model (LLM) optimization techniques for effective model deployment
  • Demonstrate how to align LLMs with human feedback

Intended audience

  • Data scientists
  • ML engineers

Prerequisites

  • More than 1 year of experience with natural language processing (NLP)
  • More than 1 year of experience with training and tuning language models
  • Intermediate-level proficiency in Python language programming
  • AWS Technical Essentials

Course outline

Module 1: Course Series Introduction

Large Language Model Basics

  • Types of Large Language Models
  • Common Generative AI Use Cases

Course Series Outline

  • Topics Covered in Future Modules

Module 2: Addressing the Challenges of Building Language Models

Common Challenges

  • Common LLM Practitioner Challenges

Multi-Machine Training Solutions

  • Scaling LLMs with Distributed Training
  • Applying Data Parallelism Techniques
  • Applying Model Parallelism Techniques

Performance Optimization Solutions

  • Performance Optimization Techniques
  • Using Purpose-Built Infrastructure

Wrap Up

  • Module Assessment

Module 3: Using Amazon SageMaker for Training Language Models

Configuring SageMaker Studio

  • SageMaker Basics
  • Setting up a SageMaker Studio Domain

SageMaker Infrastructure

  • Choosing Compute Instance Types

Working with the SageMaker Python SDK

  • SageMaker Python SDK Basics
  • Training and Deploying Language Models with the SageMaker Python SDK

Wrap Up

  • Module Assessment

Demonstration 1: Setting up Amazon SageMaker Studio

Module 4: Ingesting Language Model Data

Preparing Data

  • Data Management Overview
  • Preparing Data for LLM Training
  • Sourcing, Selecting, and Curating Data for LLM Fine-tuning

Analyzing Data Ingestion Options

  • Accessing Training Data with Amazon SageMaker
  • Ingesting Data from Amazon S3
  • Ingesting Data with FSx for Lustre
  • Additional Data Ingestion Options
  • Data Ingestion and Storage Considerations

Wrap Up

  • Module Assessment

Module 5: Training Large Language Models

Creating a SageMaker Training Job

  • Launching SageMaker Training Jobs
  • Modifying Scripts for Script Mode
  • Launching a SageMaker Training Job using the @remote decorator

Optimizing Your SageMaker Training Job

  • Monitoring and Troubleshooting
  • Optimizing Computational Performance
  • SageMaker Training Features for Language Model Training

Using Distributed Training on SageMaker

  • SageMaker Distributed Training Support
  • Using the SageMaker Distributed Data Parallel Library
  • Using the SageMaker Model Parallel Library
  • Training with the EFA
  • Train and Fine-tune Your Own LLM Using AWS silicon

Wrap Up

  • Module Assessment

Demonstration 2: Training Your First Language Model with Amazon SageMaker

Demonstration 3: Launching a SageMaker Training Job using the @remote decorator

Demonstration 4: Distributed Training with SageMaker Model Parallel

Demonstration 5: Fine-Tune and Deploy Your Own LLM Using AWS Custom Silicon

Module 6: Aligning Language Models to Human Feedback

Aligning Language Models

  • Overview
  • Common Human Alignment Approaches
  • Aligning LLMs to Human Feedback with Amazon SageMaker
  • Preference Alignment with RLHF and Multi-Adapter PPO

Wrap Up

  • Module Assessment

Demonstration 6: E2E Preference Alignment with RLHF and Multi-Adapter PPO

Module 7: Building language models with SageMaker HyperPod

Amazon SageMaker HyperPod

  • Overview
  • Amazon SageMaker HyperPod Architecture
  • Running Training Jobs on Amazon SageMaker HyperPod

Wrap Up

  • Module Assessment

Demonstration 7: Building Your Own Language Models with SageMaker HyperPod

Module 8: Deploying Language Models

Deploying a Model in SageMaker

  • Introduction to SageMaker Deployment
  • Choosing a SageMaker Deployment Option

Deploying Models for Inference

  • Deploying Your Model for Real-Time Inference
  • Using the SageMaker Python SDK for Model Deployment
  • Using the SageMaker Inference Recommender

Deploying Large Language Models for Inference

  • Optimization Techniques
  • Model Compression Techniques
  • Partitioning Models with Tensor Parallelism
  • Batching
  • Deploying LLMs with SageMaker LMI Containers

Additional Considerations

  • Other Considerations When Deploying Models on SageMaker

Wrap Up

  • Module Assessment

Demonstration 8: Deploy Mixtral-8x7B on Amazon SageMaker Using the LMI Container

Module 9: Call to Action and Additional Resources

Review

  • Generative AI
  • Large Language Models
  • Machine Learning
image