Skip to content

RAG Patterns

RAG = Retrieval-Augmented Generation. The LLM doesn't rely only on its training data — at query time, the system retrieves relevant context from your own data and injects it into the prompt.

This page catalogs every RAG variant used in the portfolio plus a few comparison patterns that aren't (yet) used. For where the embeddings live, see Vector-Databases.md. For the embedding-side primitives (chunking, reranking, BM25), see AI-Concepts.md.

Quick portfolio map

RAG Type Products Most common stack
HyDE RAG 12 products pgvector (or JSONB / MySQL JSON) + text-embedding-3-small
Basic / Naive RAG 4 products pgvector or MySQL JSON + text-embedding-3-small
Pipeline RAG 1 product (AI Concierge) Qdrant + text-embedding-3-small
Hybrid Search RAG 7 products Vector + Postgres full-text (RRF)
Reranked RAG 7 products HyDE + rerank step
Graph RAG 4 products Entity graph / Neo4j / graph-augmented indexing
Agentic RAG 6 products Tool-calling LLM
Multi-Type RAG 2 products (PoligoPro, HouseKey) Several indexes or RAG types per product
TF-IDF RAG 1 product (AutoDiag AI) TF-IDF + optional Pinecone
Enterprise RAG 2 products (OpenSentinel, Workflow Hub) pgvector, many strategies
Adaptive 3-Tier / BM25 RAG 0 products Not used; covered for comparison
No RAG 7 products n/a

The counts are per pattern; many products appear in several rows.


Naive RAG (a.k.a. Basic / Standard RAG)

What it is. The textbook three-step pipeline: embed the user query → look up the top-K most similar chunks in a vector DB → stuff those chunks into the LLM prompt as context.

Why we use it. Cheapest baseline. No reranker, no query rewriting. Good for narrow data sets where naive retrieval is "good enough."

Used in: - Toolbelt Handyman — pgvector (cosine <=>) + text-embedding-3-small; admin knowledge-base RAG indexed at container start. - APEX Sales Training — pgvector; chunking.service.ts + rag.service.ts as the full pipeline, with an admin "RAG Knowledge" dashboard. No HyDE is stated. - HouseKey — 1536-d JSON embeddings in MySQL with brute-force cosine in Node; rag.service.js + chunker.service.js, BullMQ ragQueue for indexing. - Jarvis (Tauri) — semantic memory recall rather than document RAG: memories.embedding vector(1536) in pgvector (text-embedding-3-small), cosine search with the <=> operator and a similarity threshold (db/memories.rs).

Tradeoffs. Misses synonyms ("invoice" vs "bill"). Misses paraphrased queries. Top-K is a blunt instrument — the right answer can be at rank 11. Upgrade paths in this doc: HyDE, hybrid search, reranking, agentic.


Pipeline RAG

What it is. A naming convention some teams use for naive RAG that emphasizes the ingestion pipeline (crawl → parse → chunk → embed → store) rather than the retrieval pipeline.

Used in: - AI Concierge — upload (pdf-parse, mammoth) or Crawlee CheerioCrawler → paragraph-aware chunking (≤80 words, source-name prefix) → embed → Qdrant. pnpm reindex after chunking changes. Retrieval is hybrid (see below) with source citations.

See also: Document-Processing.md for the ingestion side (PyMuPDF, Crawlee, etc.).


HyDE RAG (Hypothetical Document Embeddings)

What it is. Instead of embedding the user's question, you ask the LLM to write a hypothetical answer and embed that. The hypothetical answer is in the same shape as the documents you want to retrieve, so cosine similarity works much better.

Why we use it. Cheap (one extra LLM call), no model training, and dramatically improves recall when the query and the documents are written in different registers — e.g. "How do I cancel?" vs documents that say "Subscription termination procedure."

The trick. The hypothetical answer can be wrong; that doesn't matter, because you're only using its embedding. Final answers come from real retrieved docs.

