AI Concepts (the building blocks)¶
Definitions for the primitives that the RAG, vector, and LLM-provider pages keep referring back to. If you only know these terms by reputation, this is the page that pins them down.
Embeddings¶
What they are. A model maps a chunk of text (or image, audio, …) to a fixed-length array of floating-point numbers — typically 384, 768, 1024, 1536, or 3072 dimensions. Two pieces of content that "mean the same thing" land near each other in that high-dimensional space.
Why they matter. Once content is embedded, you can do similarity search (cosine, dot-product, or Euclidean), clustering, classification, and recommendation — without fine-tuning a model.
Embedding models in this portfolio:
- text-embedding-3-small (OpenAI, 1536 dim) — default across 18 products: Toolbelt Handyman, Workflow Hub, Sourcing AI, Marketing AI, GoGreen Seller AI, AutoDiag AI, OpenSentinel, GGPI website, AI Concierge, SmartForms, Sell Me A Pen, APEX Sales Training, Recruiting AI, PoligoPro, VotigoPro, HouseKey, Tutor AI, Jarvis (Tauri). Cheap and good enough for most retrieval.
- text-embedding-3-large (OpenAI, 3072 dim) — the DOC-AI default (backend/app/config.py; its CLAUDE.md only says "OpenAI embeddings"). Higher recall on dense document text. 2× the storage of 1536-dim vectors and a higher API cost. OpenSentinel's embeddings module also references -large and ada-002.
- HuggingFace embeddings — the SDK is installed via the unified ai-providers service in most products, but it is a fallback path rather than the primary embedder; GoGreen Seller AI and AutoDiag AI list it as an alternate embedder.
- TF-IDF (AutoDiag AI) — not learned embeddings, but the same vector-of-numbers shape; used when no embedding key is available (hashing fallback) and alongside Pinecone semantic search.
- No embedding model — GoGreen Verify (its RAG is a client-side term-frequency hash), plus SuperCabs, BidIt, GameTrakker, Do Me A Ditty and Go Green Transit.
Dimension matters. Storage cost = dimensions × 4 bytes × num_vectors. 3072-dim vectors are 4× the storage of 768-dim. Index build time scales similarly.
Cosine similarity (and friends)¶
What it is. Three common distance metrics over embedding vectors: - Cosine similarity — the angle between two vectors, ignoring magnitude. The default for text embeddings because OpenAI/HuggingFace embeddings are roughly L2-normalized to magnitude 1, which makes cosine and dot-product equivalent. - Euclidean / L2 — straight-line distance. Sensitive to magnitude, less common for normalized text embeddings. - Inner product / dot product — fastest if vectors are already normalized; equivalent to cosine in that case.
In pgvector: <=> is cosine, <-> is L2, <#> is negative inner product. Toolbelt Handyman and the other pgvector products use <=>; SmartForms, Sell Me A Pen, VotigoPro and HouseKey compute cosine in application code.
Chunking¶
What it is. Documents are too long for an embedding model's context window (8K tokens for OpenAI v3 embeddings) and would dilute meaning anyway, so we split them into chunks before embedding.
Strategies seen in the portfolio:
- Fixed-size split with overlap — Sourcing AI (chunk 500 / overlap 50, env-tunable), the simplest and most common.
- Paragraph-aware — AI Concierge (≤80 words per chunk, source-name prefix).
- Sentence-boundary — SmartForms.
- Token-count — DOC-AI uses tiktoken plus a chunking service; more predictable cost.
- Dedicated chunking services — Workflow Hub (packages/rag), GoGreen Seller AI (rag.service.ts), APEX (chunking.service.ts), HouseKey (chunker.service.js), Sell Me A Pen (chunking.service.ts), PoligoPro (chunking utility).
- Sentence-window — embed a single sentence but retrieve a window around it. Good for citation precision.
- Markdown-aware — split on # headings before falling back to length. Useful for long-form docs.
- Code-aware — split on function/class boundaries. Not used; no code-RAG product in the portfolio.
- Overlap — a 10–20% overlap between adjacent chunks so a fact at a boundary isn't lost.
Tradeoffs. - Bigger chunks: more context per retrieval, fewer chunks total, easier on the vector DB. But higher noise — irrelevant prose drowns the signal. - Smaller chunks: precise, but you may need to retrieve more of them, and a single answer may be split across chunks. - Right answer is usually 500–1000 tokens with 100–200 overlap; tune per corpus.
BM25 (Best Match 25)¶
What it is. A sparse, keyword-based ranking function used by Lucene, Elasticsearch, Solr, and Postgres full-text. Improvement over TF-IDF: adds saturation (the 10th occurrence of a word adds less than the 2nd) and document-length normalization.
Where it shows up: no in-scope product names BM25. The sparse half of hybrid search is Postgres tsvector / ts_rank full-text — DOC-AI, AI Concierge, OpenSentinel (a tsvector GIN column), GGPI website.
Why it still matters in 2026. Embeddings can't match exact tokens — a SKU like "PRT-2024-A" doesn't have a meaningful embedding. Keyword search catches those.
TF-IDF (Term Frequency × Inverse Document Frequency)¶
What it is. Older sparse retrieval — weight each term by how often it appears in this doc and how rare it is in the corpus. BM25 is a better default; TF-IDF is still useful when you want a fully local retriever with no neural model.
Used in: AutoDiag AI (TF-IDF with Pinecone semantic search in its LangChain RAG pipeline).
Hybrid search¶
What it is. Run dense vector search and sparse keyword search (BM25/TF-IDF/full-text) in parallel, then merge.
Merging strategies:
- Reciprocal Rank Fusion (RRF) — score(d) = Σ 1/(k + rank_i(d)) over each retriever. Hyperparameter k ≈ 60 by default. Robust, no per-corpus tuning.
- Weighted linear combination — α × dense_score + (1-α) × sparse_score. Needs score normalization first.
- Learned fusion — train a small model to pick. Overkill for portfolio scale.
Used in (hybrid is explicit): DOC-AI (Qdrant + Postgres tsvector, RRF), AI Concierge (vector + Postgres FTS, RRF), Workflow Hub (hybrid + RRF), OpenSentinel, GGPI website (pgvector + full text), Tutor AI (pgvector + Postgres FTS fused with RRF k=60), VotigoPro (hybrid keyword + semantic scoring).
Reranking¶
What it is. A second-pass scoring step. Stage 1 (the embedding retrieval) returns a wide candidate set cheaply; stage 2 reranks them using a more expensive but more accurate model that reads the (query, doc) pair together.
Reranker types:
- Cross-encoder — a transformer that takes [CLS] query [SEP] doc and outputs a relevance score. Not used by an in-scope product.
- Cohere Rerank — managed API. Not used in this portfolio.
- BGE-reranker / bge-reranker-v2 — open-source cross-encoders from BAAI. Available via HuggingFace; not used.
- LLM-as-reranker — prompt the LLM to score each candidate. Sourcing AI does this (top-K 5, rerank top-K 3). High quality, expensive, scales to ~20 candidates max.
- ColBERT — late-interaction; not used.
- Metadata reranker — non-neural. Score a document based on heuristics (recency, source-type weight, user prefs).
Used in (products with explicit reranking): Workflow Hub, Sourcing AI, Marketing AI, GoGreen Seller AI, SmartForms, OpenSentinel, Tutor AI (a metadata-boost heuristic, not a cross-encoder; its CLAUDE.md just says "re-rank"). DOC-AI does not rerank.
HyDE (Hypothetical Document Embeddings)¶
What it is. Instead of embedding the user's question, ask the LLM to generate a hypothetical answer and embed that. Then look for documents that match the hypothetical answer's embedding.
Why it works. A question and a real answer are written in different registers ("how do I cancel?" vs "Subscription cancellation procedure"). Two answers — one hypothetical and one real — are written in the same register, so they cluster better.
Used in: the most common enhancement in the portfolio. See RAG-Patterns.md for the full list (11 products).
Cost. One additional small-LLM call per query (SmartForms uses gpt-4o-mini). Latency hit is ~300 ms, often cached.
Query rewriting / expansion¶
What it is. Reword or expand the user's query before retrieval.
Variants: - Multi-query — generate N paraphrases, retrieve for each, dedupe and merge results. - Step-back — rewrite the specific question into a more general one, then retrieve. - Hypothetical example — generate examples of what the answer would look like (related to HyDE). - Standalone-question rewrite — for chat apps; rewrite "what about the second one?" into a context-free query using history.
Used in: Marketing AI (HyDE + query rewrite + rerank), OpenSentinel (contextual query among its techniques).
Tool use / function calling¶
What it is. Modern LLMs (Claude, GPT-4o, Gemini) can be given a list of tool schemas (JSON schema). The model returns a structured tool_use block instead of text; the runtime executes the tool and feeds the result back. Loop until the model returns a text answer.
Vendor names for the same idea: - OpenAI: "function calling" (deprecated name) → "tool use." - Anthropic Claude: "tool use." - Google Gemini: "function calling." - All compatible at the schema level.
Used in: AI Concierge (bounded 6-step loop: search_knowledge, capture_lead, book_appointment, hand_off_to_human, transfer_to_bot), GGPI website (book_consultation, recall_contact, search_memory), VotigoPro (9 voting tools), HouseKey (7 tools), Toolbelt Handyman (realtime function calling via toolRegistry.ts), GoGreen Seller AI (copilot), Recruiting AI (interviewer agent), OpenSentinel, Workflow Hub (agent runtime), Tutor AI (agentic RAG tools), Jarvis (Tauri; tool calling behind an autonomy gate).
Iteration cap. Always cap the loop. AI Concierge's bounded 6-step loop is a sensible pattern. Without a cap the model can loop indefinitely on a malformed schema.
Agents¶
What they are. Loosely defined: an LLM that decides what to do next (which tool to call, what to retrieve, when to stop) instead of running a fixed pipeline. Concretely in this portfolio: a while not done: tool_call loop wrapped around an LLM with a tool schema.
Frameworks present:
- LangChain — Python; used in DOC-AI (langchain-core 1.6.6) and AutoDiag AI (0.3.14).
- Vercel AI SDK — TypeScript; used in Workflow Hub (agent runtime). Streaming-first, tool-use-native.
- Custom loops — Tutor AI (tutorOrchestrator plus a critic agent, with a Socratic service), Jarvis (Tauri; personas, skills, workflows, self-repair), AI Concierge, GGPI website, OpenSentinel (SWARM tiers, sub-agents, task planner), GoGreen Seller AI (sub-agent manager), SmartForms (review swarm: 3 model calls per low-confidence field, capped at 10 fields).
LangSmith is the LangChain observability layer (traces, eval). Used in DOC-AI.
MCP (Model Context Protocol)¶
What it is. Anthropic's open spec (released 2024) for connecting LLMs to tools and data sources via a standardized client-server protocol. An "MCP server" exposes tools, resources, and prompts; an MCP client (the LLM host) consumes them. Like LSP for AI agents.
MCP servers:
- DOC-AI — 15 tools, TypeScript server in mcp/ (stdio or Streamable HTTP), /mcp on web and API.
- AI Concierge — POST /api/mcp, 8 tools, tenant API key with mcp:read.
- GGPI website — read-only POST /api/mcp (search_contacts, get_contact, list_bookings, list_calls, search_knowledge, search_memory).
- Recruiting AI — hosted MCP server.
- Tutor AI — Streamable HTTP, stateless (@modelcontextprotocol/sdk).
- Jarvis (Tauri) — axum MCP server inside the desktop app.
- HouseKey — mcp/server.js, 7 tools, MCP_ALLOW_MUTATIONS flag.
- OpenSentinel — POST /mcp exposing 9 curated tools.
- Workflow Hub — server and client (own implementation, SSRF-guarded registry).
- Marketing AI (services/mcp-server), GoGreen Verify, Go Green Transit (JSON-RPC POST /mcp plus the ftproxy-mcp desktop binary), GoGreen Seller AI.
MCP clients: Jarvis (Tauri, to OpenSentinel), OpenSentinel (to 11 servers), Workflow Hub, SmartForms (mcp_client.py connector). AutoDiag AI has an MCP-style registry (brain/mcp.py, HTTP callbacks).
No MCP: Toolbelt Handyman, SuperCabs, BidIt, Sourcing AI, Sell Me A Pen, APEX, PoligoPro, VotigoPro, GameTrakker, Do Me A Ditty, Maximus Pet Store, Pecos River Traders, Jarvis (Electron).
Why it matters. Replaces app-specific glue code. If a new tool exposes an MCP server, every MCP-aware client gets it for free.
Adjacent retrieval ideas (not currently used)¶
ColBERT¶
Late-interaction retrieval — embed each token (not each document) and compute the maxsim across token pairs. State-of-the-art recall but storage-heavy. Not used in portfolio.
Splade¶
Learned sparse retrieval — neural BM25-replacement. Better-than-BM25 quality, embeddable in regular search engines. Not used.
Matryoshka embeddings¶
A single model produces nested embeddings (you can truncate text-embedding-3-large from 3072 → 1024 → 256 with graceful quality degradation). OpenAI v3 embeddings support this; the portfolio doesn't currently exploit it.
Long-context attention (no RAG)¶
Some current models advertise 200K to 1M-token contexts. For small corpora, "just stuff the whole document" can outperform poorly-tuned RAG. See the "long-context" entry in RAG-Patterns.md.
Self-RAG / Corrective-RAG / Adaptive-RAG (the academic family)¶
Variants where the LLM evaluates its own retrieval and decides to retry / refine / abstain. No in-scope product implements these; OpenSentinel's multi-step retrieval and Workflow Hub's evaluation harness are the nearest relatives.