GAI Workshop L200 Budiling With GenAI On AWS ASEAN
GAI Workshop L200 Budiling With GenAI On AWS ASEAN
GAI Workshop L200 Budiling With GenAI On AWS ASEAN
Building with
Generative AI on AWS
Pedro Paez
Principal AI/ML Solutions Architect
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Time Duration Format Content
Agenda 1:55pm
2:25pm
30 min
45 min
Demo
Lab 1
Stable Diffusion
Text2Image, Text2Image Fine-tuning
3:15pm 15 min Break Break
3:30pm 30 min Demo Large Language Models
4pm 45 min Lab 2 LLM on Sagemaker Jumpstart
4:45pm 45 min Demo RAG on AWS
5:30pm 15 min Wrap Discuss insights and next steps
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
Generative AI is the fastest growing trend in AI
Developer adoption Consumer adoption
Stable Diffusion accumulated 40k stars ChatGPT reached the 1 million
on GitHub in its first 90 days users mark in just 5 days
40,000
Stable Diffusion ChatGPT Instagram Spotify
1M 5 days 75 days 150 days
500k
Ethereum
Bitcoin
Github
Stars Stylized path
400 800 1,200 1,600 2,000 2,400 2,800 3,200 0 25 50 75 100 125 150
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 4
What is Generative AI?
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 5
How foundation models work
Text generation
Summarization
Information extraction
Pretrain Adapt
Q&A
Chatbot
Creativity Search
New features and innovation! Improved access to
Expand customer base. organizational data
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 7
Enhance Creativity
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 8
Building on AWS
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Enhance User Experience
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 11
Use case:
-----------
Conversational AI
(Voice/Text) as the app UI
for all sorts of
transactional B2C apps
(Travel, Ecom, Food,
Grocery)
Source: Expedia
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Enhance Search
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 13
Amazon innovates search with Generative AI
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Enhance Productivity
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 15
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Code
CODE GENERATION, DOCUMENTATION, AUTOCOMPLETE, TESTING
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 17
Key use cases
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 18
Key use cases
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 19
How to build with Foundation Models?
20
Lessons from the field
§ OpenAI/ChatGPT are great consumer products and have won mindshare for PoCs
§ Customer journey : 1/Test on ChatGPT > 2/Define viable use cases > 3/Prod implementation
(Security? Latency? Costs? Data privacy?)
§ We don’t have a comparable solution for 1/ (Bedrock will be our solution). Need to lean on
demos and existing tech…
§ We can help with 2/ The main use cases are addressable with Code Whisperer (Code development),
AI Services + LLMs (RAG), OS models through HuggingFace/Jumpstart.
§ One model does NOT rule them all for prod implementation. Customers have reservations of third
party APIs, data and IP control, cost and latency. AWS has an answer for this!
§ Winning trend: Orchestration (Langchain) + Tech Stack (AI Services, Databases, APIs) + smaller OS
models (or bigger models)
21
Why AWS for Generative AI?
AWS and Amazon bring Choose a base FM and Data protection for FM Manage infrastructure to
20+ years of AI and ML customize it securely consumer, IP protection ensure optimal
experience and quickly to build for FM provider performance and cost
differentiated apps
100,000+ customers Adapt FMs using your The most cost-efficient,
running ML on AWS Choice of fully-managed organization’s data, high-performance
or self-managed extend FMs to deliver training and inference
Integrate FMs with our deployment for 1P, 3P high confidence
entire ecosystem and OS
Comprehensive AWS
security capabilities
22
The AWS AI/ML Stack
Generative SCALING GENERATIVE AI AMAZON BUILT FOUNDATIONAL MODEL
AI Amazon Bedrock Amazon Titan
Consumer
STUDIO IDE
Tuner
JUMPSTART CANVAS STUDIO LAB GROUND TRUTH Prepare data Geospatial ML Build with Train models Deploy in production
AMAZON
Use pre-built models No-code ML for Learn ML Label data notebooks
SAGEMAKER in SageMaker business analysts
Store features Tune parameters Manage and monitor
ML FRAMEWORKS Habana
PyTorch, TensorFlow Amazon EC2 CPUs GPUs AWS Inferentia AWS Trainium FPGA
& INFRASTRUCTURE Gaudi
23
The AWS AI/ML Stack
Generative SCALING GENERATIVE AI AMAZON BUILT FOUNDATIONAL MODEL
AI Amazon Bedrock NE W Amazon Titan NE W
Consumer
STUDIO IDE
Tuner
JUMPSTART NE W CANVAS STUDIO LAB GROUND TRUTH Prepare data Geospatial ML Build with Train models Deploy in production
AMAZON
Use pre-built models No-code ML for Learn ML Label data notebooks
SAGEMAKER in SageMaker business analysts
Store features Tune parameters Manage and monitor
ML FRAMEWORKS Habana
PyTorch, TensorFlow Amazon EC2 CPUs GPUs NE W AWS Inferentia NE W AWS Trainium FPGA
& INFRASTRUCTURE Gaudi
24
Summary of AWS generative AI services and
infrastructure
Generate code Scan code for hard-to- Flag code that resembles
suggestions in real-time find vulnerabilities open-source training
data or filter by default
During preview Amazon ran a productivity challenge, and participants who used
Amazon CodeWhisperer were 27% more likely to complete tasks successfully and did
so an average of 57% faster than those who did not use CodeWhisperer.
26
Amazon Bedrock
Accelerate Choose FMs from Privately customize Enhance your data Use AWS tools and
development of AI21 Labs, Anthropic, FMs using your protection using capabilities that you
generative AI Stability AI, and organization’s data comprehensive AWS are familiar with to
applications using Amazon to find the security capabilities deploy scalable,
FMs through an API, right FM for your use reliable, and secure
without managing case generative AI
infrastructure applications
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 27
Bedrock supports a wide range of foundation models
FMs from Amazon FMs from AI21 Labs, Anthropic, and Stability AI
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 28
Foundation models available on SageMaker JumpStart
for self-managed access
Publicly available Proprietary models
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 29
29
3 ways to use foundation models with SageMaker
JumpStart
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon Bedrock vs Amazon SageMaker Jumpstart (as
of today)
Amazon Bedrock Amazon SageMaker Jumpstart:
• The easiest path to use GenAI models, • “GenAI Hub” for many external
LLMs, including fine-tuning or directly proprietary and opensource (i.e.
using APIs for production. HuggingFace) LLM builders.
• In preview
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 31
Purpose-built accelerators for generative AI
Lowest cost per inference The most cost-efficient, high- High performance at the
in the cloud for running performance training of lowest cost per inference for
deep learning (DL) models LLMs and diffusion models LLMs and diffusion models
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 32
Generative AI - Key Considerations
Hallucination
RISKS Opaque
Compliance & Legal
Potential for Misuse
Static Knowledge
Compute
Emergence
Domain Adaptation
Accessibility
Innovative Ecosystem
BENEFITS
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 33
RAG : control for hallucination and static knowledge
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Content moderation: control for toxicity
Rekognition
Content Moderation
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Data privacy/security
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 36
AWS GENERATIVE AI WORKSHOP
git clone
https://github.com/ljunkai/sagemaker-jumpstart-generative-
ai-examples
© 2022, Amazon
© 2023, Web
Amazon Web Services,
Services, Inc. or its Affiliates.
Inc. or its affiliates.
Stable Diffusion
Arun Surendran
Solutions Architect
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.
Rise of large-scale models and recent improvements
“a picture of a very clean living room”
2017 2022
StackGAN, Stable Diffusion,
Zhang et al. Rombach et al.
© 2022, Amazon Web Services, Inc. or its Affiliates.
Stable Diffusion
T H E F I R S T F O U N D AT I O N M O D E L T O G O G L O B A L
52
Distilled Stable Diffusion
FA S T E R , C H E A P E R , B E T T E R
pencil sketch
“data scientist” Van Gogh style Mona Lisa
“Kristine”
Sample original portrait images
(15 -18 images total) Wonder Woman Pixar character pencil sketch
“nature explorer”
© 2022,
2023, Amazon Web Services, Inc. or its affiliates. 55
Generative AI is transforming businesses
TEXT GENERATION, TEXT SUMMARIZATION, EXTRACTION, CLASSIFICATION
co:here’s real estate listing generator AI21 Labs’ wordtune read AI21 Labs’ wordtune
56
Foundation models available on SageMaker JumpStart
for self-managed access (not exhaustive)
Publicly available Proprietary models
57
Prompt Engineering for
LLMS
Bryan Tan
Solutions Architect
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates. 58
What is Prompting?
§ Language models like GPT require tweaking the input, or
"prompt," to achieve the desired output called the
“completion”.
§ Slight changes to the prompt can significantly impact the
output.
§ It takes trial and error, as well as artistic flair, to arrive at the
correct output.
§ Language models do not always behave predictably.
§ Prompts must be tailored to the task at hand.
§ The effectiveness of a prompt is determined by how the
model was trained.
§ Newer models can better understand less structured prompts
and those in natural language or dialogue formats.
§ The prompt is the interface to the model, and knowing how
to craft it effectively is crucial.
© 2023, Amazon Web Services, Inc. or its affiliates. 59
Prompt Engineering Examples
Cohere generate - Jurassic Grande AlexaTM
FLAN Stable Diffusion Medium (AI21)
61
63
In-context Learning
65
§ FLAN-T5 series models in our model hub are trained for CoT
reasoning. [Demo]
Fahim Surani
Solutions Architect
© 2023, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates. 67
Language Model (LM): Predicting Next Token
Of Robot may a robot may not injure a
human being
A Country would
Apple A A
The Of Of
© 2022,
2023, Amazon Web Services, Inc. or its affiliates. 71
Domain Adaptation
On Roadmap
Document 2 Context
[ …… ]
Embedding Embedding
LLM LLM
Document 3 [ …… ] [ …… ] Question
Document 4 [ …… ]
Most Similar Match Q&A
LLM
…
Document n [ …… ] Answer
Vector Database
🤖
1. Poor Memory
2. One Task at a Time 77
Limitations of LLMs
78
Vector Databases
79
Vector Databases
80
Langchain
❓ 💬 🤖
Question answering
Chatbots Agents
over specific Documents
81
Langchain
🤖 Agents
82
Langchain
🤖 Agents
83
RAG Demo
© 2022,
2023, Amazon Web Services, Inc. or its affiliates.
affiliates. 84
Next Steps
© 2023,
2022, Amazon Web Services, Inc. or its affiliates.
affiliates. 85
Continue Learning
© 2022, Amazon Web Services, Inc. or its affiliates. © 2023, Amazon Web Services, Inc. or its affiliates.