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
81
Bedrockでのプロンプト管理戦略
totsukash
2
130
Amazon SageMaker AIでモデル開発からデプロイまで試す
totsukash
2
41
Amazon CodeGuruをGitHubと統合して アプリケーションの品質管理を楽にする
totsukash
0
14
AWS Glueで始めるETLパイプライン
totsukash
0
21
Bedrockでガードレールのフィルターを理解する
totsukash
1
63
Amazon Novaを使用した蒸留
totsukash
2
85
SageMaker AIワークフローのあれこれ紹介
totsukash
1
71
Vertex AIで画像分類タスクのデータセットを準備する
totsukash
0
43
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Embracing the Ebb and Flow
colly
85
4.6k
Designing for Performance
lara
608
69k
BBQ
matthewcrist
88
9.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
How STYLIGHT went responsive
nonsquared
99
5.5k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.5k
Optimising Largest Contentful Paint
csswizardry
36
3.2k
Docker and Python
trallard
44
3.3k
RailsConf 2023
tenderlove
30
1.1k
How to train your dragon (web standard)
notwaldorf
90
6k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.1k
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.