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
120
Bedrockでのプロンプト管理戦略
totsukash
3
140
Amazon SageMaker AIでモデル開発からデプロイまで試す
totsukash
2
46
Amazon CodeGuruをGitHubと統合して アプリケーションの品質管理を楽にする
totsukash
0
16
AWS Glueで始めるETLパイプライン
totsukash
0
22
Bedrockでガードレールのフィルターを理解する
totsukash
1
67
Amazon Novaを使用した蒸留
totsukash
2
87
SageMaker AIワークフローのあれこれ紹介
totsukash
1
71
Vertex AIで画像分類タスクのデータセットを準備する
totsukash
0
51
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Typedesign – Prime Four
hannesfritz
42
2.7k
Thoughts on Productivity
jonyablonski
69
4.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
RailsConf 2023
tenderlove
30
1.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
34k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Faster Mobile Websites
deanohume
307
31k
Scaling GitHub
holman
459
140k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.9k
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.