Objective
An application — often an LLM — states things about your records. Some restate what the record says; some are predictions dressed as facts. Verify each statement against the record text and keep the unsupported ones out of customer-facing output.
Run it in SQL (v2.1.2-ce+)
Verify each statement an application (often an LLM) makes against the record text, and keep the unsupported ones out of customer-facing output:
SELECT JSON_UNQUOTE(JSON_EXTRACT(NLI_VERIFY('nli-default',
'Shipment K9 is recorded as delivered.',
JSON_ARRAY('The supplied shipping ledger records shipment K9 as delivered.')), '$.verdict')) AS grounded_fact;
Expected: TRUTH.
SELECT JSON_UNQUOTE(JSON_EXTRACT(NLI_VERIFY('nli-default',
'Shipment K9 will arrive tomorrow.',
JSON_ARRAY('The supplied shipping ledger records shipment K9 as created.')), '$.verdict')) AS prediction_dressed_as_fact;
Expected: UNVERIFIED_PLAUSIBLE — the ledger records creation, not a future
arrival, so the prediction is not grounded. Gate customer-facing output on
TRUTH only.
Step 1: A statement the record establishes
Default thresholds (0.6) apply when none are supplied:
curl -s -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"model": "nli-default",
"statement": "Shipment K9 is recorded as delivered.",
"truth_anchors": ["The supplied shipping ledger records shipment K9 as delivered."],
"closed_world": false
}' http://localhost:8080/v1/ai/nli/verify
Expected (verified on v2.1.1-ce): verdict TRUTH, entailment 1.00 — a faithful restatement of the ledger.