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
110
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
95
Bedrockでのプロンプト管理戦略
totsukash
3
130
Amazon SageMaker AIでモデル開発からデプロイまで試す
totsukash
2
42
Amazon CodeGuruをGitHubと統合して アプリケーションの品質管理を楽にする
totsukash
0
14
AWS Glueで始めるETLパイプライン
totsukash
0
21
Bedrockでガードレールのフィルターを理解する
totsukash
1
65
Amazon Novaを使用した蒸留
totsukash
2
85
SageMaker AIワークフローのあれこれ紹介
totsukash
1
71
Vertex AIで画像分類タスクのデータセットを準備する
totsukash
0
44
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.2k
What's in a price? How to price your products and services
michaelherold
245
12k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
420
Become a Pro
speakerdeck
PRO
28
5.3k
Docker and Python
trallard
44
3.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
A better future with KSS
kneath
239
17k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
33k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.6k
Documentation Writing (for coders)
carmenintech
71
4.8k
Principles of Awesome APIs and How to Build Them.
keavy
126
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.