<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AI Archives - Víctor Dorado</title>
	<atom:link href="https://www.victordorado.es/category/ai/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.victordorado.es/category/ai/</link>
	<description></description>
	<lastBuildDate>Mon, 25 Aug 2025 09:43:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>Supercharging RAG Information Retrieval with N8N and LightRAG</title>
		<link>https://www.victordorado.es/2025/08/25/supercharging-rag-information-retrieval-with-n8n-and-lightrag/</link>
					<comments>https://www.victordorado.es/2025/08/25/supercharging-rag-information-retrieval-with-n8n-and-lightrag/#respond</comments>
		
		<dc:creator><![CDATA[vidorado]]></dc:creator>
		<pubDate>Mon, 25 Aug 2025 09:35:17 +0000</pubDate>
				<category><![CDATA[AI]]></category>
		<category><![CDATA[N8N]]></category>
		<category><![CDATA[RAG]]></category>
		<guid isPermaLink="false">https://www.victordorado.es/?p=2372</guid>

					<description><![CDATA[<p>LightRAG takes your AI to the next level: it merges the power of LLMs with semantic graphs and structured data to generate accurate, contextual, and trustworthy answers.</p>
<p>The post <a href="https://www.victordorado.es/2025/08/25/supercharging-rag-information-retrieval-with-n8n-and-lightrag/">Supercharging RAG Information Retrieval with N8N and LightRAG</a> appeared first on <a href="https://www.victordorado.es">Víctor Dorado</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p class="wp-block-paragraph">Large Language Models (LLMs) have proven remarkably effective at handling general-purpose queries, but <strong>they struggle when precision, domain-specificity, or continuously evolving knowledge are required</strong>. Out-of-the-box, their responses are often too shallow or prone to hallucination, which makes them unsuitable for production-grade information retrieval tasks.</p>



<p class="wp-block-paragraph"><strong>Retrieval-Augmented Generation (RAG) was introduced</strong> as a solution to this limitation, bridging LLMs with external knowledge bases. Yet, most “naive” RAG implementations remain constrained: <strong>they typically rely on basic vector similarity search</strong> and flat document retrieval, lacking deeper semantic reasoning, graph-based relationships, or robust orchestration capabilities. As a result, <strong>these pipelines often fail to deliver the context-rich, reliable answers</strong> demanded by real-world applications in domains such as legal or healthcare.</p>



<p class="wp-block-paragraph">This is where <strong>LightRAG</strong> comes into play. LightRAG enriches retrieval by <strong>leveraging structured knowledge representations and semantic graphs</strong>, enabling more accurate and context-aware responses.</p>



<p class="wp-block-paragraph">However, <strong>LightRAG is a single-query tool, and does not support chat history</strong> or other components within workflows. N8N, in turn, provides a powerful workflow automation layer, making it possible to seamlessly integrate enhanced RAG pipelines into operational systems and complex data flows. This is achieved through <strong>AI agents</strong>, which can leverage LightRAG alongside other tools to deliver more tailored responses and actions.</p>



<p class="wp-block-paragraph">In this post, I’ll walk through <strong>my experience combining LightRAG with N8N</strong> to move beyond naive RAG and build a more robust, production-ready approach to information retrieval.</p>



<h2 class="wp-block-heading">How LightRAG works</h2>



<p class="wp-block-paragraph">First, a RAG system must process documents. Instead of retrieving isolated text chunks from them, like standard RAG solutions, <strong>LightRAG also constructs a</strong> <strong>knowledge graph</strong> where entities, concepts, and their relationships are explicitly represented. This allows the system to <strong>capture semantic connections that naive RAG pipelines typically miss.</strong></p>



<figure class="wp-block-image size-large" style="margin-top:var(--wp--preset--spacing--60);margin-bottom:var(--wp--preset--spacing--60)"><img fetchpriority="high" decoding="async" width="1024" height="324" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-2-1024x324.png" alt="" class="wp-image-2377" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-2-1024x324.png 1024w, https://www.victordorado.es/wp-content/uploads/2025/08/image-2-300x95.png 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-2-768x243.png 768w, https://www.victordorado.es/wp-content/uploads/2025/08/image-2.png 1190w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">At retrieval time, when a query is received, it pulls the most similar passages like standard RAG solutions do, but <strong style="font-weight: bold;">LightRAG also performs a graph-based retrieval process</strong> <strong>to identify the most relevant nodes and relationships</strong>.</p>



<p class="wp-block-paragraph">Finally, <strong>the retrieved graph substructure and the most relevant text chunks are fed into the LLM</strong>, which can leverage<strong> both the textual evidence and the relational context</strong>. The result is a response that is not only <strong>grounded in the source documents</strong> but also <strong>informed by semantic structure</strong> and contextual relevance, enabling higher-quality answers for complex, domain-specific use cases.</p>



<div class="wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-021b19e" id="thats-awesome-now-show-me-the-code" data-block-id="021b19e"><h2 class="stk-block-heading__text">That&#8217;s awesome, now show me the code!</h2></div>



<p class="wp-block-paragraph">We will set up our workbench with <a href="https://docs.docker.com/compose/">Docker Compose</a>, a tool for defining and running multi-container applications. Docker Compose uses a a <code>docker-compose.yml</code> file that specifies all the configuration required by the containers.</p>



<p class="wp-block-paragraph">First, we define <strong>the PostgreSQL service</strong>—a database server with basic vector storage capabilities. The Docker Hub image <a href="https://hub.docker.com/r/shangor/postgres-for-rag">shangor/postgres-for-rag</a> is well-suited to our needs, as it comes with both the pgvector and Apache AGE extensions preinstalled. This image uses fixed defaults <code>rag/rag/rag</code> for the database name, user, and password, and cannot be configured via environment variables.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#39404f;color:#c8d0e0">docker-compose.yml</span><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>services:
  postgres:
    container_name: postgres
    image: shangor/postgres-for-rag:v1.0
    container_name: postgres
    volumes:
      - postgres_data:/var/lib/postgresql/16/main
    ports:
      - "5432:5432"
    environment: {}
    restart: unless-stopped
volumes:
  postgres_data:</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #8FBCBB">services</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">postgres</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">container_name</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">postgres</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">image</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">shangor/postgres-for-rag:v1.0</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">container_name</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">postgres</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">volumes</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">postgres_data:/var/lib/postgresql/16/main</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">ports</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">5432:5432</span><span style="color: #ECEFF4">&quot;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">environment</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">{}</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">restart</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">unless-stopped</span></span>
<span class="line"><span style="color: #8FBCBB">volumes</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">postgres_data</span><span style="color: #ECEFF4">:</span></span></code></pre></div>



<p class="wp-block-paragraph">Then, we add <strong>the LightRAG service</strong>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#39404f;color:#c8d0e0">docker-compose.yml</span><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>services:
  postgres:
   ...
  lightrag:
    container_name: lightrag
    image: ghcr.io/hkuds/lightrag:latest
    ports:
      - "9621:9621"
    volumes:
      - lightrag_data:/app/data
    env_file:
      - .lightrag-env
    restart: unless-stopped
volumes:
  postgres_data:
  lightrag_data:</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #8FBCBB">services</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">postgres</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">   </span><span style="color: #B48EAD">...</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">lightrag</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">container_name</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">lightrag</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">image</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">ghcr.io/hkuds/lightrag:latest</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">ports</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">9621:9621</span><span style="color: #ECEFF4">&quot;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">volumes</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">lightrag_data:/app/data</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">env_file</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">.lightrag-env</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">restart</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">unless-stopped</span></span>
<span class="line"><span style="color: #8FBCBB">volumes</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">postgres_data</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">lightrag_data</span><span style="color: #ECEFF4">:</span></span></code></pre></div>



<p class="wp-block-paragraph">We will keep all the configuration in <strong>a separate <code>.lightrag-env</code> file</strong>. Since it is quite large, placing it directly in the <code>docker-compose.yml</code> would bloat the file. There are many environment variables available, but here I will only show the ones I have configured.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#39404f;color:#c8d0e0">.lightrag-env</span><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>### Reranker Configuration
RERANK_BINDING=cohere
RERANK_MODEL=rerank-v3.5
RERANK_BINDING_HOST=https://api.cohere.com/v2/rerank
RERANK_BINDING_API_KEY=YOUR_API_KEY

### LLM Configuration
LLM_BINDING=openai
LLM_MODEL=gpt-4.1-mini
LLM_BINDING_HOST=https://api.openai.com/v1
LLM_BINDING_API_KEY=YOUR_API_KEY

### Embedding Configuration
EMBEDDING_BINDING=openai
EMBEDDING_MODEL=text-embedding-3-small
EMBEDDING_DIM=1536
EMBEDDING_BINDING_HOST=https://api.openai.com/v1
EMBEDDING_BINDING_API_KEY=YOUR_API_KEY

### Storage Configuration
LIGHTRAG_KV_STORAGE=PGKVStorage
LIGHTRAG_DOC_STATUS_STORAGE=PGDocStatusStorage
LIGHTRAG_GRAPH_STORAGE=PGGraphStorage
LIGHTRAG_VECTOR_STORAGE=PGVectorStorage

### PostgreSQL Configuration
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_USER=rag
POSTGRES_PASSWORD=rag
POSTGRES_DATABASE=rag
POSTGRES_MAX_CONNECTIONS=12</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #616E88">### Reranker Configuration</span></span>
<span class="line"><span style="color: #D8DEE9">RERANK_BINDING</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">cohere</span></span>
<span class="line"><span style="color: #D8DEE9">RERANK_MODEL</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">rerank-v3.5</span></span>
<span class="line"><span style="color: #D8DEE9">RERANK_BINDING_HOST</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">https://api.cohere.com/v2/rerank</span></span>
<span class="line"><span style="color: #D8DEE9">RERANK_BINDING_API_KEY</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">YOUR_API_KEY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">### LLM Configuration</span></span>
<span class="line"><span style="color: #D8DEE9">LLM_BINDING</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">openai</span></span>
<span class="line"><span style="color: #D8DEE9">LLM_MODEL</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">gpt-4.1-mini</span></span>
<span class="line"><span style="color: #D8DEE9">LLM_BINDING_HOST</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">https://api.openai.com/v1</span></span>
<span class="line"><span style="color: #D8DEE9">LLM_BINDING_API_KEY</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">YOUR_API_KEY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">### Embedding Configuration</span></span>
<span class="line"><span style="color: #D8DEE9">EMBEDDING_BINDING</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">openai</span></span>
<span class="line"><span style="color: #D8DEE9">EMBEDDING_MODEL</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">text-embedding-3-small</span></span>
<span class="line"><span style="color: #D8DEE9">EMBEDDING_DIM</span><span style="color: #81A1C1">=</span><span style="color: #B48EAD">1536</span></span>
<span class="line"><span style="color: #D8DEE9">EMBEDDING_BINDING_HOST</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">https://api.openai.com/v1</span></span>
<span class="line"><span style="color: #D8DEE9">EMBEDDING_BINDING_API_KEY</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">YOUR_API_KEY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">### Storage Configuration</span></span>
<span class="line"><span style="color: #D8DEE9">LIGHTRAG_KV_STORAGE</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">PGKVStorage</span></span>
<span class="line"><span style="color: #D8DEE9">LIGHTRAG_DOC_STATUS_STORAGE</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">PGDocStatusStorage</span></span>
<span class="line"><span style="color: #D8DEE9">LIGHTRAG_GRAPH_STORAGE</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">PGGraphStorage</span></span>
<span class="line"><span style="color: #D8DEE9">LIGHTRAG_VECTOR_STORAGE</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">PGVectorStorage</span></span>
<span class="line"></span>
<span class="line"><span style="color: #616E88">### PostgreSQL Configuration</span></span>
<span class="line"><span style="color: #D8DEE9">POSTGRES_HOST</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">postgres</span></span>
<span class="line"><span style="color: #D8DEE9">POSTGRES_PORT</span><span style="color: #81A1C1">=</span><span style="color: #B48EAD">5432</span></span>
<span class="line"><span style="color: #D8DEE9">POSTGRES_USER</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">rag</span></span>
<span class="line"><span style="color: #D8DEE9">POSTGRES_PASSWORD</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">rag</span></span>
<span class="line"><span style="color: #D8DEE9">POSTGRES_DATABASE</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">rag</span></span>
<span class="line"><span style="color: #D8DEE9">POSTGRES_MAX_CONNECTIONS</span><span style="color: #81A1C1">=</span><span style="color: #B48EAD">12</span></span></code></pre></div>



<p class="wp-block-paragraph">For testing purposes, I’ve used OpenAI, which is inexpensive and easy to set up. If you have access to a capable GPU, you can also run an Ollama service as an alternative.</p>



<p class="wp-block-paragraph"><strong>Using a reranker is crucial</strong>, as it greatly enhances the quality of responses provided by LightRAG. In my case, <strong>I chose Cohere</strong>, which offers a simple free plan, perfectly sufficient for our testing needs.</p>



<p class="wp-block-paragraph">Finally, we must add the N8N service. With N8N, we will implement the AI agent that leverages LightRAG as one of its tools.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#39404f;color:#c8d0e0">docker-compose.yml</span><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>services:
  postgres:
   ...
  lightrag:
   ...
  n8n:
    image: n8nio/n8n:latest
    ports:
      - "5678:5678"
    env_file:
      - .n8n-env
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres
    restart: unless-stopped
volumes:
  postgres_data:
  lightrag_data:
  n8n_data:</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #8FBCBB">services</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">postgres</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">   </span><span style="color: #B48EAD">...</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">lightrag</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">   </span><span style="color: #B48EAD">...</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">n8n</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">image</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">n8nio/n8n:latest</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">ports</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">5678:5678</span><span style="color: #ECEFF4">&quot;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">env_file</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">.n8n-env</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">volumes</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">n8n_data:/home/node/.n8n</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">depends_on</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">      </span><span style="color: #ECEFF4">-</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">postgres</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #8FBCBB">restart</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">unless-stopped</span></span>
<span class="line"><span style="color: #8FBCBB">volumes</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">postgres_data</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">lightrag_data</span><span style="color: #ECEFF4">:</span></span>
<span class="line"><span style="color: #D8DEE9FF">  </span><span style="color: #8FBCBB">n8n_data</span><span style="color: #ECEFF4">:</span></span></code></pre></div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#d8dee9ff;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#39404f;color:#c8d0e0">.n8n-env</span><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=postgres
DB_POSTGRESDB_PORT=5432
DB_POSTGRESDB_DATABASE=rag
DB_POSTGRESDB_USER=rag
DB_POSTGRESDB_PASSWORD=rag

N8N_HOST=http://localhost
N8N_PORT=5678
N8N_PROTOCOL=http
N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #D8DEE9">DB_TYPE</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">postgresdb</span></span>
<span class="line"><span style="color: #D8DEE9">DB_POSTGRESDB_HOST</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">postgres</span></span>
<span class="line"><span style="color: #D8DEE9">DB_POSTGRESDB_PORT</span><span style="color: #81A1C1">=</span><span style="color: #B48EAD">5432</span></span>
<span class="line"><span style="color: #D8DEE9">DB_POSTGRESDB_DATABASE</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">rag</span></span>
<span class="line"><span style="color: #D8DEE9">DB_POSTGRESDB_USER</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">rag</span></span>
<span class="line"><span style="color: #D8DEE9">DB_POSTGRESDB_PASSWORD</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">rag</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9">N8N_HOST</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">http://localhost</span></span>
<span class="line"><span style="color: #D8DEE9">N8N_PORT</span><span style="color: #81A1C1">=</span><span style="color: #B48EAD">5678</span></span>
<span class="line"><span style="color: #D8DEE9">N8N_PROTOCOL</span><span style="color: #81A1C1">=</span><span style="color: #A3BE8C">http</span></span>
<span class="line"><span style="color: #D8DEE9">N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE</span><span style="color: #81A1C1">=</span><span style="color: #81A1C1">true</span></span></code></pre></div>



<p class="wp-block-paragraph">Now we can run <code>docker compose up</code> to deploy our stack. We will have LightRAG available at <code>http://localhost:9621</code></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="281" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-3-1024x281.png" alt="" class="wp-image-2380" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-3-1024x281.png 1024w, https://www.victordorado.es/wp-content/uploads/2025/08/image-3-300x82.png 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-3-768x210.png 768w, https://www.victordorado.es/wp-content/uploads/2025/08/image-3.png 1095w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">In the screen above, I’ve already uploaded a document of my city’s mobility regulation. It covers cycle lanes, pedestrian areas, traffic, and how they interact within the urban environment. After waiting for the processing to be done (~15 minutes for a 130 page document), we can check out the knowledge graph and even make queries.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="1007" height="461" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-4.jpg" alt="" class="wp-image-2381" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-4.jpg 1007w, https://www.victordorado.es/wp-content/uploads/2025/08/image-4-300x137.jpg 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-4-768x352.jpg 768w" sizes="(max-width: 1007px) 100vw, 1007px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="902" height="576" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-4.png" alt="" class="wp-image-2382" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-4.png 902w, https://www.victordorado.es/wp-content/uploads/2025/08/image-4-300x192.png 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-4-768x490.png 768w" sizes="(max-width: 902px) 100vw, 902px" /></figure>



<p class="wp-block-paragraph">We obtained a fairly good response, along with the references used by the algorithm:</p>



<ul class="wp-block-list">
<li><strong>[KG]</strong> &#8211; References in the Knowledge Graph: either single entities or relations between two entities.</li>



<li><strong>[DG]</strong> &#8211; Text chunks retrieved from a document.</li>
</ul>



<p class="wp-block-paragraph">We can also play with different parameters: Query mode (global, local, hybrid&#8230; etc.),  response format, KG Top K, Chunk Top K, whether to enable or not reranking&#8230; refer to <a href="https://github.com/HKUDS/LightRAG?tab=readme-ov-file#query-param">the LightRAG documentation</a> for more info on these topics.</p>



<h2 class="wp-block-heading">Introducing N8N</h2>



<p class="wp-block-paragraph">LightRAG can handle simple queries, but <strong>it lacks chat history</strong>, a <strong>system prompt</strong> (although it seems to have a “User Prompt” setting, it didn’t work for me), and other tools needed to properly manage a complete automation pipeline.</p>



<p class="wp-block-paragraph">With N8N, we can implement the ideal <strong>orchestration mechanisms</strong> to fully unleash LightRAG’s search capabilities. We will set up <strong>a basic AI agent that includes a “LightRAG Tool”,</strong> which it can use to perform searches while generating more thoughtful responses that are also aligned with a custom system prompt.</p>



<h2 class="wp-block-heading">Installing the LightRAG Tool</h2>



<p class="wp-block-paragraph">There is not an official node for interacting with LightRAG. Fortunately, there is a contributed one: <a href="https://www.npmjs.com/package/n8n-nodes-lightrag">n8n-nodes-lightrag</a>, that will allow us connecting an AI agent with our LightRAG instance.</p>



<p class="wp-block-paragraph">Go to settings, in the bottom left corner, under the three points button:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="305" height="294" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-5.png" alt="" class="wp-image-2384" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-5.png 305w, https://www.victordorado.es/wp-content/uploads/2025/08/image-5-300x289.png 300w" sizes="(max-width: 305px) 100vw, 305px" /></figure>



<p class="wp-block-paragraph">In the next screen, go to &#8220;Community Nodes&#8221; and install it:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="488" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-6-1024x488.png" alt="" class="wp-image-2385" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-6-1024x488.png 1024w, https://www.victordorado.es/wp-content/uploads/2025/08/image-6-300x143.png 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-6-768x366.png 768w, https://www.victordorado.es/wp-content/uploads/2025/08/image-6.png 1056w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Creating our AI Agent</h2>



<p class="wp-block-paragraph">Now it&#8217;s finally time to create our AI Agent. We will use an OpenAI Model with <code>gpt-4.1-mini</code> configured, a simple memory node, and our LightRAG Tool</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="661" height="500" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-7.png" alt="" class="wp-image-2386" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-7.png 661w, https://www.victordorado.es/wp-content/uploads/2025/08/image-7-300x227.png 300w" sizes="(max-width: 661px) 100vw, 661px" /></figure>



<p class="wp-block-paragraph">For our system prompt, we will use simple instructions:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>You are an information assistant on Urban Mobility in Logroño, designed to answer user questions based on municipal regulations.

Retrieve relevant information and provide a concise, precise, and informative response to the user’s question. To do so, always use the "Light Rag Query" tool to fetch information from the company’s corpus, which is hosted on a LightRAG server. You should ask the tool any questions you deem necessary, including multiple queries if needed.

This tool will always return an answer along with the references used, for example:

------------------------------
Question:
Tell me in which cases wearing a helmet is required.

Answer:
Wearing a helmet is mandatory in several cases according to the regulations… etc.
References
&#91;KG&#93; certified helmet
&#91;KG&#93; certified helmet – motorcycles
&#91;DC&#93; MOBILITY-ORDINANCE-2019.pdf
------------------------------

A &#91;KG&#93; reference means it was obtained from the Knowledge Graph and can be either:

 - &#91;KG&#93; entity: A single entity
 - &#91;KG&#93; entity1 – entity2: A relationship between entity1 and entity2

A &#91;DC&#93; reference means it was obtained from text chunks in documents:

 - &#91;DC&#93; document name

However, you should not provide the references used unless explicitly asked for them.

If the answer cannot be found using the "Light Rag Query" tool, respond with:
"I cannot find the answer in the available resources."</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #d8dee9ff">You are an information assistant on Urban Mobility in Logroño, designed to answer user questions based on municipal regulations.</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff">Retrieve relevant information and provide a concise, precise, and informative response to the user’s question. To do so, always use the &quot;Light Rag Query&quot; tool to fetch information from the company’s corpus, which is hosted on a LightRAG server. You should ask the tool any questions you deem necessary, including multiple queries if needed.</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff">This tool will always return an answer along with the references used, for example:</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff">------------------------------</span></span>
<span class="line"><span style="color: #d8dee9ff">Question:</span></span>
<span class="line"><span style="color: #d8dee9ff">Tell me in which cases wearing a helmet is required.</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff">Answer:</span></span>
<span class="line"><span style="color: #d8dee9ff">Wearing a helmet is mandatory in several cases according to the regulations… etc.</span></span>
<span class="line"><span style="color: #d8dee9ff">References</span></span>
<span class="line"><span style="color: #d8dee9ff">&#91;KG&#93; certified helmet</span></span>
<span class="line"><span style="color: #d8dee9ff">&#91;KG&#93; certified helmet – motorcycles</span></span>
<span class="line"><span style="color: #d8dee9ff">&#91;DC&#93; MOBILITY-ORDINANCE-2019.pdf</span></span>
<span class="line"><span style="color: #d8dee9ff">------------------------------</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff">A &#91;KG&#93; reference means it was obtained from the Knowledge Graph and can be either:</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff"> - &#91;KG&#93; entity: A single entity</span></span>
<span class="line"><span style="color: #d8dee9ff"> - &#91;KG&#93; entity1 – entity2: A relationship between entity1 and entity2</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff">A &#91;DC&#93; reference means it was obtained from text chunks in documents:</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff"> - &#91;DC&#93; document name</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff">However, you should not provide the references used unless explicitly asked for them.</span></span>
<span class="line"><span style="color: #d8dee9ff"></span></span>
<span class="line"><span style="color: #d8dee9ff">If the answer cannot be found using the &quot;Light Rag Query&quot; tool, respond with:</span></span>
<span class="line"><span style="color: #d8dee9ff">&quot;I cannot find the answer in the available resources.&quot;</span></span></code></pre></div>



<p class="wp-block-paragraph">We must also configure the LightRAG Tool. First, configure the URL where N8N can access the lightRAG server. As we have a Docker internal network, every container is seen by  the others by its name, in our case &#8220;lightrag&#8221;.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="704" height="444" src="https://www.victordorado.es/wp-content/uploads/2025/08/Captura-desde-2025-08-25-10-45-27.png" alt="" class="wp-image-2387" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/Captura-desde-2025-08-25-10-45-27.png 704w, https://www.victordorado.es/wp-content/uploads/2025/08/Captura-desde-2025-08-25-10-45-27-300x189.png 300w" sizes="(max-width: 704px) 100vw, 704px" /></figure>



<p class="wp-block-paragraph">Then, configure the query to be provided by the model, the &#8220;mix&#8221; strategy and enable reranking:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="513" height="665" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-8.png" alt="" class="wp-image-2388" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-8.png 513w, https://www.victordorado.es/wp-content/uploads/2025/08/image-8-231x300.png 231w" sizes="(max-width: 513px) 100vw, 513px" /></figure>



<p class="wp-block-paragraph">You can try out the different modes to observe their differences. For more details, refer to <a href="https://github.com/HKUDS/LightRAG?tab=readme-ov-file#query-param">the LightRAG documentation</a>.</p>



<h2 class="wp-block-heading">Evaluating our agent</h2>



<p class="wp-block-paragraph">Finally, we can open a chat session with our agent and ask any question. For example:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph"></p>
</blockquote>



<p class="wp-block-paragraph">Our AI Agent will start processing the request:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="649" height="493" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-9.png" alt="" class="wp-image-2389" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-9.png 649w, https://www.victordorado.es/wp-content/uploads/2025/08/image-9-300x228.png 300w" sizes="(max-width: 649px) 100vw, 649px" /></figure>



<p class="wp-block-paragraph">We inmediately receive a response, and we can check out the execution process, as it is logged.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="770" height="432" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-10.png" alt="" class="wp-image-2390" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-10.png 770w, https://www.victordorado.es/wp-content/uploads/2025/08/image-10-300x168.png 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-10-768x431.png 768w" sizes="(max-width: 770px) 100vw, 770px" /></figure>



<p class="wp-block-paragraph">This is the query that our agent sent to LightRAG, and its response:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="552" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-12-1024x552.png" alt="" class="wp-image-2392" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-12-1024x552.png 1024w, https://www.victordorado.es/wp-content/uploads/2025/08/image-12-300x162.png 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-12-768x414.png 768w, https://www.victordorado.es/wp-content/uploads/2025/08/image-12.png 1213w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">We can see that the response is quite similar to the one provided by LightRAG, but this was a relatively simple question. We could instruct our agent to query LightRAG more effectively, respond in a more informal tone, consult other information sources, or even perform actions.</p>



<p class="wp-block-paragraph">Let&#8217;s try a more complicated question:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="475" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-13-1024x475.png" alt="" class="wp-image-2394" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-13-1024x475.png 1024w, https://www.victordorado.es/wp-content/uploads/2025/08/image-13-300x139.png 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-13-768x356.png 768w, https://www.victordorado.es/wp-content/uploads/2025/08/image-13.png 1059w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="456" src="https://www.victordorado.es/wp-content/uploads/2025/08/image-14-1024x456.png" alt="" class="wp-image-2395" srcset="https://www.victordorado.es/wp-content/uploads/2025/08/image-14-1024x456.png 1024w, https://www.victordorado.es/wp-content/uploads/2025/08/image-14-300x134.png 300w, https://www.victordorado.es/wp-content/uploads/2025/08/image-14-768x342.png 768w, https://www.victordorado.es/wp-content/uploads/2025/08/image-14.png 1243w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">We can observe how the agent synthesizes the information. It adds another layer of abstraction, allowing it to emphasize certain aspects of the information provided by LightRAG.</p>



<p class="wp-block-paragraph">However, this example still doesn’t add much beyond simple LightRAG queries. But keep in mind that, with N8N, the possibilities are vast: for instance, we could equip the agent with a weather tool that checks today’s conditions and advises the user on any precautions they should take.</p>



<div class="wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-3919067" id="conclusion" data-block-id="3919067"><h2 class="stk-block-heading__text">Conclusion</h2></div>



<p class="wp-block-paragraph"><strong>LightRAG represents a significant advancement</strong> in the field of Retrieval-Augmented Generation. It outperforms traditional or “naive” RAG solutions by combining <strong>efficient knowledge retrieval with contextual reasoning</strong>, all while maintaining a moderate token cost. This makes it a powerful tool for building intelligent, scalable, and cost-effective information systems.</p>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://www.victordorado.es/2025/08/25/supercharging-rag-information-retrieval-with-n8n-and-lightrag/">Supercharging RAG Information Retrieval with N8N and LightRAG</a> appeared first on <a href="https://www.victordorado.es">Víctor Dorado</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.victordorado.es/2025/08/25/supercharging-rag-information-retrieval-with-n8n-and-lightrag/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