Used in: - Workflow Hub — packages/rag, one of 16 retrieval strategies; pgvector. - Sourcing AI — HyDE → embed → vector search → re-rank → format context; sources are contracts, suppliers, RFQs, templates. - Marketing AI — ai-orchestrator RAG with HyDE, query rewrite, vector search and rerank. - GoGreen Seller AI — rag.service.ts: chunking, HyDE, pgvector search, re-ranking, LRU embedding cache; feeds the AI Copilot. - OpenSentinel — HyDE is one of its retrieval techniques (pgvector + full text). - SmartForms — sentence-boundary chunking → rag_documents (JSONB, no pgvector) → HyDE with gpt-4o-mini → cosine scoped by user_id / source_type → re-rank; reuses tenant field vocabulary in document-draft prompts. - Sell Me A Pen — hydeSearch over nine source types (product_catalog, sales_technique, objection_response, …); JSONB embeddings, no pgvector. - PoligoPro — HyDE in the Knowledge Base RAG store (pgvector). - VotigoPro — HyDE is one of the RagType strategies in RagRetriever.php; embeddings in a MySQL JSON column. - Tutor AI — rag.service.ts runs HyDE before retrieval over DocumentEmbedding (pgvector, text-embedding-3-small), with citations.

DOC-AI does not use HyDE.

Tradeoffs. Adds latency (the HyDE call itself) and a small token cost. The lowest-friction stacks (JSONB or MySQL JSON plus app-side cosine) work without installing pgvector.


Hybrid Search RAG

What it is. Run both dense vector search and sparse keyword search (BM25 / TF-IDF / full text), then merge the results. The classic merger is Reciprocal Rank Fusion (RRF) but custom weighted schemes are fine.

Why we use it. Dense embeddings miss exact strings (SKUs, error codes, names). Sparse search misses semantic matches. Hybrid fixes both blind spots.

Used in: - DOC-AI — Qdrant semantic search plus Postgres tsvector / ts_rank, merged by RRF. Embeddings: text-embedding-3-large (3072d). - AI Concierge — services/rag/hybrid.ts: vector + Postgres FTS merged with RRF; threshold 0.2, topK 5. - Workflow Hub — hybrid + RRF among its 16 strategies. - OpenSentinel — pgvector + a tsvector GIN column. - GGPI website — hybrid pgvector + full-text over the knowledge base; blog posts are synced into it. - VotigoPro — hybrid keyword + semantic scoring (not RRF-named). - Tutor AI — pgvector plus Postgres full-text search fused with RRF (k=60).


Reranked RAG

What it is. Retrieve a wide top-K cheaply, then run a smaller, more accurate reranker model — a cross-encoder, Cohere Rerank, BGE-reranker, or even an LLM with a "rate this doc" prompt — to re-order them and pass only the top 5–10 to the generator.

Why we use it. Bi-encoder embeddings are fast but lossy. Cross-encoders score (query, document) pairs jointly, which is much more accurate but too slow to run over millions of docs. The two-stage retrieve-then-rerank pattern gets near-cross-encoder quality at near-bi-encoder speed.

Variants in the portfolio: - LLM rerank — Sourcing AI (top-K 5 then rerank top-K 3, 2000 max context tokens, env-tunable). - Re-rank step inside HyDE pipelines — SmartForms, GoGreen Seller AI, Marketing AI. - Dedicated reranker module — OpenSentinel, Workflow Hub. - Heuristic metadata-boost re-rank (non-neural, not a cross-encoder) — Tutor AI.

Used in (products with explicit reranking): Workflow Hub, Sourcing AI, Marketing AI, GoGreen Seller AI, SmartForms, OpenSentinel, Tutor AI. DOC-AI does not rerank.

Tradeoffs. Adds a latency hop. LLM-as-reranker is the simplest to ship but expensive over many candidates — limit to top 20.


Adaptive / Tiered RAG (not used in portfolio)

What it is. The system decides which retrieval strategy to use per query, instead of running the same pipeline for every question.

Used in: Not used in the portfolio — covered for comparison. (The closest in-scope pieces are OpenSentinel's provider-aware router and VotigoPro's multiple RagType strategies, but neither classifies queries into tiers.)

Tradeoffs. Best for chat where most queries are trivial and only some need deep retrieval. The classifier itself has to be cheap — usually a small model or rules.


Graph RAG

What it is. Augment vector search with a knowledge graph. Entities and relationships extracted from documents become graph nodes/edges; retrieval traverses the graph to find connected facts, not just nearest neighbors. Strongly associated with Microsoft's GraphRAG paper (community detection + hierarchical summaries).

Why we use it. When answering requires connecting facts across documents (multi-hop reasoning), pure vector search loses.

