Yes, using an inappropriate distance metric with embeddings can significantly degrade performance. Distance metrics quantify the relationship between vectors, and their effectiveness depends on how the embedding space is structured. For example, embeddings designed to encode semantic similarity through direction (like unit-normalized word vectors) rely on angular relationships, making cosine similarity or dot product the natural choice. Euclidean distance, which measures straight-line distance between points, would introduce noise by conflating direction and magnitude—even when magnitude is irrelevant. This misalignment distorts similarity comparisons, leading to suboptimal results in tasks like clustering, retrieval, or classification.
Consider embeddings generated by models like Word2Vec or GloVe, which often normalize vectors to unit length to emphasize direction. Here, two words with similar semantics (e.g., "king" and "queen") might lie in nearly the same direction but have slightly different magnitudes due to training noise. Cosine similarity would correctly identify their semantic relationship by focusing on the angle between them, while Euclidean distance would exaggerate differences based on magnitude. Similarly, in contrastive learning setups like Siamese networks, embeddings are often optimized for cosine similarity. Using Euclidean distance during inference would fail to align with the training objective, reducing accuracy in tasks like face verification or duplicate detection.
The impact extends to algorithm performance. For instance, k-nearest neighbors (k-NN) classifiers or clustering algorithms like k-means rely heavily on distance metrics. If embeddings encode information in angles (e.g., in NLP or recommendation systems), Euclidean distance would group vectors with similar magnitudes but unrelated directions, or separate vectors with identical directions but varying magnitudes. In image retrieval, using Euclidean distance on embeddings optimized for cosine similarity (e.g., CLIP embeddings) might prioritize brightness or contrast over semantic content. Always validate the metric assumptions (magnitude vs. direction) against the embedding training process and task requirements to avoid such pitfalls.