N8n - RAG, Verctor Store and Prompting: AI Agent won't check the Database

Describe the problem/error/question

Hello everyone, I need your help.

I’ve only been working with LLMs for three weeks and would like to extend an existing LLM with RAG functionality. The whole thing is run locally.

Inspired by Philip Thomas’ tutorial (https://www.youtube.com/watch?v=3XRRxUTVszU), I have set up a local Docker instance running Ollama, n8n and the Vector Store Qdrant.

Test data is stored in the Vector Store via an n8n import workflow and can be accessed using a query.

I had great difficulty getting the LLM to always use the Vector Store as its primary knowledge source. After hours of work, I was able to get the LLMs gpt-oss:20b and mistral-small:24b to process the extended test data from Dani California LLC with virtually no errors.

I have attached an overview of the test cases as image below.

Since my 16 GB GPU already struggles with these two models, I would like to use a slightly smaller LLM, but apart from qwen3:14b, the success has been rather modest.

I strongly suspect that the problem lies with my prompts. I tried the whole thing with English and German prompts. The fact that the LLM uses the vector store as its sole source of knowledge also seems to be heavily dependent on prompting and the LLM.

How can I optimise prompting so that other LLMs have a higher hit rate and the Vector Store is always used as the sole source of knowledge?

Thank you for your help.

  • Sotares

n8n-Workflow

Dani California LLC

Dani California LLC

Kontaktdaten
Blue Junction 45
CA-74774 Paolo Alto
Phone: 7745-69856-2138
E-Mail: [email protected]
Web: http://www.dani-california.com

Unternehmensstandorte
New York, New York, USA
Los Angeles, Kalifornien, USA
San Francisco, Kalifornien, USA
Hamburg, Deutschland
Berlin, Deutschland
Munich, Deutschland
Bangkok, Thailand

Preisliste
Consulting: 100€ pro angefangener 15 Minuten
Betreuung monatlich je nach Umfang ab 5.000€

Team
CEO; Hank Moody
CFO: Stu Beggs
COO: Eddie Nero
CMO: Charlie Runkle
HR: Lisa Gerald

Dienstleistungen
Softwareentwicklung & Web
- Web-Entwicklung: Erstellung maßgeschneiderter Websites und Webanwendungen.
- Mobile App-Entwicklung: Konzeption und Programmierung von Apps für iOS und
Android.
- Cloud-Lösungen: Migration und Management von Daten und Anwendungen in
Cloud-Umgebungen (z. B. AWS, Azure).
- Datenbank-Management: Aufbau, Optimierung und Wartung von SQL- und
NoSQL-Datenbanken.
- Software-Audits: Überprüfung bestehender Software auf Sicherheit, Effizienz
und Performance.
- E-Commerce-Lösungen: Einrichtung und Anpassung von Online-Shops (z. B.
Shopify, Magento).
- KI- und Machine Learning-Anwendungen: Entwicklung von intelligenten Systemen
und Algorithmen.
- IT-Projektmanagement: Begleitung von IT-Projekten von der Planung bis zur
Umsetzung.

Hardware & Infrastruktur
- PC-Reparatur und Wartung: Fehlerdiagnose, Reparatur und Instandhaltung von
Desktop-Computern.
- Laptop-Reparatur und Wartung: Serviceleistungen für Laptops, inklusive
Display- und Akkutausch.
- Server-Installation & -Wartung: Aufbau und Betreuung von physischen und
virtuellen Servern.- Netzwerk-Konfiguration: Planung und Einrichtung von Heim- und Firmennetzwerken
(LAN, WLAN).
- Datenrettung: Wiederherstellung von Daten von defekten Festplatten oder
Speichermedien.
- Hardware-Upgrades: Aufrüstung von PCs und Laptops (z. B. RAM, SSD,
Grafikkarten).
- Systemintegration: Zusammenführung verschiedener Hard- und Softwarekomponenten
zu einem funktionierenden System.

Sicherheit & Support
- Cybersecurity-Beratung: Analyse von Sicherheitsrisiken und Erstellung von
Sicherheitskonzepten.
- Virenentfernung & Malware-Schutz: Bereinigung infizierter Systeme und
Installation von Schutzsoftware.
- Backup-Lösungen: Einrichtung automatischer Datensicherungen (lokal und in der
Cloud).
- IT-Support (vor Ort & remote): Technische Unterstützung bei Hard- und
Softwareproblemen.
- Schulungen für Endnutzer: Seminare zur sicheren und effizienten Nutzung von
Computern und Software.
- Firewall-Konfiguration: Einrichtung und Pflege von Firewalls zum Schutz des
Netzwerks.

Beratung & Sonstiges
- IT-Strategieberatung: Entwicklung langfristiger IT-Pläne für Unternehmen.
- Gerätekaufberatung: Empfehlung und Beschaffung der passenden Hardware für
individuelle Bedürfnisse.
- Lizenzmanagement: Verwaltung von Softwarelizenzen und Compliance-Prüfungen.
- Virtualisierungslösungen: Einrichtung virtueller Maschinen zur Optimierung der
Systemressourcen.
- Monitoring von IT-Systemen: Überwachung der Systemleistung und Fehlererkennung
in Echtzeit.
- Automatisierung von Geschäftsprozessen: Implementierung von Skripten und Tools
zur Arbeitserleichterung.
- E-Mail-Server-Management: Einrichtung und Wartung von professionellen
E-Mail-Systemen.
- Voice-over-IP (VoIP)-Lösungen: Installation und Konfiguration von
internetbasierten Telefonanlagen.
- Game-Server-Hosting: Bereitstellung und Wartung von Servern für
Multiplayer-Spiele.

Test cases

Testing questions:

Wer ist der CEO von Dani California LLC?

Zeige mir nur die Standorte der Dani LLC an, die in Deutschland sind.

Wer arbeitet bei der Dani LLC im HR?

Liste das Team von Dani LLC auf.

Zeige mir die Kontaktdaten von Dani LLC.

Bietet Dani LLC Dienstleistungen im Bereich Sicherheit oder Firewall Konfigurationen an?

Welche Preise hat Dani LLC?

Liste mir die Standorte der Dani LLC auf und sortiere das Ergebnis nach Länder.

Was kosten mich 75 Minuten Consulting Dienstleistung bei der Dani LLC?

Gebe die E-Mail Adresse von Dani LLC aus und entferne das "@" durch [at] und ersetze "." durch [dot].

Information on your n8n setup

  • n8n version: 1.111.0
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Win 11

The only way to convince LLM to use your vector store is to instruct it to do so. There is no other way. You have to explicitly tell it to: “always use X tool to get information” or similar wording is what it takes to make it use VS each time.

Similar constructs include:

  • “You must always use the <tool> to retrieve information before answering.”
  • “Never rely on your own knowledge. Always ground your response exclusively on the results from <tool>.”
  • “If <tool> is unavailable, respond with: Unable to retrieve data.”
  • “Do not answer from memory.”
  • “Do not invent or assume information. Only include facts retrieved via <tool>.”
  • “You are not allowed to use general knowledge.”

in the role description:

  • “You are a retrieval-only assistant. Your role is to act as an interface to <vector store>.”
  • “Behave like a librarian: you never answer questions directly, you only report what is in the library.”

then in the process instructions:

  • Query the <vector store> with the user’s input.
  • Use only the retrieved results to form the answer.”
1 Like

The key difference with smaller models is they need much more explicit instruction and can’t infer RAG behavior as well as larger models.

Here’s an example prompt from me too:

You are an expert assistant with access to a specialized knowledge database through the vector store tool.

CRITICAL RULES:
1. ALWAYS use the vector store tool to search for relevant information before answering
2. Base your answer ONLY on information retrieved from the vector store
3. If the vector store doesn't contain relevant information, clearly state "I cannot find this information in my knowledge base"
4. Do NOT use your general training knowledge or make assumptions beyond the retrieved data

WORKFLOW:
1. First, search the vector store for information related to the user's question
2. Review all retrieved documents carefully  
3. Formulate your answer using ONLY the information from those documents
4. If multiple searches are needed for complex questions, perform them systematically

RESPONSE FORMAT:
- Provide direct answers based on retrieved information
- Cite specific details from the knowledge base when possible
- If information is incomplete, say what you found and what's missing
- Never supplement with training data or external knowledge

1 Like

Hi @jabbson, thank you for the hints.

Queries are much better with using the name of the n8n vectore store node.

Sotares

1 Like

Glad it was helpful.

If the answer was helpful, kindly mark the answer as Solution.
Cheers!

Hi @krisn0x, thank you for this example.

I have still lot issues to fetching the vector store.

Should I really use the numbering? I feel that recognition is better without it.

I will conduct further tests, the whole thing is very interesting :sweat_smile:

Sotares

Nah, numbering is not mandatory at all