Product

Enhance Dify RAG with InfraNodus: Expand Your LLM’s Context

Integrating InfraNodus with Dify RAG enhances AI responses by providing contextual insights, improving retrieval accuracy, and enabling better handling of broad queries through topic mapping and metadata enrichment.

Dmitry Paranyushkin

InfraNodus founder

Written on

Mar 26, 2025

Share

Share to Twitter
Share to LinkedIn
Share to Hacker News

Product

·

Mar 26, 2025

Enhance Dify RAG with InfraNodus: Expand Your LLM’s Context

Integrating InfraNodus with Dify RAG enhances AI responses by providing contextual insights, improving retrieval accuracy, and enabling better handling of broad queries through topic mapping and metadata enrichment.

Dmitry Paranyushkin

InfraNodus founder

Share to Twitter
Share to LinkedIn
Share to Hacker News

Product

Enhance Dify RAG with InfraNodus: Expand Your LLM’s Context

Integrating InfraNodus with Dify RAG enhances AI responses by providing contextual insights, improving retrieval accuracy, and enabling better handling of broad queries through topic mapping and metadata enrichment.

Dmitry Paranyushkin

InfraNodus founder

Written on

Mar 26, 2025

Share

Share to Twitter
Share to LinkedIn
Share to Hacker News

Product

·

Mar 26, 2025

Enhance Dify RAG with InfraNodus: Expand Your LLM’s Context

Share to Twitter
Share to LinkedIn
Share to Hacker News

Product

·

Mar 26, 2025

Enhance Dify RAG with InfraNodus: Expand Your LLM’s Context

Share to Twitter
Share to LinkedIn
Share to Hacker News

Retrieval-Augmented Generation (RAG) is a well-known way to give large language models (LLMs) extra context from your own knowledge base or documents. However, most RAG setups have a hard time grasping the “big picture” of all that context. This gap can lead to weaker answers—especially if someone asks a broad question.

That’s where InfraNodus comes in. It creates an overview of any PDF, text, or other content you feed it, pinpointing main themes, connections, and gaps. You can then feed these insights back into Dify for more in-depth, wide-ranging responses from your AI.

Why Add InfraNodus Insights to Dify RAG System?

Standard Dify RAG pipelines shine when a user request is very specific—say, “How do I import a CSV file in InfraNodus?” They can quickly find matching chunks of text in your knowledge base. But for more open-ended questions (“What can I do with this?” “How can I enhance my workflow?”), RAG searches may struggle because the question doesn’t strongly match any particular document chunk.

By using InfraNodus to extract contextual data such as main topics, key relationships, and “blind spots,” you can help your RAG apps build with Dify produce answers that are broad but still accurate. InfraNodus uses its own GraphRAG implementation, so it has a better holistic understanding of the context as well as a better understanding of the main concepts and relations within. This supplementary metadata clarifies the overall structure of the material, prompting the model to cover important aspects—even for open-ended prompts.

How to Improve Retrieval Augmented Generation with Topical Context

A typical RAG pipeline encodes your query into vectors, then finds the closest matches in a database of text snippets. That works perfectly for precise questions but falters when dealing with vague or general prompts.

By leveraging the InfraNodus graph AI prompt generator, we can enrich our prompt with extra metadata from the knowledge base, enabling our RAG system to retrieve information more effectively. In turn, the LLM has better insights, allowing it to produce higher-quality responses and cover all important topics during user interactions.

For Example:

Standard RAG

If your knowledge base is about InfraNodus and you simply ask, “What can it do?” the chatbot agent on this portal (try it live here) gives a decent response. However, because it lacks InfraNodus data for context, it fails to cover the full range of InfraNodus’s capabilities and instead focuses on just one aspect of the tool.

InfraNodus-augmented RAG prompt

A chatbot agent on this portal uses InfraNodus-specific topical data to enhance its RAG.This data contains information about the main topics and concepts identified in the knowledge base with InfraNodus and is added directly into the LLM node’s prompt. As a result, the model will have a better understanding of the general context and produce better results even for general queries. If you try it live here, you'll notice how the additional contextual insights from the knowledge base lead to more structured and precise answers.

