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
AI導入は済んだ。次は統制を作り替える番だ_AI×開発組織 Summit 2026
techtekt
PRO
0
350
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
170
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
190
パスキーの自動テストはどこまでいけるのか
teamlab
PRO
0
280
⾮構造化データを価値に変える AI エージェント基盤とその組織
ivry_presentationmaterials
0
200
価値について
gree_tech
PRO
0
100
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
290
Local CI × GitHub Actions
gogutan
3
230
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
340
夫婦で子育てするための育児標準化
codmoninc
PRO
0
450
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
760
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
300
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
320
My Coaching Mixtape
mlcsv
0
360
Chasing Engaging Ingredients in Design
codingconduct
0
360
Discover your Explorer Soul
emna__ayadi
2
1.3k
Visualization
eitanlees
153
17k
Optimising Largest Contentful Paint
csswizardry
37
4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
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 参考文献