# Semantic Router Configuration for Aibrix config: model_config: "vllm-llama3-8b-instruct": reasoning_family: "qwen3" # This model uses Qwen-3 reasoning syntax # preferred_endpoints omitted - let upstream handle endpoint selection pii_policy: allow_by_default: false # Define available LoRA adapters for this base model # These names must match the LoRA modules registered with vLLM at startup loras: - name: "science-expert" description: "Specialized for science domains: biology, chemistry, physics, health, engineering" - name: "social-expert" description: "Optimized for social sciences: business, economics" - name: "math-expert" description: "Fine-tuned for mathematics and quantitative reasoning" - name: "law-expert" description: "Specialized for legal questions and law-related topics" - name: "humanities-expert" description: "Optimized for humanities: psychology, history, philosophy" - name: "general-expert" description: "General-purpose adapter for diverse topics" # Categories with LoRA routing # Each category uses the vllm-llama3-8b-instruct model with a specific LoRA adapter categories: - name: business system_prompt: "You are a senior business consultant and strategic advisor with expertise in corporate strategy, operations management, financial analysis, marketing, and organizational development. Provide practical, actionable business advice backed by proven methodologies and industry best practices. Consider market dynamics, competitive landscape, and stakeholder interests in your recommendations." # jailbreak_enabled: true # Optional: Override global jailbreak detection per category # jailbreak_threshold: 0.8 # Optional: Override global jailbreak threshold per category model_scores: - model: vllm-llama3-8b-instruct # Base model name (for endpoint selection and PII policy) score: 0.7 use_reasoning: false # Business performs better without reasoning - name: law system_prompt: "You are a knowledgeable legal expert with comprehensive understanding of legal principles, case law, statutory interpretation, and legal procedures across multiple jurisdictions. Provide accurate legal information and analysis while clearly stating that your responses are for informational purposes only and do not constitute legal advice. Always recommend consulting with qualified legal professionals for specific legal matters." model_scores: - model: vllm-llama3-8b-instruct score: 0.4 use_reasoning: false - name: psychology system_prompt: "You are a psychology expert with deep knowledge of cognitive processes, behavioral patterns, mental health, developmental psychology, social psychology, and therapeutic approaches. Provide evidence-based insights grounded in psychological research and theory. When discussing mental health topics, emphasize the importance of professional consultation and avoid providing diagnostic or therapeutic advice." semantic_cache_enabled: true semantic_cache_similarity_threshold: 0.92 # High threshold for psychology - sensitive to nuances model_scores: - model: vllm-llama3-8b-instruct score: 0.6 use_reasoning: false - name: biology system_prompt: "You are a biology expert with comprehensive knowledge spanning molecular biology, genetics, cell biology, ecology, evolution, anatomy, physiology, and biotechnology. Explain biological concepts with scientific accuracy, use appropriate terminology, and provide examples from current research. Connect biological principles to real-world applications and emphasize the interconnectedness of biological systems." model_scores: - model: vllm-llama3-8b-instruct score: 0.9 use_reasoning: false - name: chemistry system_prompt: "You are a chemistry expert specializing in chemical reactions, molecular structures, and laboratory techniques. Provide detailed, step-by-step explanations." model_scores: - model: vllm-llama3-8b-instruct score: 0.6 use_reasoning: true # Enable reasoning for complex chemistry - name: history system_prompt: "You are a historian with expertise across different time periods and cultures. Provide accurate historical context and analysis." model_scores: - model: vllm-llama3-8b-instruct score: 0.7 use_reasoning: false - name: other system_prompt: "You are a helpful and knowledgeable assistant. Provide accurate, helpful responses across a wide range of topics." semantic_cache_enabled: true semantic_cache_similarity_threshold: 0.75 # Lower threshold for general chat - less sensitive model_scores: - model: vllm-llama3-8b-instruct score: 0.7 use_reasoning: false - name: health system_prompt: "You are a health and medical information expert with knowledge of anatomy, physiology, diseases, treatments, preventive care, nutrition, and wellness. Provide accurate, evidence-based health information while emphasizing that your responses are for educational purposes only and should never replace professional medical advice, diagnosis, or treatment. Always encourage users to consult healthcare professionals for medical concerns and emergencies." semantic_cache_enabled: true semantic_cache_similarity_threshold: 0.95 # High threshold for health - very sensitive to word changes model_scores: - model: vllm-llama3-8b-instruct score: 0.5 use_reasoning: false - name: economics system_prompt: "You are an economics expert with deep understanding of microeconomics, macroeconomics, econometrics, financial markets, monetary policy, fiscal policy, international trade, and economic theory. Analyze economic phenomena using established economic principles, provide data-driven insights, and explain complex economic concepts in accessible terms. Consider both theoretical frameworks and real-world applications in your responses." model_scores: - model: vllm-llama3-8b-instruct score: 1.0 use_reasoning: false - name: math system_prompt: "You are a mathematics expert. Provide step-by-step solutions, show your work clearly, and explain mathematical concepts in an understandable way." model_scores: - model: vllm-llama3-8b-instruct score: 1.0 use_reasoning: true # Enable reasoning for complex math - name: physics system_prompt: "You are a physics expert with deep understanding of physical laws and phenomena. Provide clear explanations with mathematical derivations when appropriate." model_scores: - model: vllm-llama3-8b-instruct score: 0.7 use_reasoning: true # Enable reasoning for physics - name: computer science system_prompt: "You are a computer science expert with knowledge of algorithms, data structures, programming languages, and software engineering. Provide clear, practical solutions with code examples when helpful." model_scores: - model: vllm-llama3-8b-instruct score: 0.6 use_reasoning: false - name: philosophy system_prompt: "You are a philosophy expert with comprehensive knowledge of philosophical traditions, ethical theories, logic, metaphysics, epistemology, political philosophy, and the history of philosophical thought. Engage with complex philosophical questions by presenting multiple perspectives, analyzing arguments rigorously, and encouraging critical thinking. Draw connections between philosophical concepts and contemporary issues while maintaining intellectual honesty about the complexity and ongoing nature of philosophical debates." model_scores: - model: vllm-llama3-8b-instruct score: 0.5 use_reasoning: false - name: engineering system_prompt: "You are an engineering expert with knowledge across multiple engineering disciplines including mechanical, electrical, civil, chemical, software, and systems engineering. Apply engineering principles, design methodologies, and problem-solving approaches to provide practical solutions. Consider safety, efficiency, sustainability, and cost-effectiveness in your recommendations. Use technical precision while explaining concepts clearly, and emphasize the importance of proper engineering practices and standards." model_scores: - model: vllm-llama3-8b-instruct score: 0.7 use_reasoning: false - name: thinking system_prompt: "You are a thinking expert, should think multiple steps before answering. Please answer the question step by step." model_scores: - model: vllm-llama3-8b-instruct score: 0.7 use_reasoning: true default_model: vllm-llama3-8b-instruct bert_model: model_id: models/all-MiniLM-L12-v2 threshold: 0.6 use_cpu: true semantic_cache: enabled: true backend_type: "memory" # Options: "memory", "milvus", or "hybrid" similarity_threshold: 0.8 max_entries: 1000 # Only applies to memory backend ttl_seconds: 3600 eviction_policy: "fifo" # HNSW index configuration (for memory backend only) use_hnsw: true # Enable HNSW index for faster similarity search hnsw_m: 16 # Number of bi-directional links (higher = better recall, more memory) hnsw_ef_construction: 200 # Construction parameter (higher = better quality, slower build) # Hybrid cache configuration (when backend_type: "hybrid") # Combines in-memory HNSW for fast search with Milvus for scalable storage # max_memory_entries: 100000 # Max entries in HNSW index (default: 100,000) # backend_config_path: "config/milvus.yaml" # Path to Milvus config # Embedding model for semantic similarity matching # Options: "bert" (fast, 384-dim), "qwen3" (high quality, 1024-dim, 32K context), "gemma" (balanced, 768-dim, 8K context) # Default: "bert" (fastest, lowest memory) embedding_model: "bert" tools: enabled: true top_k: 3 similarity_threshold: 0.2 tools_db_path: "config/tools_db.json" fallback_to_empty: true prompt_guard: enabled: true # Global default - can be overridden per category with jailbreak_enabled use_modernbert: true model_id: "models/jailbreak_classifier_modernbert-base_model" threshold: 0.7 use_cpu: true jailbreak_mapping_path: "models/jailbreak_classifier_modernbert-base_model/jailbreak_type_mapping.json" # Classifier configuration classifier: category_model: model_id: "models/category_classifier_modernbert-base_model" use_modernbert: true threshold: 0.6 use_cpu: true category_mapping_path: "models/category_classifier_modernbert-base_model/category_mapping.json" pii_model: model_id: "models/pii_classifier_modernbert-base_presidio_token_model" use_modernbert: true threshold: 0.7 use_cpu: true pii_mapping_path: "models/pii_classifier_modernbert-base_presidio_token_model/pii_type_mapping.json" keyword_rules: - category: "thinking" operator: "OR" keywords: ["urgent", "immediate", "asap", "think", "careful"] case_sensitive: false # Router Configuration for Dual-Path Selection router: # High confidence threshold for automatic LoRA selection high_confidence_threshold: 0.99 # Low latency threshold in milliseconds for LoRA path selection low_latency_threshold_ms: 2000 # Baseline scores for path evaluation lora_baseline_score: 0.8 traditional_baseline_score: 0.7 embedding_baseline_score: 0.75 # Success rate calculation threshold success_confidence_threshold: 0.8 # Large batch size threshold for parallel processing large_batch_threshold: 4 # Default performance metrics (milliseconds) lora_default_execution_time_ms: 1345 traditional_default_execution_time_ms: 4567 # Default processing requirements default_confidence_threshold: 0.95 default_max_latency_ms: 5000 default_batch_size: 4 default_avg_execution_time_ms: 3000 # Default confidence and success rates lora_default_confidence: 0.99 traditional_default_confidence: 0.95 lora_default_success_rate: 0.98 traditional_default_success_rate: 0.95 # Scoring weights for intelligent path selection (balanced approach) multi_task_lora_weight: 0.30 # LoRA advantage for multi-task processing single_task_traditional_weight: 0.30 # Traditional advantage for single tasks large_batch_lora_weight: 0.25 # LoRA advantage for large batches (≥4) small_batch_traditional_weight: 0.25 # Traditional advantage for single items medium_batch_weight: 0.10 # Neutral weight for medium batches (2-3) high_confidence_lora_weight: 0.25 # LoRA advantage for high confidence (≥0.99) low_confidence_traditional_weight: 0.25 # Traditional for lower confidence (≤0.9) low_latency_lora_weight: 0.30 # LoRA advantage for low latency (≤2000ms) high_latency_traditional_weight: 0.10 # Traditional acceptable for relaxed timing performance_history_weight: 0.20 # Historical performance comparison factor # Traditional model specific configurations traditional_bert_confidence_threshold: 0.95 # Traditional BERT confidence threshold traditional_modernbert_confidence_threshold: 0.8 # Traditional ModernBERT confidence threshold traditional_pii_detection_threshold: 0.5 # Traditional PII detection confidence threshold traditional_token_classification_threshold: 0.9 # Traditional token classification threshold traditional_dropout_prob: 0.1 # Traditional model dropout probability traditional_attention_dropout_prob: 0.1 # Traditional model attention dropout probability tie_break_confidence: 0.5 # Confidence value for tie-breaking situations # Reasoning family configurations reasoning_families: deepseek: type: "chat_template_kwargs" parameter: "thinking" qwen3: type: "chat_template_kwargs" parameter: "enable_thinking" gpt-oss: type: "reasoning_effort" parameter: "reasoning_effort" gpt: type: "reasoning_effort" parameter: "reasoning_effort" # Global default reasoning effort level default_reasoning_effort: high # API Configuration api: batch_classification: max_batch_size: 100 concurrency_threshold: 5 max_concurrency: 8 metrics: enabled: true detailed_goroutine_tracking: true high_resolution_timing: false sample_rate: 1.0 duration_buckets: [0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30] size_buckets: [1, 2, 5, 10, 20, 50, 100, 200] # Embedding Models Configuration # These models provide intelligent embedding generation with automatic routing: # - Qwen3-Embedding-0.6B: Up to 32K context, high quality, # - EmbeddingGemma-300M: Up to 8K context, fast inference, Matryoshka support (768/512/256/128) embedding_models: qwen3_model_path: "models/Qwen3-Embedding-0.6B" gemma_model_path: "models/embeddinggemma-300m" use_cpu: true # Set to false for GPU acceleration (requires CUDA) # Observability Configuration observability: tracing: enabled: false # Enable distributed tracing for docker-compose stack provider: "opentelemetry" # Provider: opentelemetry, openinference, openllmetry exporter: type: "otlp" # Export spans to Jaeger (via OTLP gRPC) endpoint: "jaeger:4317" # Jaeger collector inside compose network insecure: true # Use insecure connection (no TLS) sampling: type: "always_on" # Sampling: always_on, always_off, probabilistic rate: 1.0 # Sampling rate for probabilistic (0.0-1.0) resource: service_name: "vllm-semantic-router" service_version: "v0.1.0" deployment_environment: "development"