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
420
Text-to-SQLで自然言語から構造化データを取得する
Shota Totsuka
February 05, 2025
Tweet
Share
More Decks by Shota Totsuka
See All by Shota Totsuka
HITL実装によるマルチエージェント組織の設計パターン
totsukash
0
4
Claude Codeの知らない知識に立ち向かう
totsukash
1
310
Claude Codeの知らない知識、ADK, A2Aを用いた プロダクト開発をClaude Codeで行う
totsukash
0
330
Claude Code で Vibe Coding
totsukash
1
9
MCP, A2Aをプロダクトに組み込んで 開発している話
totsukash
1
8
Mastra活用|Text-to-SQLの実装と応用
totsukash
1
150
Bedrockでのプロンプト管理戦略
totsukash
3
140
Amazon SageMaker AIでモデル開発からデプロイまで試す
totsukash
2
50
Amazon CodeGuruをGitHubと統合して アプリケーションの品質管理を楽にする
totsukash
0
16
Featured
See All Featured
The Invisible Side of Design
smashingmag
301
51k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.1k
Documentation Writing (for coders)
carmenintech
75
5k
Scaling GitHub
holman
463
140k
How to Ace a Technical Interview
jacobian
280
23k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
How GitHub (no longer) Works
holman
315
140k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
YesSQL, Process and Tooling at Scale
rocio
173
14k
A better future with KSS
kneath
239
17k
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.