Used in: - DOC-AI — three answer engines over one Qdrant collection. Default (OpenAI embeddings + Qdrant + Claude), LangChain (ChatAnthropic + FlatPayloadQdrantVectorStore, 5-turn client-supplied memory), and Graph RAG (entity-mention seeds, 1–2 hop traversal over entity_relationships in Postgres). Hybrid search merges Qdrant with Postgres tsvector by RRF; reviewer notes are embedded as kind: note. HyDE, re-ranking and an embedding cache are not implemented. The KB sees PII/PHI-masked text. - Workflow Hub — graph extraction and graph search in packages/rag. - OpenSentinel — graph retrieval, plus a Neo4j ecosystem graph. - Recruiting AI — BullMQ rag-graph queue for graph-augmented indexing.

Tradeoffs. Heaviest setup. Requires entity extraction (typically an LLM pass over every chunk). Worth it for document-heavy domains.


Agentic RAG

What it is. The LLM doesn't get a single retrieval — it gets tools (search, lookup, filter, fetch URL, query DB) and decides at runtime which to call, how often, and when it has enough to answer. Built on top of tool / function calling (see AI-Concepts.md).

Why we use it. Hard queries that need decomposition need several retrievals plus filtering, which a static pipeline can't do.

Used in: - AI Concierge — bounded 6-step tool loop: search_knowledge, capture_lead, book_appointment, hand_off_to_human, transfer_to_bot. - GGPI website — tool-calling chat loop: book_consultation, recall_contact, search_memory; ContactMemory "second brain" gives returning-caller context. - VotigoPro — "AI Brain" agentic RAG loop with 9 voting-specific tools (AiToolExecutor.php) plus a WizardStateMachine. - HouseKey — AI chat with 7 tools (search_properties, get_property_details, schedule_viewing, get_market_stats, contact_agent, list_agents, get_neighborhood_info), SSE streaming. - GoGreen Seller AI — AI Copilot with tools and a sub-agent manager. - Tutor AI — agenticChat.service.ts and agenticTools.service.ts: the tutor model calls retrieval tools, with a tutorOrchestrator and a critic agent checking answers.

Tradeoffs. Latency (multiple LLM calls per query) and tokens. Can loop forever if you don't cap iterations — AI Concierge's bounded 6-step loop is the right pattern.


Multi-Type RAG (parallel index pattern)

What it is. Multiple specialized RAG indexes co-exist; the router picks one (or fans out) per query. Different from Adaptive RAG: there it's the strategy that varies; here it's the corpus.

Used in: - PoligoPro — pgvector. Five stores/strategies in src/services/rag (plus a chunking utility): - Knowledge Base RAG (with HyDE) - Poll Data RAG - Agent Router RAG - Conversational Memory RAG (cross-session) - Vote Text RAG (open-ended feedback) - HouseKey — 16 RAG types (ids 1–11 from migration 021, 12–16 from migration 047); 53 docs / 69 chunks.

