© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
DalYoung Jung
AWS MySQL Specialist SA
Amazon Aurora with Gen AI
Amazon Aurora에서 생성형 AI 활용하기
YunCheol Ha
AWS Senior PostgreSQL Specialist SA
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Amazon Aurora MySQL with Gen AI
2
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
• 생성형 AI을 어떤 DB업무에 활용 가능할까?
• 생성형 AI를 DB업무에 활용하기 위해선 어떤 지식들이 필요한가?
• Amazon Aurora MySQL 서비스를 Amazon Bedrock 연동하기
• 데모
3
Agenda
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
증가되는 데이터베이스 관리의 어려움
All I wanted was a
simple distributed
database!!
It's too hard to
operate!
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
생성형 AI을 어떤 DB업무에 활용 가능할까?
자연어를 통한 일반 DB업무 간소화
• 다수의 Aurora 클러스터를 관리
”동일한 구성을 가진 10개의 Aurora 클러스터 생성해줘, 클러스터 이름은 Prod#1에서 하나씩
숫자를 늘려가면서 생성해줘.”
• 업그레이드 및 패치 자동화
“Product DB #1에서 #10번까지의 클러스터를, Aurora version 3.07 로 업그레이드 해줘”
• 성능 모니터링 및 최적화
“지난 1주일간에 가장 높은 CPU와 메모리 사용량을 보이는 클러스터를 찾아줘”
“비효율적인 리소스 사용율을 보이는 DB 리스트들을 알려줘”
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
생성형 AI을 어떤 DB업무에 활용 가능할까?
중요한 데이터의 보안과 접근 통제 관리
“보안 이슈가 의심되는 데이터베이스에 대한 자세한 보고서를 제공해줘”
이기종간의 DB 마이그레이션
“제공되는 Oracle 쿼리를 PostgreSQL 쿼리로 변경해줘”
성능 튜닝
“ 쿼리플랜을 분석해서 성능에 좋지 않은 쿼리들을 찾아줘”
“ 현재 실행되는 쿼리를 분석해서 최적화된 쿼리로 다시 작성해줘”
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
정확한 결과를 얻기 위해서는
어떻게 해야할까?
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
프롬프트엔지니어링
“Prompt는 Response 을 이끌어내기 위해 Large Language model에 전달하는 정보입니다”
Prompt에 요구 사항을 구
체적으로 전달하고
Context 로 기본으로 테이
블 스키마 및 샘플등을 제
공하는것이 중요하다
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
RAG활용하여 샘플 쿼리 및 정보를 학습
검색(Retrieval)
검색된 관련 컨텍스트를
사용자 프롬프트에
추가하여 기반 모델에
대한 입력으로 사용
증강(Augmentation) 생성(Generation)
증강 프롬프트 기반 기반
모델의 응답
사용자 쿼리를 기반으로
외부 지식 베이스 또는
데이터 소스에서 관련
콘텐츠를 가져옵니다
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
어떤 서비스들을 통해서 구현
할 수 있을까?
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
다 양 한 파 운 데 이 션 모 델 을 A P I 를 통 해 서 사 용 할
수 있 도 록 해 주 는 완 전 관 리 형 서 비 스
11
Amazon Bedrock
이점
• API를 통해 FM을 사용하여 생성형 AI 애플리케이션
개발 가속화
• 인프라 관리 불필요
• AI21 Labs, Anthropic, Cohere, Stability AI 및
Amazon의 FM 선택
• 조직의 데이터를 사용하여 개인적으로 FM 사용자
지정
• 포괄적인 AWS 보안 기능
• NEW - Bedrock용 에이전트를 사용하여 몇 번의
클릭만으로 생성형 AI 앱을 활성화하여 작업을
완료할 수 있도록 지원
11
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
Summarization,
complex reasoning,
writing, coding
Contextual answers,
summarization,
paraphrasing
High-quality images
and art
Text generation,
search, classification
Q&A and reading
comprehension
Text summarization,
generation,
Q&A, search,
image generation
Amazon Titan
Text Premier
Amazon Titan
Text Lite
Amazon Titan
Text Express
Amazon Titan Text
Embeddings
Amazon Titan Text
Embeddings V2
Amazon Titan
Multimodal
Embeddings
Amazon Titan
Image Generator
Claude 3 Opus
Claude 3 Sonnet
Claude 3 Haiku
Claude 2.1
Claude 2
Claude Instant
Llama 3 8B
Llama 3 70B
Llama 2 13B
Llama 2 70B
Command
Command Light
Embed English
Embed Multilingual
Command R+
Command R
Stable Diffusion
XL1.0
Stable Diffusion
XL 0.8
Jurassic-2 Ultra
Jurassic-2 Mid
Mistral Small
Mistral Large
Mistral 7B
Mixtral 8x7B
Text summarization,
text classification,
text completion,
code generation,
Q&A
다양한 고성능 파운데이션 모델을 지원
Amazon Bedrock
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
파운데이션 모델(FM) - Claude3 의 특징
ü 뛰어난 추론 및 추론 능력
ü 뛰어난 자연어 처리
ü 강력한 프롬프트 엔지니어링 지원
ü 뛰어난 Context 이해 및 적응성
ü 강화된 보안 및 개인 정보 보호 장치
ü 비용 효율적이고 확장 가능한 아키텍처
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
파운데이션 모델(FM) - Claude3 모델 성능
Reference : https://www.anthropic.com/news/claude-3-family
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
• 여러 클러스터에서 스키마 변경 사항을 쉽게 검증하고 적용
• ERD 분석 및 DDL 스크립트 생성
• 여러 클러스터에서 성능 문제가 발생된 데이터베이스를 식별
• 버전 업그레이드 수행 및 확인
• 여러 클러스터를 동시에 분석하여 보안 이슈를 확인
• 이기종 데이터베이스 쿼리를 MySQL 쿼리로 쉽게 변환
Claude3 를 통해 DB업무에 할수 있는 일들은?
그렇지만 내가 필요한 정확한 결과를 제공받기 위해서는
여전히 많은 노력들이 필요합니다
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Amazon Bedrock 을 활용한 프롬프트 기본 아키텍처 예
References : https://catalog.workshops.aws/genai-on-aws/en-US/08-working-with-databases
Users Front-end Application
(Python Code)
Amazon Bedrock(Claude3)
Amazon Aurora
SQL Query
statement
Retrieve schema context
Query Database
Natural language
prompt
1
2
4
5
Fetch Data
6
Send prompt to LLM
3
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Demo1:
Claude3를 활용한 MySQL 쿼리 실행
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Demo2:
Claude3를 사용한 Aurora MySQL
데이터베이스 관리 예
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Lesson Learned
21
Rule을 지정
Boto API로 Bedrock을 통
해 Claude3 호출
백그라운드 데이터로
DB 스키마 정보 제공
XML Tag 포맷으로 실행할 내용을 정의
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Lesson Learned
22
• Prompt Engineering 매우 중요
스키마 뿐만 아니라 참조할 데이터도 명시하면 좋음
• XML또는 JSON형태로 구조화된 포맷으로 정보를 제공하면 좋음
• 컬럼 정보, 컬럼에 대한 설명과 샘플데이터의 일부를 포함하면 좋음
• RAG를 통해서 관련된 정보를 학습시키면 좋음
• 정확성을 위해 샘플등을 통해서 검증 프로세스를 추가하면 좋음
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Amazon Aurora MySQL 을 통해 Amazon Bedrock Invoke
• Bedrock은 Aurora MySQL 3.06 릴리스 이상에서
지원됩니다.
• Aurora MySQL에서 Bedrock 모델을 호출하기 위한
IAM Role을 생성하고 해당 Role을 Aurora 에 추가
• Aurora MySQL을 위한 Custom 파라미터그룹을 생
성하고, IAM Role의 ARN을
aws_default_bedrock_role 파라미터에 업데이트
• Bedrock에서 Anthropic Claude3 모델이 Enable되
어있는지 확인
• Bedrock 모델을 Invoke하기 위해서 Aurora MySQL
의 bedrock사용자에게 필요한 권한을 부여
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Demo 3:
Aurora MySQL에서 Amazon
Bedrock 연결 설정 및 Invoke
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Demo4 :
Amazon Bedrock으로부터 응답을 통해
Aurora MySQL 테이블 업데이트
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
27
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Amazon Aurora PostgreSQL vector store
with Gen AI
28
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
29
Agenda
• Overview of generative AI and the role of databases
• PostgreSQL as a vector store
• Integration with Amazon Bedrocks
• Demo
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Blue elephant vase that can hold up
to three plants in it, hand painted…
Parrot decorative figure stands 12
inches high, red, and orange, has…
Reddish vase six inches deep perfect
for cactuses and desert plants…
Rabbit planter suitable for growing
vegetables indoors, green and …
Decorative ceramic turtle, blue and
about eight inches wide, makes…
Bird feeder shaped like a bird, can
hold birdseed for 28 days and is…
Sea shell themed vase that's two
feet wide and can hold a variety…
Garden variety owl planter, great for
keeping your favorite flowers…
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
Pre-trained on vast amounts of
unstructured data
Contain large number of parameters that make
them capable of learning complex concepts
Can be applied in a wide range of contexts
Customize FMs using your data for domain
specific tasks
Generative AI is powered
by foundation models
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Retrieval Augmented
Generation (RAG)
Configure FM to interact with
your company data
A N S W E R
Q U E S T I O N
K N O W L E D G E
B A S E S
F O U N D A T I O N
M O D E L
How much does a blue
elephant vase cost?
Product catalog
Price data
A blue elephant vase
typically costs $19.99
Sorry, I don't know
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
What is vector ?
Vector
[3,2]
x
y R^2
magnitude
direction
Example
[3,2,1]
x
y
z
R^3
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
Unstructured data has to be vectorized into vectors to be used in generative AI applications
CHAIRS
STATUES
VASES
Product
catalog
Blue vase
Red chair
C L A U D E
S T A B L E D I F F U S I O N
J U R A S S I C - 2
A M A Z O N T I T A N
0.23, 1.58, …, 8.45
4.56, 0.71, …, 5.36
What are vector embeddings?
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
How vector embeddings are used
Foundation Model
Prompt
augmentation
Response
Embeddings model Data source
Aurora PostgreSQL
Embeddings
model
Embedding
User
User Input
Context
-0.02
0.89 -0.38
-0.53 0.95 0.17
Retrieval
Generation
Workflow
Data Ingestion
Workflow
Semantic
search
Document chunks
1
2
3
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Why use PostgreSQL for vector searches?
The easiest way to build and scale generative AI
applications on RDS/Aurora PostgreSQL
Keep App + AI/ML data in same DB
Benefit from data & vector embedding co-
location
Aurora Serverless
Fully managed, on-demand, autoscaling
config to optimized performance, cost
Gen AI ready for OLTP, faster TTM
Easy! Familiar SQL interface, data in PG,
client libraries work without modification
End to End Production-ready
Seamlessly transition from application
prototyping to production
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
What is pgvector?
An open source extension that:
adds support for storage, indexing, searching, metadata with choice of distance
vector data type
Supports IVFFlat/HNSW indexing
Distance operators (<->, <=>, <#>)
Exact nearest neighbor (K-NN)
Approximate nearest neighbor (ANN)
Co-locate with embeddings
github.com/pgvector/pgvector
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
pgvector example: Querying nearest neighbor
CREATE EXTENSION VECTOR ;
CREATE TABLE test_embeddings(product_id bigint, embeddings vector(3) );
INSERT INTO test_embeddings VALUES
(1, '[1, 2, 3]'), (2, '[2, 3, 4]'), (3, '[7, 6, 8]'), (4, '[8, 6, 9]’);
SELECT product_id, embeddings, embeddings <-> '[3,1,2]' AS distance
FROM test_embeddings ORDER BY embeddings <-> '[3,1,2]’ limit 2;
product_id | embeddings | distance
------------+------------+-------------------
1 | [1,2,3] | 2.449489742783178
2 | [2,3,4] | 3
(2 rows)
• Supports exact and approximate nearest neighbor (ANN) search
• L2 distance <->
• Inner product <#>
• Cosine distance <=>
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
• IVFFlat
§ K-means based
§ Organize vectors into lists
§ Requires prepopulated data
§ Insert time bounded by # lists
• HNSW
§ Graph based
§ Organize vectors into
“neighborhoods”
§ Iterative insertions
§ Insertion time increases as data in
graph increases
Indexing methods: IVFFlat and HNSW
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
pgvector use cases
Industry E-Commerce Social Media Healthcare Finance
Media &
Entertainment
Automotive &
Manufacturing
1
Product
Recommendations
🟠🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠 🟠🟠🟠 🟠🟠🟠🟠 🟠🟠
2 Content Similarity 🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠 🟠🟠🟠🟠🟠 🟠🟠
3 Fraud Detection 🟠🟠🟠 🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠
4 Anomaly Detection 🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠🟠🟠
5 Document Clustering 🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠
6
Chatbots & Virtual
Assistants
🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠 🟠🟠
7 Image Similarity Search 🟠🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠
8 Customer Segmentation 🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠
9 Sentiment Analysis 🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠 🟠🟠🟠🟠 🟠🟠
10 Predictive Maintenance 🟠🟠 🟠 🟠🟠 🟠🟠 🟠 🟠🟠🟠🟠🟠
🟠🟠🟠🟠🟠: Extremely high impact and relevance
🟠🟠🟠🟠: High impact and relevance
🟠🟠🟠: Moderate impact and relevance
🟠🟠: Low impact and relevance
🟠: Very low impact and relevance
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
Integration with Amazon Bedrock
Query
Response
generation
Amazon Aurora
support for
knowledge bases for
Amazon Bedrock
0.23, 1.58, …, 8.45
4.56, 0.71, …, 5.36
Foundation
models
Amazon
Aurora
Amazon Bedrock
knowledge bases
Retrieval
Augmented
Generation
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
SQL integration via aws_ml extension
GenAI application Amazon Bedrock
Aurora PostgreSQL
• Author queries in SQL to invoke
vector embeddings in Amazon
Bedrock via
invoke_model_get_embeddings API
• Author queries in SQL to invoke LLMs
available in Amazon Bedrock via
invoke_model API
• Use cases – case notes summarization,
product catalog search, sentiment
analysis and more
SQL/aws_ml
Query
SELECT aws_bedrock.invoke_model (
'amazon.titan-text-express-v1’,
'application/json’,
'application/json’,
'{"inputText": "this is where you place your input text", "textGenerationConfig": {"maxTokenCount":
8192,"stopSequences": [],"temperature":0,"topP":1}' );
'"body": {{"embedding": [e1, e2, e3.... en]}}'
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
Demo
Document
chunks
Amazon Titan
Embeddings
PDF
document
Amazon
Aurora
PostgreSQL-
Compatible
User
Embeddings Large language
model
(Claude v3)
1
4
Question
Question + Context
Response
2 3
5
6
7
Knowledge Bases for Amazon Bedrock with Aurora PostgreSQL
What is the new features in
PostgreSQL v16 ?
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
44
Demo
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thank you!
DalYoung Jung
dalyoung@amazon.com
YunCheol Ha
yuncheol@amazon.com

[D3T1S01] Gen AI를 위한 Amazon Aurora 활용 사례 방법

  • 1.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. DalYoung Jung AWS MySQL Specialist SA Amazon Aurora with Gen AI Amazon Aurora에서 생성형 AI 활용하기 YunCheol Ha AWS Senior PostgreSQL Specialist SA
  • 2.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Amazon Aurora MySQL with Gen AI 2
  • 3.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 • 생성형 AI을 어떤 DB업무에 활용 가능할까? • 생성형 AI를 DB업무에 활용하기 위해선 어떤 지식들이 필요한가? • Amazon Aurora MySQL 서비스를 Amazon Bedrock 연동하기 • 데모 3 Agenda
  • 4.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 증가되는 데이터베이스 관리의 어려움 All I wanted was a simple distributed database!! It's too hard to operate!
  • 5.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 생성형 AI을 어떤 DB업무에 활용 가능할까? 자연어를 통한 일반 DB업무 간소화 • 다수의 Aurora 클러스터를 관리 ”동일한 구성을 가진 10개의 Aurora 클러스터 생성해줘, 클러스터 이름은 Prod#1에서 하나씩 숫자를 늘려가면서 생성해줘.” • 업그레이드 및 패치 자동화 “Product DB #1에서 #10번까지의 클러스터를, Aurora version 3.07 로 업그레이드 해줘” • 성능 모니터링 및 최적화 “지난 1주일간에 가장 높은 CPU와 메모리 사용량을 보이는 클러스터를 찾아줘” “비효율적인 리소스 사용율을 보이는 DB 리스트들을 알려줘”
  • 6.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 생성형 AI을 어떤 DB업무에 활용 가능할까? 중요한 데이터의 보안과 접근 통제 관리 “보안 이슈가 의심되는 데이터베이스에 대한 자세한 보고서를 제공해줘” 이기종간의 DB 마이그레이션 “제공되는 Oracle 쿼리를 PostgreSQL 쿼리로 변경해줘” 성능 튜닝 “ 쿼리플랜을 분석해서 성능에 좋지 않은 쿼리들을 찾아줘” “ 현재 실행되는 쿼리를 분석해서 최적화된 쿼리로 다시 작성해줘”
  • 7.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 정확한 결과를 얻기 위해서는 어떻게 해야할까?
  • 8.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 프롬프트엔지니어링 “Prompt는 Response 을 이끌어내기 위해 Large Language model에 전달하는 정보입니다” Prompt에 요구 사항을 구 체적으로 전달하고 Context 로 기본으로 테이 블 스키마 및 샘플등을 제 공하는것이 중요하다
  • 9.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 RAG활용하여 샘플 쿼리 및 정보를 학습 검색(Retrieval) 검색된 관련 컨텍스트를 사용자 프롬프트에 추가하여 기반 모델에 대한 입력으로 사용 증강(Augmentation) 생성(Generation) 증강 프롬프트 기반 기반 모델의 응답 사용자 쿼리를 기반으로 외부 지식 베이스 또는 데이터 소스에서 관련 콘텐츠를 가져옵니다
  • 10.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 어떤 서비스들을 통해서 구현 할 수 있을까?
  • 11.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 다 양 한 파 운 데 이 션 모 델 을 A P I 를 통 해 서 사 용 할 수 있 도 록 해 주 는 완 전 관 리 형 서 비 스 11 Amazon Bedrock 이점 • API를 통해 FM을 사용하여 생성형 AI 애플리케이션 개발 가속화 • 인프라 관리 불필요 • AI21 Labs, Anthropic, Cohere, Stability AI 및 Amazon의 FM 선택 • 조직의 데이터를 사용하여 개인적으로 FM 사용자 지정 • 포괄적인 AWS 보안 기능 • NEW - Bedrock용 에이전트를 사용하여 몇 번의 클릭만으로 생성형 AI 앱을 활성화하여 작업을 완료할 수 있도록 지원 11
  • 12.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 Summarization, complex reasoning, writing, coding Contextual answers, summarization, paraphrasing High-quality images and art Text generation, search, classification Q&A and reading comprehension Text summarization, generation, Q&A, search, image generation Amazon Titan Text Premier Amazon Titan Text Lite Amazon Titan Text Express Amazon Titan Text Embeddings Amazon Titan Text Embeddings V2 Amazon Titan Multimodal Embeddings Amazon Titan Image Generator Claude 3 Opus Claude 3 Sonnet Claude 3 Haiku Claude 2.1 Claude 2 Claude Instant Llama 3 8B Llama 3 70B Llama 2 13B Llama 2 70B Command Command Light Embed English Embed Multilingual Command R+ Command R Stable Diffusion XL1.0 Stable Diffusion XL 0.8 Jurassic-2 Ultra Jurassic-2 Mid Mistral Small Mistral Large Mistral 7B Mixtral 8x7B Text summarization, text classification, text completion, code generation, Q&A 다양한 고성능 파운데이션 모델을 지원 Amazon Bedrock
  • 13.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 파운데이션 모델(FM) - Claude3 의 특징 ü 뛰어난 추론 및 추론 능력 ü 뛰어난 자연어 처리 ü 강력한 프롬프트 엔지니어링 지원 ü 뛰어난 Context 이해 및 적응성 ü 강화된 보안 및 개인 정보 보호 장치 ü 비용 효율적이고 확장 가능한 아키텍처
  • 14.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 파운데이션 모델(FM) - Claude3 모델 성능 Reference : https://www.anthropic.com/news/claude-3-family
  • 15.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 • 여러 클러스터에서 스키마 변경 사항을 쉽게 검증하고 적용 • ERD 분석 및 DDL 스크립트 생성 • 여러 클러스터에서 성능 문제가 발생된 데이터베이스를 식별 • 버전 업그레이드 수행 및 확인 • 여러 클러스터를 동시에 분석하여 보안 이슈를 확인 • 이기종 데이터베이스 쿼리를 MySQL 쿼리로 쉽게 변환 Claude3 를 통해 DB업무에 할수 있는 일들은? 그렇지만 내가 필요한 정확한 결과를 제공받기 위해서는 여전히 많은 노력들이 필요합니다
  • 16.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Amazon Bedrock 을 활용한 프롬프트 기본 아키텍처 예 References : https://catalog.workshops.aws/genai-on-aws/en-US/08-working-with-databases Users Front-end Application (Python Code) Amazon Bedrock(Claude3) Amazon Aurora SQL Query statement Retrieve schema context Query Database Natural language prompt 1 2 4 5 Fetch Data 6 Send prompt to LLM 3
  • 17.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Demo1: Claude3를 활용한 MySQL 쿼리 실행
  • 18.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024
  • 19.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Demo2: Claude3를 사용한 Aurora MySQL 데이터베이스 관리 예
  • 20.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024
  • 21.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Lesson Learned 21 Rule을 지정 Boto API로 Bedrock을 통 해 Claude3 호출 백그라운드 데이터로 DB 스키마 정보 제공 XML Tag 포맷으로 실행할 내용을 정의
  • 22.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Lesson Learned 22 • Prompt Engineering 매우 중요 스키마 뿐만 아니라 참조할 데이터도 명시하면 좋음 • XML또는 JSON형태로 구조화된 포맷으로 정보를 제공하면 좋음 • 컬럼 정보, 컬럼에 대한 설명과 샘플데이터의 일부를 포함하면 좋음 • RAG를 통해서 관련된 정보를 학습시키면 좋음 • 정확성을 위해 샘플등을 통해서 검증 프로세스를 추가하면 좋음
  • 23.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Amazon Aurora MySQL 을 통해 Amazon Bedrock Invoke • Bedrock은 Aurora MySQL 3.06 릴리스 이상에서 지원됩니다. • Aurora MySQL에서 Bedrock 모델을 호출하기 위한 IAM Role을 생성하고 해당 Role을 Aurora 에 추가 • Aurora MySQL을 위한 Custom 파라미터그룹을 생 성하고, IAM Role의 ARN을 aws_default_bedrock_role 파라미터에 업데이트 • Bedrock에서 Anthropic Claude3 모델이 Enable되 어있는지 확인 • Bedrock 모델을 Invoke하기 위해서 Aurora MySQL 의 bedrock사용자에게 필요한 권한을 부여
  • 24.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Demo 3: Aurora MySQL에서 Amazon Bedrock 연결 설정 및 Invoke
  • 25.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024
  • 26.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Demo4 : Amazon Bedrock으로부터 응답을 통해 Aurora MySQL 테이블 업데이트
  • 27.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 27
  • 28.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Amazon Aurora PostgreSQL vector store with Gen AI 28
  • 29.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 29 Agenda • Overview of generative AI and the role of databases • PostgreSQL as a vector store • Integration with Amazon Bedrocks • Demo
  • 30.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Blue elephant vase that can hold up to three plants in it, hand painted… Parrot decorative figure stands 12 inches high, red, and orange, has… Reddish vase six inches deep perfect for cactuses and desert plants… Rabbit planter suitable for growing vegetables indoors, green and … Decorative ceramic turtle, blue and about eight inches wide, makes… Bird feeder shaped like a bird, can hold birdseed for 28 days and is… Sea shell themed vase that's two feet wide and can hold a variety… Garden variety owl planter, great for keeping your favorite flowers…
  • 31.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 Pre-trained on vast amounts of unstructured data Contain large number of parameters that make them capable of learning complex concepts Can be applied in a wide range of contexts Customize FMs using your data for domain specific tasks Generative AI is powered by foundation models
  • 32.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Retrieval Augmented Generation (RAG) Configure FM to interact with your company data A N S W E R Q U E S T I O N K N O W L E D G E B A S E S F O U N D A T I O N M O D E L How much does a blue elephant vase cost? Product catalog Price data A blue elephant vase typically costs $19.99 Sorry, I don't know
  • 33.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 What is vector ? Vector [3,2] x y R^2 magnitude direction Example [3,2,1] x y z R^3
  • 34.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 Unstructured data has to be vectorized into vectors to be used in generative AI applications CHAIRS STATUES VASES Product catalog Blue vase Red chair C L A U D E S T A B L E D I F F U S I O N J U R A S S I C - 2 A M A Z O N T I T A N 0.23, 1.58, …, 8.45 4.56, 0.71, …, 5.36 What are vector embeddings?
  • 35.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 How vector embeddings are used Foundation Model Prompt augmentation Response Embeddings model Data source Aurora PostgreSQL Embeddings model Embedding User User Input Context -0.02 0.89 -0.38 -0.53 0.95 0.17 Retrieval Generation Workflow Data Ingestion Workflow Semantic search Document chunks 1 2 3
  • 36.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Why use PostgreSQL for vector searches? The easiest way to build and scale generative AI applications on RDS/Aurora PostgreSQL Keep App + AI/ML data in same DB Benefit from data & vector embedding co- location Aurora Serverless Fully managed, on-demand, autoscaling config to optimized performance, cost Gen AI ready for OLTP, faster TTM Easy! Familiar SQL interface, data in PG, client libraries work without modification End to End Production-ready Seamlessly transition from application prototyping to production
  • 37.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 What is pgvector? An open source extension that: adds support for storage, indexing, searching, metadata with choice of distance vector data type Supports IVFFlat/HNSW indexing Distance operators (<->, <=>, <#>) Exact nearest neighbor (K-NN) Approximate nearest neighbor (ANN) Co-locate with embeddings github.com/pgvector/pgvector
  • 38.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 pgvector example: Querying nearest neighbor CREATE EXTENSION VECTOR ; CREATE TABLE test_embeddings(product_id bigint, embeddings vector(3) ); INSERT INTO test_embeddings VALUES (1, '[1, 2, 3]'), (2, '[2, 3, 4]'), (3, '[7, 6, 8]'), (4, '[8, 6, 9]’); SELECT product_id, embeddings, embeddings <-> '[3,1,2]' AS distance FROM test_embeddings ORDER BY embeddings <-> '[3,1,2]’ limit 2; product_id | embeddings | distance ------------+------------+------------------- 1 | [1,2,3] | 2.449489742783178 2 | [2,3,4] | 3 (2 rows) • Supports exact and approximate nearest neighbor (ANN) search • L2 distance <-> • Inner product <#> • Cosine distance <=>
  • 39.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 • IVFFlat § K-means based § Organize vectors into lists § Requires prepopulated data § Insert time bounded by # lists • HNSW § Graph based § Organize vectors into “neighborhoods” § Iterative insertions § Insertion time increases as data in graph increases Indexing methods: IVFFlat and HNSW
  • 40.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 pgvector use cases Industry E-Commerce Social Media Healthcare Finance Media & Entertainment Automotive & Manufacturing 1 Product Recommendations 🟠🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠 🟠🟠🟠 🟠🟠🟠🟠 🟠🟠 2 Content Similarity 🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠 🟠🟠🟠🟠🟠 🟠🟠 3 Fraud Detection 🟠🟠🟠 🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠 4 Anomaly Detection 🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠🟠🟠 5 Document Clustering 🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠 6 Chatbots & Virtual Assistants 🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠 🟠🟠 7 Image Similarity Search 🟠🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 8 Customer Segmentation 🟠🟠🟠🟠 🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠 9 Sentiment Analysis 🟠🟠 🟠🟠🟠🟠🟠 🟠🟠🟠 🟠🟠🟠 🟠🟠🟠🟠 🟠🟠 10 Predictive Maintenance 🟠🟠 🟠 🟠🟠 🟠🟠 🟠 🟠🟠🟠🟠🟠 🟠🟠🟠🟠🟠: Extremely high impact and relevance 🟠🟠🟠🟠: High impact and relevance 🟠🟠🟠: Moderate impact and relevance 🟠🟠: Low impact and relevance 🟠: Very low impact and relevance
  • 41.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 Integration with Amazon Bedrock Query Response generation Amazon Aurora support for knowledge bases for Amazon Bedrock 0.23, 1.58, …, 8.45 4.56, 0.71, …, 5.36 Foundation models Amazon Aurora Amazon Bedrock knowledge bases Retrieval Augmented Generation
  • 42.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 SQL integration via aws_ml extension GenAI application Amazon Bedrock Aurora PostgreSQL • Author queries in SQL to invoke vector embeddings in Amazon Bedrock via invoke_model_get_embeddings API • Author queries in SQL to invoke LLMs available in Amazon Bedrock via invoke_model API • Use cases – case notes summarization, product catalog search, sentiment analysis and more SQL/aws_ml Query SELECT aws_bedrock.invoke_model ( 'amazon.titan-text-express-v1’, 'application/json’, 'application/json’, '{"inputText": "this is where you place your input text", "textGenerationConfig": {"maxTokenCount": 8192,"stopSequences": [],"temperature":0,"topP":1}' ); '"body": {{"embedding": [e1, e2, e3.... en]}}'
  • 43.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 Demo Document chunks Amazon Titan Embeddings PDF document Amazon Aurora PostgreSQL- Compatible User Embeddings Large language model (Claude v3) 1 4 Question Question + Context Response 2 3 5 6 7 Knowledge Bases for Amazon Bedrock with Aurora PostgreSQL What is the new features in PostgreSQL v16 ?
  • 44.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 44 Demo
  • 45.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thank you! DalYoung Jung dalyoung@amazon.com YunCheol Ha yuncheol@amazon.com