Skip to content

SynapCores / Recipe

Document-Revision Conflicts with NLI

Catch summaries and answers that quote an obsolete revision — and learn where typed comparisons must take over from language inference

All recipes· ml· 10 minutesadvanceden
Instance: localhost:8080

Opens your running SynapCores (Document-Revision Conflicts with NLI will be staged for a preview — nothing runs until you click Run). No instance yet? Install free in ~30s.

Share

Objective

A summary repeats "retention is 30 days" from revision 1; revision 2 changed it to 90. This recipe shows the two-step pattern that works — and why numeric, temporal claims are the case where you must not lean on NLI alone.

Run it in SQL (v2.1.2-ce+)

NLI reads wording, so a stale numeric claim against the current policy does surface as a contradiction — but read the caution below before trusting it:

SELECT
  JSON_UNQUOTE(JSON_EXTRACT(NLI_VERIFY('nli-default',
    'The archive retention period is exactly 30 days.',
    JSON_ARRAY('The active archive policy sets the retention period to exactly 90 days.')), '$.verdict')) AS stale_summary,
  JSON_UNQUOTE(JSON_EXTRACT(NLI_VERIFY('nli-default',
    'The archive retention period is exactly 90 days.',
    JSON_ARRAY('The active archive policy sets the retention period to exactly 90 days.')), '$.verdict')) AS current_summary;

Expected: stale_summary = LIE, current_summary = TRUTH. It works here because 30 vs 90 is a stark mismatch — but NLI does not compare numbers with typed precision (30 vs 31, or "30 days" vs "one month" are exactly where it slips). For numeric and temporal facts, treat the verdict as a hint and confirm with an exact comparison in your application.

Step 1: Both revisions as anchors — the diagnostic

curl -s -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{
    "model": "nli-default",
    "statement": "The archive retention period is exactly 30 days.",
    "truth_anchors": [
      "Revision 1 states that the archive retention period is exactly 30 days.",
      "Revision 2 states that the archive retention period is exactly 90 days."
    ],
    "closed_world": false,
    "contradiction_threshold": 0.6, "entailment_threshold": 0.6
  }' http://localhost:8080/v1/ai/nli/verify

Observed on v2.1.1-ce with nli-default: entailment 0.98 on revision 1, contradiction 1.00 on revision 2 → verdict LIE (contradiction takes priority). The revisions pull in opposite directions, and the conflict is flagged. Numeric wording is where NLI models miss most often, so treat this as a conflict detector and record what your model actually returns on your own wording before automating anything on it.

Step 2: Select the active revision first — the production pattern

curl -s -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  -d '{
    "model": "nli-default",
    "statement": "The archive retention period is exactly 90 days.",
    "truth_anchors": ["The active archive policy sets the retention period to exactly 90 days."],
    "closed_world": false,
    "contradiction_threshold": 0.6, "entailment_threshold": 0.6
  }' http://localhost:8080/v1/ai/nli/verify

Expected (verified): verdict TRUTH, entailment 0.98. Your application selects which revision is active — the classifier does not know that later documents supersede earlier ones.

Honest boundaries

For an authoritative retention value, parse the active revision into a typed number and compare with SQL — WHERE retention_days = 90 cannot be sweet-talked by phrasing. Use NLI for the wording around the number, not the number.

Key Concepts Learned

  • Revision selection is application logic; NLI sees only the text supplied.
  • Numeric and temporal claims deserve typed comparison; NLI is the second-opinion layer.

Tags

nliclaim-verificationdocument-managementrevisionsnumeric-pitfallsrest