Similarity Search

Similarity search retrieves items that are close to a query under a chosen representation and similarity function. It is a task pattern shared by text retrieval, image search, molecule search, protein sequence search, nearest-neighbor baselines, and memory lookup.

The basic form is:

where is a query, is a candidate item, and are representations, is the corpus, and is a similarity score.

Representation Choices

DomainRepresentationCommon similarity
Textdense embedding, sparse vectorcosine, dot product, BM25 score
Imagepatch/global embeddingcosine, Euclidean distance
Moleculefingerprint, graph embedding, shape featureTanimoto, cosine, RMSD-like distance
Protein sequenceresidue embedding, k-mer, alignment featurecosine, identity, alignment score
3D structurecoordinates, distances, geometric graphRMSD, distance-map score, learned score

Changing the representation changes the task. A near neighbor under text embeddings is not necessarily a near neighbor under citation graph, timestamp, molecular scaffold, or 3D shape.

Metrics

  • Recall@: whether relevant items appear in the retrieved neighborhood.
  • Precision@: how many returned neighbors are relevant.
  • MRR: rank of the first relevant item.
  • nDCG: graded relevance under a ranked list.
  • Coverage: fraction of queries for which the index can return usable candidates.

Checks

  • What representation defines closeness?
  • Is the similarity score symmetric or query-conditioned?
  • Is the index exact, approximate, filtered, or hybrid?
  • Are near-duplicates and homologs handled by the split?
  • Is search used as a final task or as a recall stage before Reranking?
  • Is a simple nearest-neighbor baseline strong enough to explain the result?