Adaptive RAG strategy with query classification retrieval Gem
This n8n workflow implements a version of the Adaptive Retrieval-Augmented Generation (RAG) framework. It recognizes that the best way to retrieve informatio...
🔌 Nodes & Integrations Used (8)
📖 Implementation & Setup Guide
This n8n workflow implements a version of the Adaptive Retrieval-Augmented Generation (RAG) framework. It recognizes that the best way to retrieve information often depends on the type of question asked. Instead of a one-size-fits-all approach, this workflow adapts its strategy based on the user's query intent.
🌟 How it Works
- **Receive Query:** Takes a user query as input (along with context like a chat session ID and Vector Store collection ID if used as sub-workflow).
- **Classify Query:** First, the workflow classifies the query into a predefined category. This template uses four examples:
- * **Factual:** For specific facts.
- * **Analytical:** For deeper explanations or comparisons.
- * **Opinion:** For subjective viewpoints.
- * **Contextual:** For questions relying on specific background.
- **Select & Adapt Strategy:** Based on the classification, it selects a corresponding strategy to prepare for information retrieval. The example strategies aim to:
- * *Factual:* Refine the query for precision.
- * *Analytical:* Break the query into sub-questions for broad coverage.
- * *Opinion:* Identify different viewpoints to look for.
- * *Contextual:* Incorporate implied or user-specific context.
- **Retrieve Info:** Uses the output of the selected strategy to search the specified knowledge base (Qdrant vector store - change as needed) for relevant documents.
- **Generate Response:** Constructs a response using the retrieved documents, guided by a prompt tailored to the original query type.
By adapting the retrieval strategy, this workflow aims to provide more relevant results tailored to the user's intent.
⚙️ Usage & Flexibility
* **Sub-Workflow:** Designed to be called from other n8n workflows, passing `user_query`, `chat_memory_key`, and `vector_store_id` as inputs. * **Chat Testing:** Can also be triggered directly via the n8n Chat interface for easy testing and interaction. * **Customizable Framework:** The query categories (Factual, Analytical, etc.) and the associated retrieval strategies are examples. You can modify or replace them entirely to fit your specific domain or requirements.
🛠️ Requirements
* **Credentials:** You will need API credentials configured in your n8n instance for: * Google Gemini (AI Models) * Qdrant (Vector Store)
⚡ How to import this workflow into n8n:
- Click the Direct Download JSON button above to save
Adaptive_RAG_strategy_with_query_classification_retrieval_Gem.json. - Log in to your n8n Cloud or self-hosted n8n instance.
- In your workflow canvas, click the menu in top-right and select Import from File (or paste the JSON directly).
- Configure your credentials (e.g. API keys, database URLs) in the corresponding node settings.
- Click Execute Workflow to test and switch to Active!
Related AI Agents Workflows
View All in AI Agents →5 ways to process images PDFs with Gemini AI in n8n
How it works Many users have asked in the support forum about different methods to analyze images and PDF documents with Google Gemini AI in n8n. This workfl...
7 AI Sales Assistant
Production-ready n8n automation template for 7 AI Sales Assistant built by AhiXLight. Seamlessly connects Airtop Tool, Slack, Airtop with 24 configured nodes.
AAVE portfolio professional AI agent Telegram Email GPT 4o
A next-generation AI-powered DeFi health monitor that tracks wallet positions across Aave V3 using GPT-4o and LangChain. It delivers human-readable reports v...
Access control for AI agents RBAC using Airtable and Telegram
Purpose This workflow allows granular control over the access to tools connected to AI Agents (including Multi-Agent setups) using Role Based Access Control....