RAGSpine
核心概念

FAQ 短路

一个经领域专家审核的"问题到回答"缓存,绕过 LLM——由保守的排除规则把关,因为它位于防编造机制守卫的前面。

FAQ 缓存对已知问题返回经领域专家(SME)审核的回答,完全绕过 LLM、 事实存储和检索器。它是一项延迟与成本优化——同时也是一个 高风险层,因为它位于防编造机制守卫的_前面_。一次错误的 短路会跳过下游全部安全检查。

正因为 FAQ 层位于防编造机制之前,它的 排除规则刻意保守:结构化数值类、竞争对手、实时、已过期、 已禁用和 RESTRICTED 条目绝不短路。

它的位置

/v1/ask 路由(service/api/routes.py)中,FAQ 查询最先运行:

# 1) FAQ short-circuit — on hit, never touches provider / fact store / retriever
hit = faq_cache.lookup(req.question, reference_date=ref)
if hit is not None:
    return AskResponse(..., route="faq", answer=hit.answer, sources=[...])

# 2) miss -> normal workflow (anti-fabrication guard, dual channel, ...)
result = answer_question(req.question, store, provider, ...)

lookup 是一个纯函数(service/faq/faq_cache.py):它咨询 parse_intent / clarify_scope 做边界判定,但绝不触达 LLM、事实存储或 检索器。匹配只做归一化后的精确/别名匹配(NFKC + casefold + 空白 折叠 + 去尾部标点)——没有模糊匹配或 embedding 匹配。

保守的排除规则

只要下列任一条成立,lookup 就返回未命中None)——这些排除规则在 查询缓存索引_之前_检查:

一个 FAQ 条目

条目经领域专家审核并做版本跟踪;命中会携带自己的溯源信息 (FAQHit.source):

{
  "id": "what-is-ragspine",
  "question": "RAGSpine 是什么?",
  "aliases": ["What is RAGSpine?"],
  "answer": "RAGSpine 是一个无框架的后端 RAG 引擎……",
  "source": "internal/faq-handbook.md",
  "version": 3,
  "enabled": true,
  "valid_from": "2026-01-01",
  "valid_until": null,
  "sensitivity": "INTERNAL"
}

命中返回 route: "faq",附带 cache 块(hittypefaq_idversionsource)。 trace 只记录 cache_hitfaq_idfaq_version——绝不记录回答文本。通过 RAGSPINE_FAQ_SOURCE 环境变量加载 FAQ JSON。

本页目录