Factual Consistency Scanner
(Output scanner)
Last updated
(Output scanner)
Last updated
This scanner is designed to assess if the given content contradicts or refutes a certain statement or prompt. It acts as a tool for ensuring the consistency and correctness of language model outputs, especially in contexts where logical contradictions can be problematic.
The scanner leverages pretrained natural language inference (NLI) models from Hugging Face to determine the relationship between a given prompt and the generated output.
Natural language inference is the task of determining whether a “hypothesis” is true (entailment), false ( contradiction), or undetermined (neutral) given a “premise”.
This calculated score is then compared to a configured threshold. Outputs that cross this threshold are flagged as contradictory.
Factual Consistency Detection Policy for AI Chatbot
Create a new policy as same as shown in LLM Guardrails Policy, for Factual Consistency detection select output scanner Factual Consistency.
Optionally, perform a test to ensure the policy is functioning as intended. Check that Factual Consistency is detected and blocked as specified.