AI Glossary / Natural language and speech / Intermediate

Semantic similarity

Definition

Semantic similarity is the degree to which two words, phrases, sentences, or other representations resemble one another in meaning. A computational similarity score estimates that resemblance under a particular method. The score depends on the representations, comparison function, and task; it is not an objective percentage of shared meaning.

What it means

“Purchase” and “buy” can have similar meanings, while “purchase” and “receipt” are related through an activity without meaning the same thing. Semantic similarity is often distinguished from this broader semantic relatedness. The distinction matters when a system must find paraphrases rather than merely retrieve material on the same topic.

At sentence level, comparison must account for how words combine. “Nora helps Sam” and “Sam helps Nora” share vocabulary but reverse the roles. A useful score should reflect the distinction relevant to the application, although actual models may miss it.

How it works

One family of methods compares concepts within a structured lexical resource. Another represents language as vectors derived from textual usage or model training, then compares those vectors. Cosine similarity, for example, compares vector directions after accounting for their lengths.

Sentence Transformers documentation demonstrates embedding texts and computing pairwise scores. It also supports several comparison functions, which have different numerical behavior. Choosing a function is only part of the system: the embedding model must preserve the distinctions the task needs.

Evaluation compares model behavior with suitable human judgments or task outcomes. A decision threshold is selected for a particular use case and tested on representative data. A threshold that works for one model or domain should not be assumed transferable to another.

Three practical examples

1. A help center groups differently worded questions about resetting a password. Similarity can propose candidate duplicates, while a reviewer checks whether account recovery and password change require different answers.

2. A research assistant retrieves passages resembling a query in meaning. The retrieved passages still need inspection for relevance and factual support.

3. A content team compares two versions of a short instruction. A similarity score may identify broad continuity, but changes to negation, numbers, and conditions need explicit review because they can alter the instruction substantially.

Think of it this way

Think of placing descriptions on a map so that nearby positions suggest resemblance. The usefulness of the map depends on which features determined the positions and how distance is measured. A map can bring useful neighbors together while hiding an important distinction. Unlike a physical map, a learned semantic space has no guaranteed correspondence to a single agreed geography of meaning.

Worked example

Consider two invented two-dimensional vectors, A=(3,4) and B=(6,8). A has length 5 and B has length 10. Their dot product is 3 times 6 plus 4 times 8, which equals 50. Cosine similarity is 50 divided by (5 times 10), so it equals 1.

Now compare A with C=(4,-3). C has length 5 and the dot product is 3 times 4 plus 4 times -3, which equals 0. Their cosine similarity is therefore 0. The vectors A and B have the same direction despite different lengths, whereas A and C are perpendicular.

These numbers establish geometric relationships only. No words or sentences have been encoded in this example, so it demonstrates no semantic judgment. If an actual model assigned A and B to two contradictory sentences, their cosine of 1 would expose a representational problem for a contradiction-sensitive task. It would not make the sentences equivalent. For nonzero real vectors cosine ranges from -1 to 1; a zero vector requires special handling because the denominator vanishes.

Illustrative case study

Illustrative fictional case: Northline Support proposes merging two articles because their embeddings are close. Both discuss cancellation, but one says customers may cancel before dispatch and the other describes what happens after dispatch.

The editor retains separate instructions and uses similarity to suggest cross-links instead of automatic merging. The team then includes conditions and time boundaries in its evaluation set. This fictional scenario shows why the intended use determines acceptable errors; it provides no claimed deployment results.

Common misconceptions and mistakes

A high score does not establish truth, entailment, or interchangeability. Two texts can discuss the same claim while disagreeing about it.

Do not read cosine 0.8 as “80% the same meaning.” Such a probability interpretation requires a separately defined and validated model.

Similar-looking scores from different models may not be comparable. Differences in training, normalization, and scoring function can change their distribution.

Word overlap is neither necessary nor sufficient for semantic similarity. Paraphrases may share few words, while reversed roles or added negation can change a sentence with minimal lexical change.

Business use

Business teams can use similarity to improve search, group enquiries, identify candidate duplicates, and support editorial review. Begin by defining what should count as a useful match. Topic resemblance, equivalent instructions, and interchangeable answers are different requirements.

Build test pairs that reflect that requirement, including difficult near-matches. Review false matches and missed matches separately. If a system ranks candidates, measure ranking quality; if it automatically merges records, examine the consequences of an incorrect merge. Record the model and scoring method so later changes can be evaluated consistently. Preserve access to the underlying text rather than presenting an unexplained score as the final evidence.

People also ask

Is semantic similarity the same as relatedness?

Usually similarity is narrower. Two concepts can participate in the same situation without resembling each other in meaning.

Does a negative cosine mean two sentences contradict each other?

Not necessarily. It means their vectors point in opposing directions under that representation; contradiction requires a suitable semantic assessment.

Is there one correct threshold?

No. The threshold depends on the model, data, decision, and costs of errors. It should be evaluated for the specific application.

Check your understanding

Two nonzero vectors are (3,4) and (6,8). Their cosine is 1. What can we conclude without knowing how they were generated?

Answer: They point in the same direction. We cannot conclude that any associated texts are true, interchangeable, or semantically identical without evaluating the representation and task.

Related terms

  • Cosine similarity
  • Embedding
  • Semantic space
  • Textual entailment
  • Nearest neighbor search
  • semantic relatedness
  • embeddings
  • paraphrase detection

Learn next

Create pairs that are paraphrases, merely related, contradictory, and unrelated. State the intended comparison before examining model scores. Include a changed number or reversed participant to test whether the representation preserves task-critical details.

More in Natural language and speech

  • Semantic parsing - Semantic parsing is the task of converting a natural-language utterance into a formal representation of its meaning.
  • Semantic role - A semantic role describes how a participant or circumstance relates to a predicate's event or situation.
  • Semantic role labeling - Semantic role labeling, or SRL, is the task of identifying a predicate's arguments and assigning labels that describe their roles in the event or situation.
  • Semantometrics - Semantometrics is an approach to research evaluation that uses the semantic content of scholarly publications, often together with their relationships in...
  • Semivowel - A semivowel is a vowel-like speech sound that functions outside the syllable nucleus, commonly called a glide.
  • Sentence extraction - Sentence extraction is a summarization technique that selects complete sentences from source material and uses them in a shorter output.

Sources

Jurafsky and Martin, Speech and Language Processing, chapter 5, Embeddings: https://web.stanford.edu/~jurafsky/slp3/5.pdf

Sentence Transformers, Semantic Textual Similarity documentation: https://www.sbert.net/docs/sentence_transformer/usage/semantic_textual_similarity.html

Primary textbook and implementation documentation were read. The vectors and calculations are original teaching examples; they are not outputs from an embedding model.

Previous: Semantic service-oriented architecture Next: Semantic similarity network

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer