TLDR Web Dev · MISCELLANEOUS

DON'T USE COSINE SIMILARITY CARELESSLY

p.migdal.pl14 min read

Summary from the TLDR Web Dev newsletter

Using cosine similarity carelessly when comparing vectors generated from text embeddings can be problematic. While seemingly simple and widely used, cosine similarity often fails to capture true semantic similarity, instead focusing on superficial aspects like writing style or matching questions to questions rather than questions to answers. More effective approaches include directly querying LLMs for similarity comparisons, training task-specific embeddings, and pre-processing text to remove irrelevant information before embedding.