n8n Assignment Report: Chatmate
Course: GenAI Assignment: 1 Date: 2025-11-25
1. Workflow Overview
This project implements a “Chatmate” system using n8n, which allows users to interactively query a PDF document (“Attention Is All You Need”). The system is built on a Retrieval-Augmented Generation (RAG) architecture, utilizing Supabase for vector storage and Groq for LLM inference.
The workflow consists of two distinct flows:
- Document Ingestion Flow: Handles the loading, text extraction, embedding generation, and storage of the PDF content.
- Conversational Retrieval Flow: Handles user queries, retrieves relevant context from the vector store, and generates answers using the LLM.
2. Node Configuration & Implementation Details
Flow 1: Document Ingestion
This flow is designed to be run once to populate the vector database.
- Trigger:
Manual Trigger(“When clicking Execute Workflow”) - Initiates the ingestion process manually. - Read File:
Read/Write Files from Disk- Reads the PDF file from the local file system.- Path:
/media/2tbhdd/LinuxFiles/SanctuaryObs/Sanctuary/University/WiSe25/GenAI/Ass/n8n/Attention_Is_All_You_Need.pdf
- Path:
- Text Extraction:
Extract Text(PDF Parser) - Extracts raw text content from the binary PDF data. - Embeddings:
HuggingFace Inference- Generates vector embeddings for the extracted text chunks.- Model:
sentence-transformers/distilbert-base-nli-mean-token - Output Dimension: 768
- Model:
- Vector Storage:
Supabase Vector Store- Inserts the text chunks and their corresponding embeddings into the Supabasedocumentstable.
Flow 2: Conversational Retrieval
This flow runs for every user interaction in the chat interface.
- Trigger:
Chat Trigger(“When chat message received”) - Captures the user’s input from the chat UI. - Orchestrator:
AI Agent- The central node that manages the conversation flow, calls tools, and invokes the LLM.- System Prompt: Configured to act as a helpful assistant answering based on the provided context.
- LLM:
Groq Chat Model- Provides the reasoning and generation capabilities.- Model:
llama3-8b-8192(Selected for speed and performance).
- Model:
- Retrieval Tool:
Supabase Vector Store- Connected as a tool to the AI Agent. It allows the agent to perform semantic searches against the stored PDF content to find relevant information. - Memory:
Simple Memory(Window Buffer) - Maintains the context of the conversation, allowing for follow-up questions.
3. Challenges & Solutions
- Challenge: Ensuring the PDF was accessible to the n8n instance (Docker container).
- Solution: I ensured the file path was correctly mounted and accessible. In a real Docker setup, I would use a bind mount (e.g.,
-v /local/path:/n8n/path) to map the local directory to the container’s file system.
- Solution: I ensured the file path was correctly mounted and accessible. In a real Docker setup, I would use a bind mount (e.g.,
- Challenge: Selecting the right embedding model.
- Solution: I used
sentence-transformers/distilbert-base-nli-mean-tokenas recommended, which offers a good balance between performance and embedding quality for general English text.
- Solution: I used
- Challenge: Configuring the Supabase connection.
- Solution: I ensured the table schema in Supabase matched the expected format (id, content, metadata, embedding) and that the vector extension was enabled (
create extension vector;).
- Solution: I ensured the table schema in Supabase matched the expected format (id, content, metadata, embedding) and that the vector extension was enabled (
4. Conclusion
The implemented workflow successfully demonstrates a RAG pipeline. The separation of ingestion and retrieval allows for efficient querying, as the heavy lifting of processing the document is done only once. The use of Groq ensures low-latency responses, making the chat experience smooth and interactive.