Tradeoffs. Excellent isolation (a poorly-formed FAQ doesn't pollute poll search) but every new corpus is more index plumbing.


TF-IDF RAG

What it is. Skip embeddings entirely. Use Term Frequency × Inverse Document Frequency vectors (essentially weighted word counts) and cosine similarity. The 1990s baseline.

Why anyone still uses it. Zero LLM dependency, runs on the CPU, perfect when documents and queries share vocabulary (technical / structured text). Useful as a fallback when embedding APIs are down.

Used in: - AutoDiag AI — LangChain RAG pipeline pairing TF-IDF with Pinecone semantic search (src/ai/rag/{langchain_rag,pinecone_store,pipeline,documents}.py). Pinecone is optional; embeddings fall back to HuggingFace or TF-IDF hashing. Repair-data aggregation (AllData, Mitchell1 ProDemand, Identifix) sits alongside.

Tradeoffs. No semantic understanding. "Auto" and "vehicle" are unrelated to it. Use for narrow technical corpora.


BM25 RAG (not used in portfolio)

What it is. Best Match 25 — the modern improvement over TF-IDF, used in Lucene/Elasticsearch/Solr. Adds saturation and document-length normalization. Sparse keyword retrieval with no embeddings.

Used in: Not used in the portfolio — covered for comparison. No in-scope product names BM25; the sparse half of its hybrid search is Postgres tsvector / ts_rank full-text (DOC-AI, AI Concierge, OpenSentinel).

Tradeoffs. Same as TF-IDF — no semantics. But faster to update incrementally (no embedding API call).


Enterprise RAG (multi-technique stack)

What it is. Internal name for "we do basically all of the above." Products that combine HyDE + hybrid search + reranking + query rewriting + multi-step + graph retrieval into one configurable pipeline.

Used in: - OpenSentinel — pgvector + text-embedding-3-small. HyDE, hybrid (pgvector + full text), reranker, graph retrieval, multi-step retrieval, retrieval cache and contextual query (src/core/memory). Also personal memory, a Neo4j ecosystem graph and markdown notes with wikilinks bridged into RAG. Other portfolio products integrate with it (Toolbelt Handyman, Workflow Hub, Sourcing AI, DOC-AI, Seller AI, AI Concierge, SmartForms, Sell Me A Pen, APEX, Recruiting AI, PoligoPro, VotigoPro). - Workflow Hub — packages/rag with 16 retrieval strategies (HyDE, hybrid + RRF, reranking, graph extraction and search, chunking, document classification, KB reindex, evaluation harness).

Tradeoffs. Most code to maintain. Worth it only when downstream products benefit from a single shared retrieval service.


Conversational / History-Aware RAG

What it is. Before retrieving, rewrite the user's latest message into a standalone query using the conversation history. "What about the next one?" → "What is the second item in the Q3 invoice list?" Then retrieve.

Used in (explicitly or as part of larger pipelines): OpenSentinel (contextual query), PoligoPro (Conversational Memory RAG), VotigoPro (Conversational strategy in RagRetriever.php), DOC-AI (LangChain engine, 5-turn client-supplied memory), GGPI website (ContactMemory).


Self-Querying RAG (not used in portfolio)

What it is. The LLM looks at the user's question and writes structured filter conditions for the vector DB itself: {"price": {"<": 50}, "category": "audio"}. The vector search runs filtered.

Why we'd add it. Products with structured metadata (for example HouseKey's property data) would let users say "show me three-bedrooms under $300k" and skip embedding the constraints altogether.


Multi-modal RAG (not used in portfolio yet)

What it is. Images and text share a joint embedding space (CLIP, SigLIP, OpenAI multimodal embeddings). Retrieve images by text query, or vice-versa.

Why we don't use it yet. DOC-AI OCRs scans via Claude vision and treats images as the text they extract. True multi-modal RAG would skip the OCR step. Candidate use case: SmartForms (form classification by visual layout; it already runs LayoutLMv3 layout detection).


Long-context "no RAG" (7 apps with no RAG)

What it is. With 200K+ context windows on current Claude and Gemini models, "just put the whole document in the prompt" is a real engineering option. No embeddings, no vector DB, no chunking.

Products with no RAG, no embeddings and no vector store: - SuperCabs — Anthropic-only; AI work is tool-endpoint style (internal assistant tools, LLM-based OCR). - BidIt — Anthropic-only; catalog search is Meilisearch, not vectors. - GameTrakker — no LLM at all. - Go Green Transit — no LLM at all. - Jarvis (Electron) — plain-JavaScript desktop app with no database, so no embeddings or vector store; it calls the LLM APIs directly. - Maximus Pet Store and Pecos River Traders — Laravel e-commerce; the multi-provider AiProviderService is chat-only (no embeddings, no retrieval); catalog search is structured MySQL queries.

GoGreen Verify is a borderline case: it injects a seeded forensic knowledge base into every AI prompt and its RAG is a client-side term-frequency hash; it has no embedding model and no vector column.

Tradeoffs. Token cost grows linearly with corpus size, latency grows quadratically (attention). Fine when the corpus is small enough to fit and you have no need for citation precision. Wrong choice once the corpus exceeds ~500K tokens or queries are sensitive to noise.


Quick selection guide

If you need… Pick this
Cheapest baseline, narrow data Naive RAG (pgvector + 3-small)
Better recall than naive, no infra change HyDE RAG
Don't lose exact terms (SKUs, codes) Hybrid (vector + full text, RRF)
Recall at scale, willing to spend a bit more Add a reranker
Multi-hop reasoning across documents Graph RAG
Hard queries needing decomposition Agentic RAG
Several distinct corpora that shouldn't bleed Multi-Type RAG
Tiny corpus, no embedding budget TF-IDF
Corpus < ~200K tokens, citation not critical No RAG, long-context