AlignScore 集成#
NeMo Guardrails 提供对 AlignScore 指标(Zha 等人)的开箱即用支持,该指标使用基于 RoBERTa 的模型对模型响应相对于知识库的事实一致性进行评分。
在我们的测试中,我们将 AlignScore 作为 HTTP 服务托管时观察到平均延迟约为 220ms,而将模型加载到内存中直接推理时约为 45ms。这使得它比自检方法快得多。然而,这种方法需要在本地部署公开可用的 AlignScore 模型。有关更多详细信息,请参阅AlignScore 部署指南。
用法#
要使用基于 AlignScore 的事实核查,您必须在 config.yml
中设置以下配置选项
rails:
config:
fact_checking:
parameters:
# Point to a running instance of the AlignScore server
endpoint: "https://:5000/alignscore_large"
output:
flows:
- alignscore check facts
基于 AlignScore 的事实核查防护栏的 Colang 流程与自检事实核查防护栏的流程相同。要触发事实核查防护栏,您需要在需要事实核查的 bot 消息之前将 $check_facts
上下文变量设置为 True
,例如
define flow
user ask about report
$check_facts = True
bot provide report answer