Skip to Content
生産性のためのハンズオンRAG (Japanese Edition)
book

生産性のためのハンズオンRAG (Japanese Edition)

by Ofer Mendelevitch, Forrest Sheng Bao
May 2026
358 pages
5h 53m
Japanese
O'Reilly Media, Inc.
Content preview from 生産性のためのハンズオンRAG (Japanese Edition)

第2章 基本RAGスタック

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

第1章では、リトリーバル拡張生成(RAG)の核心となる概念、すなわち大規模言語モデルがトレーニング中に学習した内容だけに依存するのではなく、外部知識にアクセスできるようにすることについて紹介した。本章では、RAGシステムが実際に機能するための技術的構成要素についてさらに深く掘り下げる。これらの構成要素は、生のドキュメントの準備から、文脈に基づいた高品質な応答の生成に至るまで、データが流れるパイプラインを形成しており、これはしばしばRAGスタックと呼ばれる。

まず、あらゆるRAGシステムを定義する2つの主要なフローについて検討する。1つは、将来LLMに未見の知識を供給するためにデータを変換・保存する「取り込みフロー」であり、もう1つは、推論時に起動してユーザのリクエストに応答する「クエリフロー」である。 これらのフローにおける各ステップ——パーシング、チャンキング、エンベディング、インデクシング、ベクトル検索、再ランク付け、そしてLLMベースの生成——は、それぞれ独自の役割を果たし、固有のトレードオフを伴う。これらの要素を理解することは、エラーの診断、品質の向上、そして本番環境で予測可能な動作をするスケーラブルなRAGアーキテクチャの設計に不可欠だ。

各レイヤーを順を追って解説するにあたり、概念の説明にとどまらず、実際のコード例、実践的なガイダンス、そして一般的な設計選択の背景にある理論的根拠を用いて具体化する。この章を読み終える頃には、基本的なRAGスタックがエンドツーエンドでどのように機能するか、またその構成要素がどのようにやり取りをして、正確かつ効率的で信頼性の高いAI駆動型の情報検索を実現するのかについて、明確な理解が得られるだろう。

RAGスタックのフロー

第1章で見たように、基本的なRAGスタックには、取り込みフロークエリフローという2つの主要なフローがある。取り込みフローは通常、新しいデータが利用可能になったとき、または既存のデータを更新する必要があるときに一度実行される。クエリフローは、ユーザがRAGシステムにクエリを送信するたびにトリガーされ、取り込みフローで準備されたデータを使用してユーザのクエリに応答する。

取り込みフロー

取り込みフローでは、ソースドキュメントが前処理(つまり、解析とチャンキング)され、この前処理の結果は、後でLLMがタスクを実行したりユーザークエリに応答したりするために、効率的な検索と取得が可能になるよう保存される。

取り込みフローは通常、構文解析、チャンキング、エンベディング、インデックス作成の4つのステップから構成される(図2-1)。

Diagram illustrating the ingestion flow process with steps: parsing, chunking, embedding, and indexing using data sources like databases, files, and web scraping.
図2-1. データ取り込みフローの主要な 構成要素またはステップ。本番システムでは、これらのステップは通常、再試行機能を用いて非同期的に調整されることに留意されたい

取り込み対象のデータは、データベース、ファイル(ローカルまたはクラウド)、API、ウェブスクレイピングなど、さまざまなソースから取得できる。データベースやAPIからのデータは構造化されているため、一般的に取り込みが容易だ。これらの場合、フィールドやデータ型を定義するスキーマは事前に判明している。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

The Human Factor in AI-Based Decision-Making

The Human Factor in AI-Based Decision-Making

Philip Meissner, Christoph Keding
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 0642572397647