Contextual Retrieval RAG System with Kimi-K2, Gemini, and Qdrant - n8n Workflow

Build advanced RAG using contextual summaries. This n8n workflow leverages Kimi-K2 via Featherless.ai for unlimited tokens, Gemini embeddings, and Qdrant vector database storage.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers building high-accuracy RAG systems requiring contextual document chunking.
Users seeking cost-effective, high-volume LLM inference solutions using Featherless.ai in an n8n workflow.
Engineers needing robust document processing and vectorization solutions within n8n templates.
Anyone looking to implement advanced AI agents utilizing the Qdrant n8n node and Gemini embeddings.

Overview

Traditional Retrieval-Augmented Generation (RAG) implementations often suffer from poor retrieval accuracy when dealing with long, complex documents because simple text chunking loses vital contextual information like surrounding headings or related paragraphs. This advanced n8n workflow solves that limitation by implementing Contextual Summaries.

This n8n template uses the Kimi-K2 model (accessed via the Featherless.ai n8n node, ideal for token-intensive tasks due to its unlimited token pricing model) to analyze each page chunk along with its immediate surrounding context. It generates succinct summaries, titles, and comprehensive keywords. These rich metadata fields are then vectorized using the high-performance Gemini-Embeddings-001 model—configured via a specific HTTP Request n8n node to ensure precise control over dimensionality and task type—and stored in a Qdrant vector database. This powerful n8n workflow drastically improves retrieval relevance compared to standard RAG pipelines.

How it Works

This comprehensive n8n workflow executes in three main phases: Ingestion, Vectorization, and Application.


  1. Ingestion & Preprocessing: The process begins with the manual n8n trigger, which first downloads the large source document (e.g., the UK Highway Code PDF). The Extract from File n8n node pulls the text, and the Split Pages n8n node separates the document into individual chunks for sequential processing.

  2. Contextual Summarization: For each chunk, the Featherless.ai n8n node is invoked with the Kimi-K2 model. The prompt carefully references adjacent chunks to generate a context-aware summary, title, and exhaustive list of keywords. A subsequent Set n8n node then parses this structured LLM response into distinct data fields.

  3. Vectorization & Storage: Initial setup uses Qdrant n8n node steps to ensure the target collection (highwaycode) and a full-text index on the contextual summary payload exist. Next, the n8n workflow uses an HTTP Request n8n node to call the Google Gemini API, generating a high-quality 768-dimensional vector embedding for the contextual summary. Finally, the Add Docs To Qdrant Vector Store n8n node upserts the original chunk, the generated summary, page number, and the newly created vector into Qdrant.

  4. Application (Subworkflow Tool): A Subworkflow Trigger defines the reusable retrieval tool. When called with a query, it generates a new Gemini embedding for that query and performs a similarity search via the Qdrant n8n node, returning the most relevant contextual chunks. This subworkflow demonstrates how to build robust n8n templates for advanced RAG systems, which can be easily consumed by AI Agents or MCP Servers.

Installation Guide

To deploy and utilize this advanced n8n workflow, follow these setup instructions:


  1. Import Workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' feature.

  2. Credential Configuration: This n8n workflow requires three distinct credentials:

Featherless.ai: Set up API key credentials for the Featherless.ai n8n node used for Kimi-K2 inference.
Google Gemini (PaLM) API: Configure credentials for the HTTP Request n8n node steps responsible for generating Gemini embeddings.
* Qdrant: Set up the Qdrant Rest API credentials pointing to your running Qdrant vector store instance.

  1. Initial Run: Once credentials are set, execute the primary n8n trigger (When clicking ‘Execute workflow’) to initiate the document download and populate your Qdrant collection. The workflow automatically handles the creation of the collection and payload indexes.

Node Details

When clicking ‘Execute workflow’ (n8n trigger): The manual execution starting point for the document ingestion process.
Download Large Document (HTTP Request n8n node): Downloads the large PDF file for processing.
Extract from File (n8n node): Performs the necessary operation to extract textual content from the PDF binary.
Split Pages (Split Out n8n node): Core flow control, splitting the document text into manageable, page-sized items for chunking, allowing the downstream Featherless.ai n8n node to process each piece.
Kimi-K2 via Featherless.ai (Featherless n8n node): Generates high-quality contextual summaries (context, title, keywords) for each document chunk, utilizing its surrounding text for maximum relevance.
Retrieval Vectors with Gemini Embeddings 001 (HTTP Request n8n node): Essential for generating the embedding vector. Key settings include model: models/gemini-embedding-001, tasktype: RETRIEVALDOCUMENT, and output_dimensionality: 768 to ensure optimal performance for document retrieval.
Add Docs To Qdrant Vector Store (Qdrant n8n node): Responsible for persisting the contextually enhanced document chunks and their associated Gemini vectors into the Qdrant store.
Subworkflow Trigger (n8n trigger): Defines the entry point for the reusable RAG query logic, allowing other n8n templates and agents to utilize the generated knowledge base.


  • Query Docs from Qdrant Vector Store (Qdrant n8n node): Executes the similarity search using the query embedding vector generated by the previous n8n node, retrieving relevant source material.

Related n8n Workflows

Free

Nodes: 17 Nodes
Updated: December 26 2025
View all
Created by

Freelance AI Automation Engineer based in London, UK. Since 2024, my n8n templates have documented my journey into applied AI and have helped hundreds of businesses and organisations get up to speed with AI automation. Today, I continue to explore use-cases as AI evolves and occasionally upload templates which I find novel and interesting. Subscribe to the RSS Feed: https://cdn.subworkflow.ai/n8n-templates/rss.xml

Featured*