Semantic Claim Verification with the Built-in NLI Model
Objective
Your application drafts text — support replies, catalog copy, policy summaries — and you need to know whether each claim is actually backed by the evidence you trust before it goes out. SynapCores ships a natural-language-inference (NLI) classifier that runs inside the database process on an embedded ONNX runtime: you supply the evidence (the premise) and the claim (the hypothesis), and it returns entailment, contradiction, and neutral probabilities. No external AI service, no per-call vendor cost, and the evidence never leaves your server.
This recipe provisions the model, classifies premise/hypothesis pairs, and verifies statements against multiple evidence anchors with a threshold policy.
Step 1: Install and enable the model
Pull the curated, hash-pinned bundle (DeBERTa-v3-small, Apache-2.0, English) and enable it. Run as the service owner, against the same config the gateway uses:
synapcores --config /etc/synapcores/gateway.toml pull nli-default
synapcores --config /etc/synapcores/gateway.toml models status nli-default
synapcores --config /etc/synapcores/gateway.toml models enable-nli nli-default
Then restart the gateway. For Docker, enable at startup instead:
docker run -d --name synapcores -p 8080:8080 \
-v synapcores-data:/var/lib/synapcores \
-e AIDB_ACCEPT_LICENSE=1 \
-e AIDB_NLI_ENABLED=1 -e AIDB_NLI_MODEL=nli-default \
synapcores/community:latest
Tarball installs (macOS/Linux): the engine loads its bundled ONNX Runtime
from the lib/ directory beside the executable — keep the extracted
release folder together rather than copying the binary alone, or set
ORT_DYLIB_PATH to the extracted lib/libonnxruntime.dylib (.so on
Linux). Docker images need nothing extra.
A smaller model is available as nli-xsmall (~284 MB) when memory or latency
budgets are tight. Air-gapped hosts can copy a verified bundle directory from a
connected machine and register it with
synapcores --config ... import /path/to/bundle --name nli-default.
Step 2: Confirm the model is ready
curl -s -H "Authorization: Bearer $TOKEN" \
http://localhost:8080/v1/ai/nli/models
The response lists each model with a state — wait for ready (states:
disabled, missing, installed, loading, ready, failed). ready
also reports the loaded bundle's SHA-256, which you should keep with any
review record.
Step 3: Classify premise/hypothesis pairs
Direction matters in NLI — "a red car" proves "a vehicle", not the other way around:
curl -s -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"model": "nli-default",
"pairs": [
{"premise": "A red car is parked.", "hypothesis": "A vehicle is parked."},
{"premise": "A vehicle is parked.", "hypothesis": "A red car is parked."},
{"premise": "No vehicle is parked.", "hypothesis": "A vehicle is parked."}
]
}' http://localhost:8080/v1/ai/nli/pairs
Expected (verified on v2.1.1-ce): pair 1 entailment, pair 2 neutral (a vehicle might not be a red car), pair 3 contradiction — each above 0.99. Up to 32 pairs per request.
Step 4: Verify a claim against evidence anchors
/v1/ai/nli/verify evaluates one statement against each supplied anchor
independently, then applies a threshold policy. A qualifying contradiction
wins even when another anchor supports the claim:
curl -s -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"model": "nli-default",
"statement": "The standard plan includes phone support.",
"truth_anchors": [
"The standard plan does not include phone support."
],
"closed_world": false,
"contradiction_threshold": 0.6,
"entailment_threshold": 0.6
}' http://localhost:8080/v1/ai/nli/verify
Expected (verified): verdict LIE, contradiction 1.00, with the violating anchor identified — the claim reverses the evidence.
Step 5: Choose a world policy for unproven claims
closed_world decides what happens when evidence neither supports nor
contradicts a claim. Open world (default) returns an uncertain verdict —
right for review queues. Closed world refuses to certify anything unproven —
right for publish gates:
curl -s -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{
"model": "nli-default",
"statement": "The Atlas lamp is waterproof.",
"truth_anchors": ["The Atlas lamp has a USB-C charging port."],
"closed_world": true,
"contradiction_threshold": 0.6,
"entailment_threshold": 0.6
}' http://localhost:8080/v1/ai/nli/verify
Expected (verified): the charging spec says nothing about waterproofing
(neutral 0.99), so closed-world policy refuses the claim (verdict LIE,
violated_anchor: null) — the scores are identical to open-world; only the
policy verdict changes.
Where teams use this
| Use case | Pattern |
|---|---|
| Support-response grounding | Split a drafted reply into atomic claims; verify each against the approved plan guide before sending. |
| Product-claim checks | Verify catalog or campaign claims against the SKU's specification revision. |
| Policy wording consistency | Flag help-page or agent explanations that reverse an explicit policy exclusion. |
| Knowledgebase conflict review | Submit passages from two articles as anchors; a qualifying contradiction flags the conflict for an editor. |
| LLM output guardrail | Verify a RAG answer's claims against the retrieved passages before display. |
Keep provenance (document ID, version, who selected the passage) with your review record — the API classifies the text you supply; it does not retrieve evidence or decide which source is authoritative.
What to expect on CPU
Measured on a 6-core desktop CPU (i5-10400F), nli-default, fp32:
- First call after model load: ~0.4 s; warm single pair: ~0.37 s median
/verifyscales linearly with anchors: ~0.36 s per anchor (4 anchors ≈ 1.4 s, 32 ≈ 11.6 s)- Keep anchor counts small on the hot path; batch review jobs can run async
nli-xsmall roughly halves the model footprint for latency-sensitive paths.
Honest boundaries
- Evaluates the text you supply — it does not look up facts, resolve pronouns, or compare numbers and dates with typed precision. Use exact comparisons for those.
- Each anchor is checked independently; it will not chain two anchors into a multi-step proof.
- Scores describe model behavior over your text and thresholds — treat verdicts as review assistance on consequential decisions, with a human in the loop.
Key Concepts Learned
- NLI direction: the premise proves the hypothesis, never the reverse.
- Threshold policy turns raw probabilities into operational verdicts, and closed-world mode turns "unproven" into "refuse to publish".
- In-process inference means claim checks carry no external API dependency, cost, or data egress.