Library / RAG & Knowledge Bases
RAG & Knowledge Bases
Build a Google Drive document similarity database with Ollama and Postgres
When a chat message arrives, it answers questions from your own knowledge base with Ollama using Chat, Ollama, PGVector, Google Drive.
What it does
## AI-Powered Duplicate Checker & Internal Linking Assistant ### Process source documents to analyze semantic similarity and interactively query vector datasets for internal linking opportunities. This complete workflow operates in two primary modes: batch pipeline processing and real-time interactive query handling. It scans a Google Drive directory for website page documents, parses the text content, and stores the records in Postgres. Using Ollama and PGVector, it segments text into semantic chunks and generates vector embeddings. The system builds an HNSW index to calculate page-level centroids and global similarity metrics to flag duplicate content. Concurrently, an interactive chat interface captures user search queries, vectorizes the input in real time, executes localized similarity calculations against the database, and compiles downloadable internal linking opportunity reports. ### Setup steps - Configure Google Drive credentials and set the source folder or directory used by the scan and download nodes. - Configure Postgres credentials and ensure the database has pgvector enabled plus the required scraped-pages, vector, similarity, and report tables. - Configure the Ollama embeddings node with a locally available embedding model and ensure the Ollama service is reachable from n8n. - Review the SQL in the cleanup, embedding, similarity, centroid, aggregation, and reporting nodes so table names, thresholds, and index definitions match your database schema. - Set or verify the document filter criteria, text extraction settings, chunking parameters, and export file formats before running the manual trigger. - Configure the n8n Chat Trigger and response nodes to establish interactive communication, routing pathways, and operational rule validation loops within the user interface. - Align the live text splitting settings and local embedding models with the ingestion phase parameters to ensure query vector compliance. - Verify live-query SQL scripts to ensure real-time distance computations target the correct temporary vector tables and document schemas. ### Requirements - Google Drive credentials - PostgreSQL database with pgvector and HNSW index support - Ollama service running local embedding models - Active n8n Chat Interface configuration
The steps
- Loop Source File
- GDrive Download Document
- Extract Raw Text Content
- Save Scraped Page Text
- Batches for Embedding
- Get Unprocessed Scraped Text
- Save Document Embeddings
- Generate Local Embeddings
- Context Injector
- Chunk Text Recursively
- Dedup Processed Items
- Clear Vector Table
- Clear Scraped Pages Table
- Scan Source Directory
56 steps in total.
Similar automations
RAG & Knowledge BasesEmbed Gmail Emails in PGVector with Ollama16 stepsRAG & Knowledge BasesCheck consent before pgvector indexing in Postgres with OpenAI and Slack21 stepsWeb Scraping & ResearchExtract Airline Check-in Details with Ollama into PGVector13 stepsRAG & Knowledge BasesAnswer support questions from your docs with Telegram, OpenRouter and pgvector28 steps