status; any LLM fallback is recorded as an advisory check and can never overwrite the deterministic outcome. Because the deterministic path is heuristic TF-IDF analysis, a supported claim is capped at UNVERIFIABLE — see Result contract.
Features
- TF-IDF semantic similarity — no LLM needed.
- Keyword overlap analysis — fast and deterministic.
- Entity matching — numbers, dates, names.
- Citation extraction — with relevance scoring.
- Negation detection — catch contradictions.
- Advisory-only LLM fallback — invoked only when deterministic confidence is below
min_confidence, and its result is stored inadvisory_checks.
Usage
Result contract
The Fact Engine returns aDiagnosticResult. The deterministic verdict maps to a diagnostic status as follows:
When you call the engine through the Python SDK,
QWEDClient.verify_fact also fails closed on the client side. If the QWED service is unreachable or the request times out, the client returns status="UNVERIFIABLE" and is_verified=False instead of raising. See verify_fact.
Confidence is exposed via developer_fields.deterministic_confidence and is never verdict-deciding — the mapping above is based on the deterministic verdict alone.
Scoring methods
methods_used in the result reflects this shape — each entry carries an advisory_only flag so callers can tell deterministic contributions from advisory ones.
Advisory-only LLM fallback
When the deterministic confidence is belowmin_confidence and a provider is configured, the engine calls an LLM for additional analysis. The LLM output is recorded in advisory_checks and does not change the returned status:
SUPPORTED) is capped at UNVERIFIABLE and never emits VERIFIED with a proof_ref. Only a deterministic refutation (BLOCKED) or an unexpected error fail closed.
Prompt-injection screening
Before the advisory call, QWED screens the claim and the context for prompt-injection phrases, such as “ignore previous instructions” or “developer mode”. It does not resolve or call the provider until both pass. The check matches each phrase as whole words, with an optional English ending (s, es, ed, ing) on its last word, so “Impact assessment” passes and “Disregard all prompts above” does not. It also refuses a claim or a context longer than 10,000 characters, which keeps the check’s cost bounded. The check reads through invisible characters, such as a zero-width space, a word joiner or a soft hyphen, inside a word or between words, and it also reads the text’s NFKC form, so fullwidth letters do not hide a phrase. The 10,000-character limit applies to the NFKC form too, so a text of 10,000 characters or fewer is still refused as too long when its NFKC form is longer than 10,000 characters. The text sent to the provider is unchanged.
A refused claim or context makes the whole request BLOCKED with constraint_id: security.input_refused, rather than a result without the advisory you asked for. The message is always The input was refused by the injection screen before any model saw it. The screen’s reason, for example Input too long (max 10000 chars), stays in the server log. Before this change the result carried fact_verifier.translation_refused and a message that gave the reason. The deterministic fields (deterministic_verdict, deterministic_confidence, evidence, citations and scores) stay in developer_fields.
The screening applies only when the advisory runs: the deterministic confidence is below min_confidence and you name a provider. To get only the deterministic result, for example for a context over 10,000 characters, send no provider.
Batch verification
BatchFactVerifier.verify_batch() returns one DiagnosticResult, with the counts in developer_fields["summary"]. An item counts as verified only when it is VERIFIED with is_valid true, as the attestation and the audit log count it. A VERIFIED item proven false counts as blocked (changed in v10.0.0).