AI Glossary / Natural language and speech / Advanced
Similarity
Definition
Similarity is the degree to which two items resemble one another under a specified interpretation or representation. In lexical semantics, it commonly concerns shared meaning or properties, rather than every kind of association. In computational NLP, a similarity score estimates a chosen relationship using features, vectors, models, or human judgments; its meaning depends on that choice.
What it means
A sofa and an armchair share important properties, whereas an armchair and a person sitting in it are associated through an activity. Both relationships can be useful, but calling them the same thing can mislead an application.
The relevant resemblance depends on the task. Two support messages may describe the same issue using different wording, or share many words while making opposite claims. A spelling-based score, a semantic representation, and a task-specific matching model can rank those pairs differently.
Therefore, a high score should be read as high similarity according to this method, not proof that the texts are interchangeable, true, or equally relevant to every question.
How it works
Choose what is being compared and what resemblance matters. A system may compare shared terms, taxonomic relationships, learned embeddings, or representations produced jointly for a text pair. Human judgments can supply an evaluation reference when their instructions match the intended relation.
Cosine similarity compares the directions of nonzero vectors by dividing their dot product by the product of their lengths. Other measures preserve different information, including vector magnitude or exact lexical overlap. There is no universally best measure independent of the representation and task.
Evaluation must distinguish semantic similarity from broader relatedness when that distinction matters. The SimLex-999 research explicitly designed judgments around similarity, illustrating why the instructions behind an evaluation dataset are part of what its results mean.
Three practical examples
- A glossary editor uses similarity suggestions to find potentially overlapping definitions, then checks whether the terms are synonyms, subtypes, or merely associated concepts.
- A support system groups messages about comparable problems. It checks negation and product context before treating close wording as evidence of the same issue.
- A search team ranks documents using an embedding score but evaluates whether the results answer users' questions. Similarity supplies a ranking signal, while relevance remains a task judgment.
Think of it this way
Think of comparing objects with several measuring tools. A ruler compares lengths; a color chart compares colors. Neither gives the one true answer to which objects are alike. A similarity method is another measuring tool: useful when its measured property fits the decision, misleading when the score's meaning is left unspecified.
Worked example
Use three invented vectors: a = [1, 1], b = [2, 2], and c = [0.9, 1.1]. They are mathematical examples, not measured word embeddings.
The dot product a·b is 4. Their lengths are √2 and √8, whose product is 4, so cosine(a,b) = 1. Vector b points in exactly the same direction as a, despite being twice as long. For c, a·c = 2 and its squared length is 2.02. Thus cosine(a,c) = 2/√4.04, approximately 0.9950. Cosine ranks b slightly closer in direction to a than c.
Euclidean distance gives a different ranking. The distance from a to b is √2, approximately 1.4142. The distance from a to c is √0.02, approximately 0.1414. Under that measure, c is much closer. Neither calculation is wrong: they preserve different aspects of the vectors.
A cosine value of 1 therefore does not imply identical vectors, let alone identical meanings. A zero vector also has no defined cosine under this formula because its length makes the denominator zero. A practical implementation needs an explicit policy for that case.
Illustrative case study
Fictional publisher MeaningDesk compares proposed glossary entries to detect duplication. An initial review queue contains many strongly associated pairs that explain different concepts. Editors discover that the score is useful for finding a shared topic but does not reliably establish equivalence.
They label a review sample with separate relationships: equivalent meaning, narrower or broader meaning, associated topic, and unrelated. They then evaluate the matching method against the editorial decision it is meant to support. The original text remains visible beside every suggestion.
This fictional case illustrates a clearer evaluation target. It reports no measured accuracy gain and does not imply that a single numerical threshold can replace editorial judgment.
Common misconceptions and mistakes
Similarity is not identity. It is also not automatically synonymy, entailment, relevance, or truth. Two passages can be topically close while contradicting each other, and related words need not name similar kinds of things.
A score's numerical range does not make it a probability. Cosine values for real-valued vectors can range from −1 to 1; a negative value does not by itself establish that the words are antonyms. The geometry must be interpreted through the representation.
Do not transfer a cutoff between models or tasks without checking it. Changes in tokenization, pooling, normalization, training data, or the comparison set can affect score distributions and ranking behavior.
Business use
Similarity methods can help prioritize duplicate checks, retrieval, clustering, and content comparisons. Begin with examples of the decisions users actually need, including close but incorrect matches. Evaluate both missed matches and misleading suggestions. Record the representation and scoring method with the results so later changes can be understood. For consequential editorial or operational decisions, expose enough source context to verify the relationship being proposed.
People also ask
Can similar words have different meanings?
Yes. Similarity permits resemblance without equivalence; even close alternatives can differ in scope or usage.
Is cosine similarity always the right choice?
No. Its usefulness depends on whether direction in the selected vector space captures the relevant relationship.
Does a high sentence score prove a paraphrase?
No. Negation, quantities, participants, and conditions can differ despite a high model score.
Check your understanding
Why is cosine(a,b) equal to one?
Answer: The vectors point in the same direction and differ only by positive scale.
Why does Euclidean distance prefer c?
Answer: Its coordinates are closer to a's coordinates, even though its direction differs slightly.
What must be stated before a similarity score is useful?
Answer: What is compared, which representation and measure are used, and what relationship the task requires.
Related terms
- Semantic similarity
- Relatedness
- Cosine similarity
- Euclidean distance
- Embedding
- Relevance
- Entailment
- synonymy
- paraphrase
Learn next
Create a small set of pairs labeled for the relationship your application needs. Include synonyms, associated concepts, contradictions, and near-duplicate text with changed quantities. Compare rankings from different methods and inspect where their notion of resemblance diverges from the task.
More in Natural language and speech
- SGNS - SGNS stands for skip-gram with negative sampling, a method for learning word embeddings by distinguishing observed word - context pairs from sampled noise...
- Sibilant sound - A sibilant sound contains prominent hissing or hushing frication produced by a directed stream of air in the front of the mouth.
- Side sequence - A side sequence is a subsidiary stretch of conversation that temporarily interrupts an ongoing sequence before participants return to it.
- Sinewave synthesis - Sinewave synthesis, in speech research, creates an artificial speech-like signal by replacing changing vocal resonances with time-varying pure tones.
- Singleton - In coreference analysis, a singleton is an entity represented by only one mention within the text or annotation scope being considered.
- Singular they - Singular they is the use of “they,” “them,” “their,” or related forms to refer to one person.
Sources
Jurafsky and Martin, Speech and Language Processing, Chapter 5, lexical similarity, relatedness, and cosine: https://web.stanford.edu/~jurafsky/slp3/5.pdf Hill, Reichart, and Korhonen, SimLex-999: Evaluating Semantic Models With (Genuine) Similarity Estimation, 2015: https://aclanthology.org/J15-4004.pdf The vectors, comparisons, and MeaningDesk scenario are original illustrations.
Previous: Simalto Next: Similarity graph