Step-by-Step: Using InfraNodus to Boost Dify RAG

Below is a generic approach you can adapt to suit your data:

  1. Collect the Data

  • Gather PDF or .MD files you want to use for your AI’s knowledge base.

  • If you’re dealing with a website, you can use Firecrawl (cloud or open-source) to crawl the pages. Firecrawl also integrates well with Dify.

  • You can import various data directly into InfraNodus—websites, Google search results, RSS feeds, YouTube transcripts, social media, and more. Once processed, InfraNodus can export relevant chunks or analytics.

  1. Visualize & Analyze

  • Upload the text into InfraNodus and generate a text network.

  • From the Analytics section, explore “Main Ideas,” “Most Influential Concepts,” “Relations,” and “Blind Spots.” Save these notes or auto-generate them via InfraNodus’s Graph AI prompt generator.

  • You can extract the necessary data with one click if you go to the Project Notes > and click the Generate a RAG Prompt from Analytics button. This will extract all the necessary insights from the Analytics panel and you can use this to augment your RAG prompt in Dify.

  • (Optional) Dive further: check “Structural Gaps,” remove top layers to surface hidden ideas, or use InfraNodus API to automate the extraction of these insights.

  1. Set Up Your AI Tool & Add Files

  • Within InfraNodus, you can also chat directly with the content.

  • For Dify, go to Knowledge and create a new Knowledge Base, upload the files there or use the Firecrawl API to ingest a website.

  1. Augment Your Prompt

Next, incorporate the data you generated with InfraNodus into your model’s prompt. To do this, locate the area in your application where you can add custom instructions that wrap around user queries directly in the prompt field.

Below is an example of a “System Prompt” you can use in Dify. Simply replace the data inside <tags> with what you generated in InfraNodus (such as main topics, key relationships, and conceptual gateways). This ensures your AI has access to a broader, more connected view of your knowledge base:

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>

Enhance General Queries

If your users ask very general questions that don’t directly map to a single knowledge-chunk, you can add a step that refines or “rewrites” the query in Dify chatflow. This step merges broader knowledge from InfraNodus so the RAG retrieval stage isn’t left guessing.

Here's an example of a prompt you can use to enhance user query:

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>

Everything inside the <tags></tags> can be retrieved directly from the InfraNodus graph. Simply navigate to Project Notes > Auto Generate for RAG, or use the InfraNodus API endpoint, to obtain these insights.

Optimize for Speed

In the example above, we’re using this entire support portal as our knowledge base. As a result, when InfraNodus first processes it to retrieve the main topics and contextual graph insights, it may take around 15–20 seconds.

To avoid running that process every time, we can store the initial output in a variable and reuse it for subsequent user queries. To set this up in Dify, add a “Variable Assigner” node and assign the output of the InfraNodus Knowledge Base Enhancer tool to it. Then, include an If / Else node that checks whether “InfraNodusGraph” is empty. If it isn’t, the workflow goes straight to the LLM Prompt Augmentor.

Below is an example workflow structure in Dify chatflow:

1) User starts interaction

2) If / Else operator sees if the InfraNodus variable is empty

3) If it is empty, make the InfraNodus request (as above) to retrieve graph insights on the original context

4) Save it into the variable assigner node (so it can be reused in the If / Else condition)

5) Use the output of InfraNodus (or the variable assigner output) to create a prompt that would enrich the original user's query in case it's too general 

6) Run knowledge retrieval RAG to extract the most relevant statements

7) Use the output of the RAG search AND the original query AND the InfraNodus-generated insight about the material to generate another prompt that would answer the original query. 

8) Output the results

You can try this chatbot here, or download a sample Dify workflow here.

Conclusion

RAG gets a major boost when you complement it with a high-level contextual map. InfraNodus is an easy way to create that map, helping your system handle both specific and more exploratory questions. When you use Dify to build your RAG apps, consider integrating metadata from InfraNodus to dramatically improve the clarity, structure, and coverage of your AI’s answers.

    On this page

    Related articles

    The Innovation Engine for Generative AI Applications

    The Innovation Engine for Generative AI Applications

    The Innovation Engine for Generative AI Applications