13
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

InfraNodusでDify RAGを強化する:LLMのコンテキストを拡大

Last updated at Posted at 2025-03-27

著者:Dmitry Paranyushkin(InfraNodus創設者)

検索拡張生成(RAG)は、大規模言語モデル(LLM)にDifyのナレッジベースやドキュメントから付加情報を与える効果的な手法です。しかし、多くのRAGシステムには「大局的な視点」が欠けており、特に広範な質問に対して不十分な回答を生成する要因となっていました。

InfraNodusはDify RAGシステムに統合する時の役割

InfraNodusは、PDFやテキストなど多様なコンテンツから主要テーマ・関連性・情報の空白領域を抽出し、全体像を視覚化します。この情報をDifyに統合することで、AIからより深く広範な回答を引き出すことが可能になります。

主な効果:

  • コンテキスト全体の把握による回答精度の向上
  • 膨大なナレッジベースからの効率的なテーマ抽出
  • 抽象度の高い質問に対応可能なメタデータ提供

RAGパイプラインの改善方法

従来のRAGパイプラインは精密な質問には有効ですが、曖昧または一般的な問い合わせには課題がありました。InfraNodusのグラフAIプロンプトジェネレーターを活用することで、以下の改善が実現されます:

  1. ナレッジベースのメタデータをプロンプトに追加
  2. 検索段階での文脈理解を深化
  3. LLMが重要な概念を網羅的に考慮

具体例

