はじめに
前回の#4では、LazyGraphRAGの概念とMicrosoftが提案する「DRIFT検索」について解説しました。今回は、実際にGraphRAG 2.7.0に実装されているDRIFT検索(LazyGraphRAG) を使って、Local検索・Global検索と比較検証していきます。
AI for Scienceの論文検索における課題
なぜ従来のRAGでは不十分なのか
AI for Science分野では、研究者が大量の論文から知識を抽出し、新たな研究仮説を立てる必要があります。しかし、従来のRAG(Retrieval-Augmented Generation)には以下の課題がありました。
1. 論文間の関係性が見えない
従来のベクトル検索ベースのRAGは、個々のチャンク(文章断片)の類似度に基づいて検索を行います。
従来のRAG:
クエリ → ベクトル検索 → 類似チャンク抽出 → LLM回答生成
問題点:
- 論文Aと論文Bの関係性が失われる
- 研究者間の共同研究ネットワークが見えない
- 概念間の階層構造が無視される
例えば、「スピントロニクス研究の最新動向」を調べたい場合:
- 従来のRAG:「スピントロニクス」という単語を含むチャンクを返す
- 実際に欲しい情報:どの研究グループが、どの材料で、どのような応用に取り組んでいるかの全体像
2. Global検索とLocal検索のジレンマ
GraphRAGはこの問題に対処するため、2種類の検索を提供しています。
| 検索モード | 特徴 | 課題 |
|---|---|---|
| Local検索 | 特定のエンティティ周辺を詳細に検索 | 全体像が見えない |
| Global検索 | コミュニティレポートを使った俯瞰的検索 | 詳細が失われる |
AI for Scienceでよくあるクエリ例:
「ARIAフレームワークとは何か?どの研究機関が開発し、どのような技術要素があり、どのような評価結果が報告されているか?」
このクエリには:
- 俯瞰的理解(Global):ARIAの全体像、開発機関、位置づけ
- 詳細な事実(Local):具体的な技術要素、R²=0.9276などの数値
両方が必要です。
3. LazyGraphRAGが解決すること
LazyGraphRAG(DRIFT検索)は、このGlobalとLocalのギャップを埋めるために設計されました。
| 観点 | 従来のGraphRAG | LazyGraphRAG (DRIFT) |
|---|---|---|
| 検索戦略 | GlobalかLocalか選択 | 両方を動的に統合 |
| コンテキスト | 固定 | クエリに応じて拡張 |
| 回答の深さ | モード依存 | 必要に応じて深掘り |
| 計算コスト | 低〜中 | 高(トレードオフ) |
AI for Science論文検索への適用
AI for Science分野の論文検索では、以下のようなクエリパターンが多く見られます。
| クエリパターン | 例 | 必要な検索 |
|---|---|---|
| 概念説明 | 「ARIAフレームワークとは?」 | Global + Local |
| 比較分析 | 「GraphRAGとLazyGraphRAGの違いは?」 | 複数Local + Global |
| 研究動向 | 「AI for Scienceの最新トレンドは?」 | Global優先 |
| 技術詳細 | 「ARIAのContext Layerの仕組みは?」 | Local優先 |
| 関係性探索 | 「清華大学とARIAの関係は?」 | Local + グラフ走査 |
LazyGraphRAGは、これらのクエリパターンに対して適応的に検索戦略を選択し、最適な回答を生成します。
それでは、実際にLazyGraphRAG(DRIFT検索)を動かして、その効果を検証していきましょう。
実験環境
| 項目 | 値 |
|---|---|
| GraphRAG バージョン | 2.7.0 |
| LLM | Ollama qwen2.5:7b |
| Embedding | nomic-embed-text |
| API エンドポイント | http://192.168.224.1:11434 |
| 入力文書 | ARIA Framework論文(43KB Markdown) |
セットアップ
1. 仮想環境の作成とGraphRAGのインストール
# 仮想環境の作成
python3 -m venv .venv
source .venv/bin/activate
# GraphRAGのインストール
pip install graphrag==2.7.0
2. GraphRAGプロジェクトの初期化
mkdir lazygraphrag && cd lazygraphrag
graphrag init
これにより、以下のファイルが生成されます。
-
settings.yaml- GraphRAGの設定ファイル -
prompts/- プロンプトテンプレート
3. Ollama用の設定ファイル作成
GraphRAG 2.7.0でOllamaを使用する場合、settings.yamlを以下のように編集します。
### GraphRAG + LazyGraphRAG (DRIFT) 設定
### Ollama ローカルLLM版
### LLM settings ###
models:
default_chat_model:
type: chat
model_provider: ollama
model: qwen2.5:7b
api_base: http://192.168.224.1:11434
api_key: ollama # Ollamaでは任意の値でOK
model_supports_json: true
concurrent_requests: 1
async_mode: threaded
retry_strategy: exponential_backoff
max_retries: 10
request_timeout: 600 # タイムアウト延長
default_embedding_model:
type: embedding
model_provider: ollama
model: nomic-embed-text
api_base: http://192.168.224.1:11434
api_key: ollama
concurrent_requests: 1
async_mode: threaded
retry_strategy: exponential_backoff
max_retries: 10
### Input settings ###
input:
storage:
type: file
base_dir: "input"
file_type: text
file_pattern: '.*.md'
chunks:
size: 1200
overlap: 100
group_by_columns: [id]
### Output/storage settings ###
output:
type: file
base_dir: "output"
cache:
type: file
base_dir: "cache"
reporting:
type: file
base_dir: "logs"
vector_store:
default_vector_store:
type: lancedb
db_uri: output/lancedb
container_name: default
### Workflow settings ###
embed_text:
model_id: default_embedding_model
vector_store_id: default_vector_store
extract_graph:
model_id: default_chat_model
prompt: "prompts/extract_graph.txt"
entity_types: [organization, person, technology, concept, method, dataset]
max_gleanings: 1
summarize_descriptions:
model_id: default_chat_model
prompt: "prompts/summarize_descriptions.txt"
max_length: 500
cluster_graph:
max_cluster_size: 10
community_reports:
model_id: default_chat_model
graph_prompt: "prompts/community_report_graph.txt"
text_prompt: "prompts/community_report_text.txt"
max_length: 2000
max_input_length: 8000
### Search settings ###
local_search:
chat_model_id: default_chat_model
embedding_model_id: default_embedding_model
max_tokens: 12000
global_search:
chat_model_id: default_chat_model
map_prompt: "prompts/global_search_map_system_prompt.txt"
reduce_prompt: "prompts/global_search_reduce_system_prompt.txt"
max_tokens: 12000
# LazyGraphRAG (DRIFT) 設定
drift_search:
chat_model_id: default_chat_model
embedding_model_id: default_embedding_model
max_tokens: 12000
auth_typeに注意
GraphRAG 2.7.0では auth_type: none は無効です。Ollamaの場合は api_key: ollama のような任意の値を設定してください。
4. 入力文書の配置
mkdir input
cp your_document.md input/
今回は#3で使用したARIA Framework論文(43KB Markdown)を使用しました。
インデックス構築
実行コマンド
graphrag index
構築結果
| 項目 | 値 |
|---|---|
| 総構築時間 | 10,715秒(約179分) |
| ドキュメント数 | 1 |
| エンティティ数 | 124 |
| リレーションシップ数 | 106 |
| コミュニティ数 | 15 |
エンティティタイプ内訳
| タイプ | 数 |
|---|---|
| CONCEPT | 30 |
| METHOD | 27 |
| (empty) | 16 |
| PERSON | 14 |
| TECHNOLOGY | 13 |
| DATASET | 12 |
| ORGANIZATION | 6 |
| GEO | 5 |
| METRIC | 1 |
ワークフロー所要時間内訳
| ワークフロー | 時間 | 備考 |
|---|---|---|
| extract_graph | 10,019秒(167分) | LLMによるエンティティ・関係抽出 |
| create_community_reports | 687秒(11分) | コミュニティレポート生成 |
| generate_text_embeddings | 9秒 | ベクトル埋め込み |
| その他 | 0.3秒 |
ローカルLLMの限界
qwen2.5:7bでは、エンティティ抽出だけで約3時間かかりました。GPT-4等のクラウドAPIを使用すれば、大幅な高速化が期待できます。
クエリテスト
同一のクエリを3つの検索モードで実行し、応答を比較しました。
テストクエリ: "What is the ARIA framework?"
実行コマンド
# DRIFT (LazyGraphRAG)
graphrag query -m drift -q "What is the ARIA framework?"
# Local検索
graphrag query -m local -q "What is the ARIA framework?"
# Global検索
graphrag query -m global -q "What is the ARIA framework?"
応答時間比較
| 検索モード | 応答時間 |
|---|---|
| DRIFT (LazyGraphRAG) | 2,138秒(35.6分) |
| Local | 62秒 |
| Global | 83秒 |
回答内容の比較
DRIFT (LazyGraphRAG) の回答
The ARIA framework is an advanced automated research intelligence assistant
developed by multiple institutions, including Tsinghua University,
Shanghai HiQ Smart Data Co., Ltd., and Beijing Information Science &
Technology University.
It consists of several key components such as the Context Layer,
AI Module Layer, and Spec-Driven Execution, which work together to
enable efficient data analysis processes.
The **Context Layer** maintains a comprehensive, time-ordered narrative
of the project for traceable reasoning and transparent peer review.
The **AI Module Layer** contains machine learning algorithms for
predictive capabilities.
The **Spec-driven Execution** design principle allows researchers to
articulate their analysis goals transparently and audibly.
ARIA has been evaluated using various datasets, achieving high accuracy
in predictive models. For instance, it used the Boston Housing dataset
with an XGBoost model to achieve a high R² value of 0.9276.
ARIA ensures the quality and reliability of generated code through
a combination of modular design, static analysis, and human-in-the-loop
validation. During execution, ARIA employs static analysis tools such
as `mypy` and `ruff` to enforce quality gates.
特徴:
- ✅ 最も包括的な回答
- ✅ Context Layer, AI Module Layer, Spec-Driven Executionの詳細
- ✅ 具体的な数値(R²=0.9276)
- ✅ 品質管理手法(mypy, ruff)への言及
- ❌ 応答時間が非常に長い
Local検索の回答
The ARIA (Automated Research Intelligence Assistant) framework is a
sophisticated system designed to support automated and interpretable
data analysis, integrating multiple layers to facilitate transparent
and collaborative scientific research.
ARIA is structured into six interoperable layers:
- Command Layer
- Context Layer
- Code Layer
- Data Layer
- Orchestration Layer
- AI Module Layer
Each layer contributes distinct capabilities while maintaining
bidirectional links to the others. The framework's core design
principle is spec-driven execution, where researchers articulate
what they wish to analyze in natural language, and ARIA determines
how to perform the analysis transparently and audibly.
ARIA's modular design ensures scalability across domains, allowing
new analytical tools to be integrated without disrupting the
framework's logical structure.
特徴:
- ✅ 構造化された回答
- ✅ 6層構造の詳細説明
- ✅ human-in-the-loopアーキテクチャへの言及
- ✅ 高速な応答(62秒)
Global検索の回答
The ARIA framework is a sophisticated automated research intelligence
assistant developed by Tsinghua University, Shanghai HiQ Smart Data
Co., Ltd., and Beijing Information Science & Technology University.
It comprises key components such as an AI module layer for machine
learning algorithms, a context layer to maintain project metadata,
and spec-driven execution as its core design principle.
ARIA has demonstrated high accuracy in predictive models using the
Boston Housing dataset with an R² value of 0.9276 and XGBoost model.
ARIA is poised for future extensions that include formal verification,
multimodal analysis, policy-aware deployment, longitudinal evaluation,
domain-specific orchestration language, scientific workflow systems,
next-generation autonomous scientific systems, and scientific discovery.
特徴:
- ✅ 開発機関の明記
- ✅ R²=0.9276の評価結果
- ✅ 将来拡張への言及
- △ 詳細度は中程度
性能トレードオフ分析
| モード | 品質 | 速度 | 適用場面 |
|---|---|---|---|
| DRIFT | ◎ | × | 詳細分析、レポート作成 |
| Local | ○ | ◎ | 特定概念の素早い検索 |
| Global | △ | ○ | 全体像の把握 |
DRIFT検索のアーキテクチャ
DRIFT検索は以下のステップで動作します。
- プライマー抽出: クエリからキーワードを抽出
- コミュニティ重み付け: 関連コミュニティをスコアリング
- レポート統合: Local検索結果とGlobal検索結果を統合
- Map-Reduce: 複数レポートを並列処理し、集約
- 最終回答生成: 統合された情報から回答を生成
このため、DRIFT検索はLocal・Globalの「いいとこ取り」ですが、処理コストが高くなります。
まとめ
実験結果のまとめ
| 項目 | DRIFT | Local | Global |
|---|---|---|---|
| 応答時間 | 35.6分 | 62秒 | 83秒 |
| 包括性 | ◎ | ○ | △ |
| 構造化 | ○ | ◎ | △ |
| 具体性 | ◎ | ○ | ○ |
LazyGraphRAG (DRIFT) の使い所
-
詳細な分析レポートが必要な場合
- 複数の観点からの情報統合
- 具体的な数値・事実の抽出
-
時間に余裕がある場合
- バッチ処理
- 夜間の自動実行
-
クラウドLLMを使用できる場合
- GPT-4等で高速化
- API料金を許容できる
今後の改善点
-
ハードウェアアクセラレーション
- GPU搭載マシンでの実行
- 量子化モデルの使用
-
モデル選択
- 小型高速モデル(qwen2.5:3b等)の評価
- クラウドAPIとのハイブリッド
-
キャッシュ戦略
- よく使うクエリのキャッシュ
- 部分更新インデックス
次回予告
次回#6では、日本語論文のチャンク分割に関するレポートを作成予定です。GraphRAGで日本語文書を扱う際の課題と解決策について解説します。