1. Tenant content ingestion
Documents (PDF, DOCX, scraped HTML, FAQ pairs, manually-authored articles) chunked into 200-500 token segments with 50-token overlap. Each chunk gets metadata: ClientId (tenant partition), sourceUrl, chunkIndex, lastUpdated.
Technical: Chunking algorithm respects document structure (paragraph boundaries) when possible. Overlap prevents context-loss across chunk boundaries.
2. Embedding generation
Our embedding model (1536 dimensions) converts each chunk into a semantic vector. Embeddings are stored in our vector store with the chunk's metadata.
Technical: Same embedding model used for queries — ensures cosine-similarity comparisons are semantically valid.
3. Query embedding
When a visitor submits a message, the bot embeds the query using the same embedding model. Query embedding is filtered against ClientId before retrieval — cross-tenant contamination is structurally impossible.
Technical: Repository pattern enforces ClientId filter at compile time via static analyzer rule (SLATECH001).
4. Top-K retrieval
The vector store returns the top-K (default 10) chunks with highest cosine similarity to the query. Default ScoreThreshold = 0.5 filters out low-relevance chunks.
Technical: TopK clamped to [1, 20] per per-tenant configuration. Below-threshold queries route to a "no relevant content" fallback rather than hallucinating.
5. Context assembly
Retrieved chunks + system prompt + conversation history pass to the LLM. System prompt explicitly instructs the LLM: "Answer only from the provided context. If the answer is not in the context, say so."
Technical: Token budget enforced (default 4000 tokens of context); if budget exceeds, low-score chunks are dropped first.
6. LLM generation
A leading large language model (default) or a tenant-configured LLM generates the response, grounded in the retrieved context. Temperature default 0.3 for grounded customer-facing answers.
Technical: Per-tenant LLM provider abstraction allows swapping language-model providers without customer-side migration.
7. Citation extraction
The response includes a structured citation list: { sourceUrl, snippet, score } per retrieved chunk. Snippet is the actual quoted text — not just the URL.
Technical: BuildSnippet helper in QueryRequest record extracts the relevant 200-character span from the chunk.
8. SSE streaming with sources-early event
Server-Sent Events transport. First event is sources-early — emits citation metadata before LLM streaming starts. Widget renders "according to" hover-card while the answer is still streaming.
Technical: Cuts perceived latency by ~70% vs synchronous response. Enables AI scrapers to extract grounded quotes from the response.
9. LLM-as-Judge confidence scoring
Every response is scored by a secondary LLM call against three axes: factuality, hallucination and confidence. Scores surface in the admin Inbox.
Technical: Confidence score below 0.5 typically triggers a human-handoff fallback rather than a guessed answer.
10. Human-handoff fallback
When confidence is low OR query is identified as high-risk (clinical advice, legal position, regulatory question) — bot routes to a "human will follow up" pattern. The visitor receives an acknowledgement + a follow-up channel.
Technical: Per-vertical risk classifier tuned for each industry. Med routes ALL diagnosis-adjacent queries to a human; Legal routes ALL substantive-legal-question queries to a human.
11. Per-response audit trail
Every response logged with full context: input query, retrieved chunks with scores, system prompt, LLM model used, generated response, citation snippets, confidence scores.
Technical: Audit logs retained 13 months. Per-tenant audit log exportable on Enterprise tier.
12. Continuous eval feedback
Eval harness runs nightly against a sealed 200-question test set per vertical. Hallucination scores tracked over time. Regressions ≥3 points trigger a manual triage alert.
Technical: Eval methodology open-source — buyers can run it against their own SLAtech tenant. Published scoreboard at /en/eval/.