今回のチャットフローは、一般なナレッジベースのドキュメントに接続する標準バージョンと、InfraNodus固有のトピック データを使用してRAGを強化されたバージョンの二つに。
IN-2.png

  • 標準RAGの場合
    「InfraNodusは何ができるか?」の質問に対し、機能の一側面のみ回答(試しリック
    InfraNodus-1.png

  • InfraNodus統合RAGの場合
    メイントピック(グラフ分析・AIワークフロー・アイデア探索など)とその関係性をプロンプトに追加することで、ツールの全容を踏まえた体系的な回答を生成(試しリック
    IN_3.png

使用方法

1. データ収集

  • 対象コンテンツ:PDF/Markdownファイル
  • Webサイトの場合はFirecrawl(cloud or open-source)を活用
  • InfraNodusは各種データソース(Google検索/RSS/YouTube字幕など)から直接インポート可能
    1.png

2. テキスト解析

  1. 可視化と分析:InfraNodusにテキストをアップロード
  2. 分析結果の探索:Analyticsパネルから「主要アイデア」「影響力の高い概念」「関連性」「盲点」を確認。手動で保存するか、Graph AIで自動要約を生成。
  3. RAGプロンプト生成:プロジェクトノート内のGenerate a RAG Prompt from Analyticsをクリックし、DifyでのRAGプロンプト改善に使用するデータを抽出。
  4. 詳細分析(オプション):「構造的ギャップ」の確認、表層ノードの削除による隠れたアイデアの抽出、またはInfraNodus APIによる自動化。

2.png

3. AIツール設定

  • Dify側で新規ナレッジベースを作成
  • ファイルをアップロードまたはFirecrawl APIでWebサイト取込

3.png

4. プロンプト強化

  • InfraNodus生成データ(主要トピック/関係性等)をDifyのカスタムプロンプトに組み込み
  • システムプロンプト例:
You are an expert in InfraNodus, and your task is to provide an answer to the user question based on the context you are provided about using InfraNodus and its tool.
## IMPORTANT INSTRUCTIONS, FOLLOW WHEN ANSWERING:
When you provide a response, use the following meta information about the underlying knowledge base to have a high-level overview of the content and to provide higher quality responses that integrate this content, in cases when relevant to the query (or when the query is too general to find results):
- the main topics in the context (listed inside the <MainTopics></MainTopics> XML tag) — you should focus on them especially
- relations between the concepts (listed inside <Relations></Relations> and <MainConcepts></MainConcepts> XML tag) — these are the most important ideas and relations in the context
- latent topics inside (listed inside <LatentTopics></LatentTopics> - these are non-obvious topics that you can take into account
- conceptual entry points (listed inside <ConceptualGateways></ConceptualGateways> XML tag) — use them to connect topics or to connect the knowledge to the outside world
<MainTopics>
1. Graph Dynamics: graph topic node word click setting show knowledge
2. AI Workflow: infranodus text network ai data analysis workflow base
3. Idea Exploration: idea generate gap research insight discourse develop interesting
4. Search Context: search context related google keyword result import market
5. Node Relations: occur sharing information retrieve
6. Text Analysis: main content relevant extract reveal create skip
</MainTopics>
<Relations>
structural gap
network analysis
topical cluster
</Relations>
<LatentTopics>
1. Conceptual Navigation: top concept cluster click menu setting statement analytics
2. Data Integration: search data research keyword import step google result
3. Insight Discovery: generate gap insight interesting find identify question specific
4. Network Strategy: network analysis use gpt base tool knowledge visualization
5. Analytical Display: discourse context structure analyze market connection term develop
6. Research Import: content main create extract reveal skip
7. Gap Identification: workflow 🎥 thinking case study start exploration tutorial
8. Knowledge Exploration: related article book product conversation original
9. Contextual Analysis: occur information sharing retrieve
</LatentTopics>
<ConceptualGateways>
retrieve, occur, influence, recommendation, node, search, setting, word, text, network, click, case, show
</ConceptualGateways>
## CONTEXT INFORMATION:
Use the following context as your learned knowledge, inside <context></context> XML tags.
<context>
{{#context#}}
</context>
Do not hallucinate answers, ONLY use the context provided to generate responses, and provide references to all the context elements you use for your response in inline links with links to the URLs where these results can be found .
If you didn't use any of the context documents to generate your response but generated it from your own knowledge, inform the user about it at the beginning.
Keep your answers VERY SHORT and concise. Only the minimum necessary.

クエリの拡張と最適化手法

一般的な質問をした場合、単一のナレッジベースに直接マッピングできないケースがあります。このような状況に対応するため、Difyのチャットフローには改善ステップを追加できます。InfraNodusから得られる広範な知見を統合することで、検索拡張生成(RAG)の検索フェーズにおける推測を不要にします。

enhance.png

以下はユーザー改善ステップを具体化するためのプロンプトです:

You receive a user query relating to InfraNodus text network analysis tool.
If the user query is specific, you just pass it on without changing anything.
However, if it's too general or not too precise, you need to make it more specific by adding the following context to it.
IMPORTANT: Make sure the final query is not much longer than the original one. Just add only the most important necessary information.
## CONTEXT TO ADD
### Context Explanation:
- the main topics in the context (listed inside the <MainTopics></MainTopics> XML tag) — you should focus on them especially
- relations between the concepts (listed inside <Relations></Relations> and <MainConcepts></MainConcepts> XML tag) — these are the most important ideas and relations in the context
- latent topics inside (listed inside <LatentTopics></LatentTopics> - these are non-obvious topics that you can take into account
- conceptual entry points (listed inside <ConceptualGateways></ConceptualGateways> XML tag) — use them to connect topics or to connect the knowledge to the outside world
### Context Details:
<MainTopics>
1. Graph Dynamics: graph topic node word click setting show knowledge
2. AI Workflow: infranodus text network ai data analysis workflow base
3. Idea Exploration: idea generate gap research insight discourse develop interesting
4. Search Context: search context related google keyword result import market
5. Node Relations: occur sharing information retrieve
6. Text Analysis: main content relevant extract reveal create skip
</MainTopics>
<Relations>
structural gap
network analysis
topical cluster
</Relations>
<LatentTopics>
1. Conceptual Navigation: top concept cluster click menu setting statement analytics
2. Data Integration: search data research keyword import step google result
3. Insight Discovery: generate gap insight interesting find identify question specific
4. Network Strategy: network analysis use gpt base tool knowledge visualization
5. Analytical Display: discourse context structure analyze market connection term develop
6. Research Import: content main create extract reveal skip
7. Gap Identification: workflow 🎥 thinking case study start exploration tutorial
8. Knowledge Exploration: related article book product conversation original
9. Contextual Analysis: occur information sharing retrieve
</LatentTopics>
<ConceptualGateways>
retrieve, occur, influence, recommendation, node, search, setting, word, text, network, click, case, show
</ConceptualGateways>

処理速度の最適化手法

enhanceplus.png

Difyチャットフローの最適化構造:

  1. ユーザーインタラクション開始
  2. If/ElseノードがInfraNodus変数を判定
  3. 変数は空の場合、InfraNodusリクエストを実行
  4. 変数割当ノードに保存
  5. クエリ拡張プロンプト生成
  6. 知識検索RAGを実行
  7. 検索結果・元クエリ・分析結果を統合し回答生成
  8. 最終結果出力

実際のデモを試すリンクはこちら、サンプルワークフローをダウンロードするならここにクリック。

結論

RAGの効果を最大限引き出すには、InfraNodusで作成する文脈マップが不可欠です。具体的質問と探索的質問の両対応が可能になり、Difyアプリの回答品質(明確性・構造性・網羅性)が飛躍的に向上します。

13
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?