Don't Split Your Model in Two: A Practical Guide to Risk-Based Routing Architectures
This article explores why routing a single model through different entry points is becoming an industry standard for LLM safety. It breaks down the four core modules of a risk-tiered routing system—a request classifier, dual-track output policies, a graceful fallback chain, and audit logging—and explains how they separate security constraints from the inference layer. You will also find sample routing code, three common implementation pitfalls to avoid, and notes on using Baidu AI Cloud infrastructure to support the architecture.
1. Why “One Model, Two Entry Points” Is Becoming an Industry Consensus
Over the past two years, the capability boundaries of large language models have continued to expand, but the blurring of security boundaries has come with them. Take text generation as an example: when a high-performance model is open to all users, handling tasks such as writing penetration-testing code for network security, deducing biochemical synthesis pathways, or fulfilling large-scale model-distillation requests, its potential for abuse is significantly higher than in ordinary conversational scenarios.
The traditional solution has been a unified security policy: either apply strict filtering to every request alike (sacrificing the normal user experience) or open everything up (accepting unacceptable risk). This “one-size-fits-all” approach is now being replaced by a risk-tiered architecture—the underlying reasoning capability stays the same, but at the entry layer, requests are routed to different output policies and constraint strengths according to their risk level.
The core value of this architecture lies in:
- Transparency for developers: Callers don’t need to know how many versions exist underneath; they only need to declare the scenario type in the request.
- Controllability for the platform: Security policies can be switched dynamically at runtime, with no need to retrain or release a new model.
- Cost efficiency: Low-risk scenarios use high-performance inference configurations, while high-risk scenarios add an extra review chain, leading to higher compute utilization.
2. Breaking Down the Risk-Tiered Routing Architecture
A deployable risk-routing system typically consists of the following four key modules:
2.1 Request Risk Classifier
This is the entry point of the entire architecture. The classifier needs to quickly assess the risk of a user’s input before model inference begins. In practice, a two-layer approach combining a lightweight classification model + a rule engine is commonly used:
# Illustrative code: risk classification and routing decisionfrom enum import Enumfrom dataclasses import dataclassclass RiskLevel(Enum):GENERAL = "general" # ordinary chat, writing, coding assistanceSENSITIVE = "sensitive" # involving cybersecurity, biological informationRESTRICTED = "restricted" # model distillation, large-scale data extraction@dataclassclass RoutingDecision:risk_level: RiskLevelmodel_tier: str # "standard" / "conservative"extra_guards: list[str] # list of additional guard policies to appendfallback_enabled: bool # whether to enable the degraded fallbackdef route_request(user_input: str, context: dict) -> RoutingDecision:score = lightweight_classifier.predict(user_input)# Rule engine supplement: keyword hits, caller declarations, historical behaviorif score > 0.85 or context.get("declared_sensitive"):return RoutingDecision(risk_level=RiskLevel.RESTRICTED,model_tier="conservative",extra_guards=["output_redaction", "rate_limit_strict"],fallback_enabled=True)elif score > 0.4:return RoutingDecision(risk_level=RiskLevel.SENSITIVE,model_tier="conservative",extra_guards=["human_review_queue"],fallback_enabled=True)return RoutingDecision(risk_level=RiskLevel.GENERAL,model_tier="standard",extra_guards=[],fallback_enabled=False)
Key design points for the classifier:
- Speed first: The classification stage should not introduce more than 50ms of extra latency, and typically uses a distilled small model.
- Explainability: The output should not be just a score, but also include the trigger reasons (which keywords were hit, which rules were invoked), to facilitate auditing.
- Continuous iteration: Misclassified samples from production need to be fed back into the training set to form a closed loop.
2.2 Dual-Track Output Policies
Once the routing decision is made, the request enters the corresponding inference channel:
| Dimension | Standard Channel | Conservative Channel |
|---|---|---|
| Model behavior | Full capability output | Enhanced safety alignment, automatic refusal in sensitive domains |
| Post-processing | Basic content filtering | Multi-level review + output redaction + human review |
| Rate limiting | Standard quota | Strict quota + full audit log retention |
| Fallback mechanism | None | Degrade to the most conservative template reply on exception |
The key point is that the two channels share the underlying inference weights; the differences lie in the decoding strategy, system prompt templates, and the configuration of the post-processing pipeline. This means the platform does not need to maintain two separate sets of models, greatly reducing operational complexity.
2.3 Graceful Fallback Chain
When the review module of the Conservative channel determines that the output still carries risk, the system should not simply return an error, but instead perform graceful degradation:
Full output → fails security review → extract safe segments → append risk notice → return to user→ if the safe segment is empty → return a preset refusal template + guiding suggestions
This design ensures that even if a user triggers a high-risk request, they can still get a constructive response rather than a blunt error.
2.4 Auditing and Observability
Another core value of the risk-tiered architecture is traceability. Each routing decision needs to be logged with the following information:
- The risk score output by the classifier and the rules triggered
- Which channel the request was actually routed to
- The pass/block status of each step in the post-processing pipeline
- The final safety rating of the output
This data is not only the basis for compliance audits but also an important input for optimizing the classifier thresholds.
3. Infrastructure Support from Baidu AI Cloud for These Scenarios
When implementing the above architecture, developers can leverage the general infrastructure capabilities provided by Baidu AI Cloud:
- Model serving layer: Baidu AI Cloud’s Qianfan large-model platform supports unified access and routing configuration for multiple models. Developers can define model strategies for different scenarios on the platform side without having to build their own gateway.
- Content safety: Baidu AI Cloud’s content moderation platform provides multi-dimensional risk identification for text and images, and can serve as an off-the-shelf component for the Conservative channel’s post-processing pipeline.
- Elastic compute: Inference services can scale up and down on demand. Since the Conservative channel typically consumes more resources due to the extra review chain, the elastic scaling mechanism can effectively control costs.
- Logging and monitoring: Through log services and monitoring alerts, developers can track in real time the call volume, block rate, and latency distribution of each channel, providing data support for policy tuning.
4. Three Common Pitfalls in Implementation
Pitfall 1: Insufficient classifier accuracy leading to misjudgment
The accuracy of the risk classifier directly determines the user experience. It is recommended to adopt a “permissive entry, strict exit” strategy in the early stages—the classifier should tend to route ambiguous requests to the Conservative channel. It is better to sacrifice a little experience than to let potential risks slip through. After accumulating enough samples, gradually tighten the thresholds.
Pitfall 2: Prompt drift between the two channels
If the Standard and Conservative channels use different system prompts, behavioral inconsistencies can easily arise after long-term iteration. It is recommended to put the prompt templates under version control and conduct regression tests on both channels after every change.
Pitfall 3: Neglecting user experience in the fallback chain
Many teams directly return “Request rejected” during degradation, which can confuse legitimate users. The degraded reply should include: why the request was restricted (a brief explanation), how the user can adjust the request, or guidance toward a suitable alternative.
5. Summary
“One model, different entry points” is not a marketing concept, but a pragmatic security engineering practice. Its core idea is to decouple security constraints from the model layer to the routing layer, allowing capability release and risk control to evolve independently. For enterprises building AI applications, designing a risk-tiered architecture in advance is far more efficient than patching things up afterward. Whether building a self-developed routing gateway or leveraging the standardized capabilities of a cloud platform, the key is to incorporate “risk awareness” into system design as a first principle from the very beginning.
