什么是 Signal-Driven Decision?
Signal-Driven Decision 是 Semantic Router 的核心路由架构。它不再依赖单一分类器,而是并行提取请求的多个维度信号(Signal),并通过布尔树组合它们以做出精确的路由决策。
核心理念
传统路由使用单一信号:
# 传统:单一分类模型
if classifier(query) == "math":
route_to_math_model()
Signal-Driven routing 使用多种 signal:
# 信号驱动:多种信号组合
if (keyword_match AND domain_match) OR high_embedding_similarity:
route_to_math_model()
**核心优势**:通过多维度的信号交叉验证,有效避免了单一模型经常发生的判定盲区,提升了路由的鲁棒性。
## 13 种 Signal 类型
### 1. Keyword Signal
- **内容**:使用 AND/OR 运算符的快速模式匹配
- **延迟**:小于 1ms
- **用例**:确定性路由、合规性、安全性
```yaml
signals:
keywords:
- name: "math_keywords"
operator: "OR"
keywords: ["calculate", "equation", "solve", "derivative"]
示例:"Calculate the derivative of x^2" → 匹配 "calculate" 和 "derivative"
2. Embedding Signal
- 内容:使用 embedding 的语义相似度
- 延迟:10-50ms
- 用例:意图检测、释义处理
signals:
embeddings:
- name: "code_debug"
threshold: 0.70
candidates:
- "My code isn't working, how do I fix it?"
- "Help me debug this function"
示例:"Need help debugging this function" → 0.78 相似度 → 匹配!
3. Domain Signal
- 内容:MMLU 领域分类(14 个类别)
- 延迟:50-100ms
- 用例:学术和专业领域路由
signals:
domains:
- name: "mathematics"
mmlu_categories: ["abstract_algebra", "college_mathematics"]
示例:"Prove that the square root of 2 is irrational" → Mathematics (数学) 领域