Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Text-to-SQLで自然言語から構造化データを取得する
Search
Shota Totsuka
February 05, 2025
2
120
Text-to-SQLで自然言語から構造化データを取得する
Shota Totsuka
February 05, 2025
Tweet
Share
More Decks by Shota Totsuka
See All by Shota Totsuka
Mastra活用|Text-to-SQLの実装と応用
totsukash
0
140
Bedrockでのプロンプト管理戦略
totsukash
3
140
Amazon SageMaker AIでモデル開発からデプロイまで試す
totsukash
2
47
Amazon CodeGuruをGitHubと統合して アプリケーションの品質管理を楽にする
totsukash
0
16
AWS Glueで始めるETLパイプライン
totsukash
0
28
Bedrockでガードレールのフィルターを理解する
totsukash
1
68
Amazon Novaを使用した蒸留
totsukash
2
88
SageMaker AIワークフローのあれこれ紹介
totsukash
1
72
Vertex AIで画像分類タスクのデータセットを準備する
totsukash
0
52
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
73
4.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
The Pragmatic Product Professional
lauravandoore
36
6.8k
How STYLIGHT went responsive
nonsquared
100
5.7k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Git: the NoSQL Database
bkeepers
PRO
431
65k
Balancing Empowerment & Direction
lara
1
520
Six Lessons from altMBA
skipperchong
28
3.9k
Site-Speed That Sticks
csswizardry
10
740
Transcript
None
自己紹介 ©Blueish 2024. All rights reserved. 戸塚 翔太|BLUEISH Shota Totsuka
・LLMアプリ開発者(Go/Python …etc) ・生成AI, 機械学習 ・趣味: スキー/スノボ, 最近はDifyにContribute ・静岡県(浜松)に住んでます 近くの方がいれば、一緒に勉強会しましょう! Xアカウント @totsukash
自己紹介 ©Blueish 2024. All rights reserved. AWS認定(1月から開始)
01 Text-to-SQLについて 02 やってみた 03 ハマったこと 04 まとめ 目次 ©Blueish
2024. All rights reserved.
ちょっと注意事項... ©Blueish 2024. All rights reserved.
サンプルデータではできそうですが、 本番利用に向けてはハマりポイントが 多そうです。 ©Blueish 2024. All rights reserved.
十分検証してください。 ©Blueish 2024. All rights reserved.
Let's go!!! ©Blueish 2024. All rights reserved.
01 Text-to-SQLについて ©Blueish 2024. All rights reserved.
- 自然言語からSQLを作成 - 例: 「idが1の人の名前は?」 →「SELECT name FROM table WHERE
id = 1」 - DBのスキーマ等とプロンプトの指示を元にSQLを作成 - 概念としてはLLMの隆盛前からあったが、生成AIでより難易度が低下 Text-to-SQL Text-to-SQLについて
©Blueish 2024. All rights reserved. - ベクトル検索 - 類似度の高いものを探す -
完全一致ではない - Text-to-SQL - 条件に合うものを探す - 曖昧度は低いが、SQLが正し く生成されなければ正しく情 報を取得できない ベクトル検索との違い Text-to-SQLについて
02 やってみた ©Blueish 2024. All rights reserved.
©Blueish 2024. All rights reserved. やってみた ©Blueish 2024. All rights
reserved. - Bedrock ナレッジベース - ナレッジベースを通してSQLクエリを生成し、実行結果を取得 - Redshift Serverless - 構築したテーブルに対して、実際にSQLクエリを実行するためのクエリエンジン - S3 - csvファイルを格納 構成
©Blueish 2024. All rights reserved. やってみた ©Blueish 2024. All rights
reserved. 自然言語 SQL
©Blueish 2024. All rights reserved. やってみた ©Blueish 2024. All rights
reserved. - AWS が提供するクラウドベースのデータウェアハウスサービス - クエリエンジンの提供 - サーバーレス運用 → 運用コストの削減 Redshift Serverless
©Blueish 2024. All rights reserved. やってみた ©Blueish 2024. All rights
reserved. - id - name - email - …etc RedshiftでDBを準備 データ構成は以下記事のものを使用させていただきました。 https://blog.denet.co.jp/adcale2024_bedrock-knowledge-bases-structured-data-retrieval/
©Blueish 2024. All rights reserved. やってみた ©Blueish 2024. All rights
reserved. - 2024年12月4日 AWS re:Invent 2024 で構造化データ取得のサポートがプレ ビューとして発表 - 現在はRedshiftのみサポート? Bedrock ナレッジベース(with 構造化データ)
©Blueish 2024. All rights reserved. やってみた ©Blueish 2024. All rights
reserved. 自然言語 SQL
03 ハマったこと ©Blueish 2024. All rights reserved.
©Blueish 2024. All rights reserved. ハマったこと ©Blueish 2024. All rights
reserved. - 日本語で書いて欲しいクエリが英語に置換される 【解決策】 - 「”サッカー”は英語に訳さず日本語でクエリに使用して」など ①日本語が微妙
©Blueish 2024. All rights reserved. ハマったこと ©Blueish 2024. All rights
reserved. - Generation/Orchestration それぞれ変更可能 - 出力形式やテーブルのスキーマを上書きするこ とはできなさそう - temperatureなどのパラメータは変更可能 プロンプトテンプレートの変更も可能
©Blueish 2024. All rights reserved. ハマったこと ©Blueish 2024. All rights
reserved. ②Agentから接続できない問題
ご清聴ありがとうございました。 ©Blueish 2024. All rights reserved.