Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
BigQuery と LangChainで実現するRAGパイプライン
Search
Kotaro
July 26, 2024
Technology
210
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
BigQuery と LangChainで実現するRAGパイプライン
機械学習の社会実装勉強会第37回の発表内容です。
https://machine-learning-workshop.connpass.com/event/324630/
Kotaro
July 26, 2024
Other Decks in Technology
See All in Technology
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
sanghyuk
0
160
あけおめLINE 傾向とその対策
nasa9084
0
330
Vibe Coding で作ったプロダクトをどう安全に動かすか / How to Safely Run Products Built with Vibe Coding
glidenote
0
690
音声コミュニティを守るAI監視基盤_ 90%以上の入力削減を支えたServerless設計と運用判断
shuheioka123
0
110
顧客に向き合う開発組織へ。リアーキテクチャとフィーチャーチーム化で挑む組織改革
safie
0
2.5k
AWS FinOps Agent 結局何が得意なの?
siromi
0
170
Von-Neumann Machines, Dreams & The Futures of IT
ufried
0
130
spanner-autoscalerに学ぶ CRD設計パターン 〜自動化と緊急時対応を両立する Kubernetesコントローラーの作り方〜
tkuchiki
0
140
高負荷プロダクション環境におけるAWS Lambdaのリアル 〜スケールとコストを左右する実行ライフサイクルの技術仕様〜
maimyyym
2
630
セルフサービスのオブザーバビリティ基盤をOpenTelemetryで作る / Building a Self-Service Observability Platform with OpenTelemetry
ymotongpoo
3
330
EventBridge に「合流」はない ― サーバーレスのワークフローを育てるということ / No Join in EventBridge
yusukeshimizu
2
560
SREへの勘違いに気づいた後の話
tomodakengo
0
160
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
590
Building Flexible Design Systems
yeseniaperezcruz
330
41k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
510
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
The browser strikes back
jonoalderson
0
1.7k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
420
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
290
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
500
Evolving SEO for Evolving Search Engines
ryanjones
0
300
Transcript
BigQuery と LangChain で実現する RAG パイプライン 2024/07/27 機械学習の社会実装勉強会 第37回
LLMの課題 Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs https://arxiv.org/abs/2312.05934
不正確な回答 トレーニングデータにない情報は知らない - 最新情報 - 機密情報 - … LLM ? RAG 追加の情報を外部ソースから与える ファインチューニング LLMを再学習させる LLMの知識を拡張させる方法 「昨日の東京の天気は?」
RAGとは RAG (Retrieval-Augmented Generation) - 外部データベースから関連する情報を検索(Retrieval) - 質問文を拡張(Augument) - それを基に回答を生成(Generation)
RAGの基本構造 社内文書等 Vector DB Embedding Embedding LLM 4. 質問文: 有給休暇は何日?
+ 参考情報: 有給休暇は20日 1. 質問文: 有給休暇は何日? 5. 回答文: 有給休暇は20日です 0. Vector DBに保存 3. 参考情報取得 2. ベクトル検索
RAGの基本構造 外部情報 ベクトル 6月23日は創立記念日 [0.3, 0.23, …] 開発部署の内線番号は 57 [0.2,
0.67, …] 有給休暇は年間20日 [0.4, 0.4, …] 社内文書等 Vector DB Embedding 0. Embedding した外部データをVector DBに保存 [0.3, 0.23, …] [0.1, 0.3, …] [0.3, 0.5, …] ... Store
RAGの基本構造 入力プロンプト (質問文) ベクトル 有給休暇は年間何日ですか? [0.3, 0.23, …] VectorDBの情報 入力プロンプトとの類似度
6月23日は創立記念日 [0.3, 0.23, …] 0.3 有給休暇は年間 20日 [0.2, 0.67, …] 0.8 開発部署の内線番号は57 [0.4, 0.4, …] 0.2 1. 質問文をEmbedding 2. ベクトル検索により類似度の高い文章を 3. 参考情報として取得
RAGの基本構造 入力プロンプト (質問文+参考情報 ) 有給休暇は年間何日ですか? 参考情報:有給休暇は年間 20日 LLMの回答 有給休暇は年間20日です。 4.
拡張した質問文を生成し 5.LLMの回答を得る
効率的な情報検索 必要な情報を外部データベースから検索し、最新の情報を提供する 計算リソースの節約 必要な情報を都度検索するため、すべての知識をモデルに持たせる必要がない RAGの利点 比較的低コストで信頼性の高い回答が期待できる
RAGの実装 (今回のデモ ) 1. VertexAIEmbeddingsを使用してテキストデータをembeddingする https://api.python.langchain.com/en/latest/embeddings/langchain_google_vertexai.embeddings.VertexAIEmbeddings.html 2. BigQueryVectorStoreを用いてBigQueryに格納する https://api.python.langchain.com/en/latest/bq_storage_vectorstores/langchain_google_community.bq_storage_vectorstores.bigquer y.BigQueryVectorStore.html
3. create_retrieval_chain で 一連のRetrieval の処理を実行する https://api.python.langchain.com/en/latest/chains/langchain.chains.retrieval.create_retrieval_chain.html 使用したNotebook: https://github.com/kootr/ml-study-session/tree/main/20240727_bq_rag_langchain 参考にした記事: https://cloud.google.com/blog/ja/products/ai-machine-learning/rag-with-bigquery-and-langchain-in-cloud ↑少しライブラリの情報が古いです
DEMO
課題 ベクトル検索の精度が回答品質に直結 - ドキュメントの適切な分割単位 - 誤字脱字・表記揺れ - 継続的なメンテナンス
まとめ - RAG は LLM の回答の精度を向上させる有用な手法 - ベクトル検索の精度を高めることが重要 - Langchain
で BigQuery を Vector DB として利用できる - RAG パイプラインを実現できる
Tutorial: ChatGPT Over Your Data (langchain) 検索拡張生成(RAG)とは (Google Cloud) 元論文
https://arxiv.org/pdf/2005.11401 サーベイ論文 https://arxiv.org/pdf/2312.10997v5 参考文献