Overview
This master class provides a hands-on guide to building robust Retrieval-Augmented Generation (RAG) systems using N8N, covering everything from simple setups to advanced workflows with no code and light coding, including ingestion pipelines, metadata filtering, hybrid search, reranking, and contextual retrieval.
Course Introduction & Structure
- The course is practical and project-focused, structured into 7 lessons from beginner to advanced.
- Early lessons are fully no-code; advanced sections involve some basic coding.
- Solutions are built step-by-step, covering core RAG concepts as you build.
- By the end, you will have a full RAG pipeline with document ingestion, vector storage, and advanced retrieval.
Basic RAG Agent Setup
- Notebook LM and OpenAI’s Assistant used to demonstrate foundational RAG: uploading docs, asking questions, and observing grounded answers.
- Emphasizes the importance of LLMs answering strictly from provided context, avoiding hallucinations.
- Set system prompts to instruct agents to only answer from uploaded data or respond with “Sorry I don’t know”.
Document Ingestion & Vector Store
- Ingest documents using chunking (breaking them into smaller parts) for better retrieval.
- Use OpenAI’s embedding models to convert text chunks into numerical vectors.
- Store vectors in-memory (simple store) for quick tests or in persistent stores like Supabase for production.
- Metadata (e.g., file name, category) added to chunks for improved filtering and search.
Record Manager & Deduplication
- Implement a record manager in Supabase to track uploaded documents by unique hash and file ID.
- Prevent duplicates by checking for existing hashes—on changes, remove old vectors and upsert new ones.
Supporting Multiple File Types & OCR
- Adapt the pipeline to handle PDFs, Google Docs, HTML, and scanned documents (using Mistral OCR for non-machine-readable files).
- Normalize text extraction and hash generation across formats for consistency.
- Add logic to trigger OCR when extracted text is insufficient (e.g., scanned PDFs).
Data Deletion & Automation
- Add deletion logic: files deleted from a designated “recycling bin” folder will trigger vector and record deletion in Supabase.
- Files moved to a “processed” folder after ingestion for organization.
Metadata & Filtering
- Attach relevant metadata (category, summary, file type) using LLM-generated summaries or manual fields.
- Use metadata filters in queries for more precise, context-aware retrieval (e.g., filter by motorsport category).
Web Scraping Integration
- Use Firecrawl to scrape web content and ingest it into the RAG pipeline, treating web pages like other documents.
- Set up webhook triggers to handle crawled data and automate ingestion on a schedule.
Advanced Retrieval: Hybrid Search, Reranking, Contextual Retrieval
- Hybrid Search: Combine keyword (full text) and semantic (vector) search using reciprocal rank fusion via custom Supabase functions.
- Reranking: Use Cohere’s re-ranking model to order search results by relevance, not just similarity.
- Contextual Retrieval: Generate context blurbs for each chunk using LLMs (prompt caching recommended to save costs and improve performance).
Key Terms & Definitions
- RAG (Retrieval-Augmented Generation) — LLMs that ground answers in external, user-provided data.
- Vector Store — Database holding semantic vector representations of document chunks.
- Chunking — Splitting documents into smaller segments for indexing.
- Embedding — Numeric representation of text for similarity search.
- Metadata Filtering — Restricting results based on extra attributes like category or author.
- Hybrid Search — Combining semantic and keyword search for better retrieval.
- Reranking — Ordering retrieved chunks by relevance using AI models.
- Contextual Retrieval — Adding document context to each chunk for more accurate responses.
Action Items / Next Steps
- Build out each workflow step as demonstrated, using your own documents for testing.
- Experiment with chunk size, overlap, and retrieval settings to optimize answers.
- Extend metadata fields and filters to support your specific use case.
- Review advanced techniques (hybrid search, reranking, contextual retrieval) and integrate as needed.
- Explore the AI Automators community for downloadable workflows and further resources.
- Complete suggested readings and bookmark video for reference.