← All posts

Semantic Similarity Isn't Logical Consistency

2026-06-21 ·

Two Problems That Look Identical

Take two sentences:

"The store opens at 9am."
"The store opens at 5pm."

Embed both with any off-the-shelf sentence transformer and compute cosine similarity, and you'll get a high score — often above 0.85. Same subject, same structure, nearly identical tokens.

But logically, the two sentences contradict each other. One of them is wrong.

This is the gap between semantic similarity and logical consistency, and it trips up a lot of NLP pipelines that quietly assume the two are interchangeable.


Why Embeddings Get This Wrong

Sentence embeddings are trained to cluster text by topic and structure, not by truth value. A model rewarded for putting paraphrases close together in vector space has no particular incentive to push contradictions apart — "the store opens at 9am" and "the store opens at 5pm" share almost every surface feature a topical-similarity objective cares about.

So when a downstream task actually needs entailment, contradiction, or neutrality — not just "are these about the same thing" — leaning on raw embedding distance quietly fails. The errors don't look like noise either; they cluster exactly where the two notions of "similar" disagree most.


Where This Bites in Practice

A few places this shows up:

  • Fact-checking pipelines that use retrieval similarity as a proxy for agreement, and end up "confirming" claims that are topically related but factually opposed.
  • Deduplication systems that merge near-duplicate records which actually disagree on a key field.
  • RAG retrieval that surfaces a passage discussing the right entity while asserting the wrong fact about it — high relevance, wrong content.

In each case, the system optimized for "sounds like the same thing" when it needed "agrees with the same thing."


Treating It as a Calibration Problem, Not a Similarity Problem

The fix isn't a bigger embedding model — it's reframing the task. Once you're asking "how logically aligned are these two statements," you're in entailment/regression territory, not nearest-neighbor territory:

  • Fine-tune directly on labeled entailment/contradiction/neutral pairs rather than inferring relationships from embedding distance.
  • Treat the output as a calibrated score, not a similarity threshold — a model can be very confident about a contradiction and still need to express how strong that contradiction is.
  • Stress-test on adversarial pairs that are lexically close but logically opposed. If your model only sees easy paraphrases and clear contradictions during training, it won't have learned to separate the two phenomena.

The Takeaway

"These two sentences are about the same thing" and "these two sentences agree with each other" are different questions, and a lot of architectures answer the first one by default whether you asked for it or not. Whenever a task description uses words like consistency, alignment, or agreement, it's worth pausing to check whether the pipeline is actually measuring that — or just measuring how similar the sentences sound.