Prompt Classification Routing
This proposal introduces a unified content scanning and routing framework that extends the vLLM Semantic Router with three complementary signal sources:
- Keyword-Based Routing - Deterministic, fast, Boolean logic for exact term matching
- Regex Content Scanning - Pattern-based detection for safety, compliance, and structured data
- Embedding Similarity Scanning - Semantic concept detection robust to paraphrasing
All three signals integrate with the existing BERT-based classification through a Signal Fusion Layer, providing users with a powerful, flexible routing control plane while maintaining backward compatibility with the current architecture.
Key Design Principles
- Complementary, Not Replacement: Augment existing BERT classification rather than replacing it
- Dual Execution Paths: Support both in-tree (low-latency) and out-of-tree via MCP (high-flexibility) modes
- Policy-Driven Fusion: Allow users to compose signals using Boolean expressions, thresholds, and weighted rules
- Performance-Conscious: Provide fast paths for common cases while supporting complex scenarios
- Security-First: ReDoS protection, input validation, and comprehensive audit logging
Problem Statement & Motivation
Current Limitations
The vLLM Semantic Router currently relies exclusively on ModernBERT classification for semantic category detection. While powerful, this approach has several limitations:
From Issue #313: No Deterministic Routing
Problem: Cannot route queries based on specific keywords or technology terms
- Query: "How to secure a Kubernetes cluster with RBAC?"
- Current: Must run ML inference (~20-30ms) → Classify as "computer science" → Route to general models
- Desired: Match keywords
["kubernetes", "k8s", "RBAC"]→ Route directly to[k8s-expert, devops-model]
Impact:
- Unnecessary latency (~20-30ms) for queries that could be routed deterministically in ~1-2ms
- Less precise routing (category "computer science" is too broad)
- Cannot leverage domain knowledge (e.g., "CVE-" patterns always go to security models)
- No Boolean logic for complex matching (e.g., "Kubernetes AND security" vs "Kubernetes OR Docker")