A developer is creating a vector index on an Azure SQL Database table to support ANN search. The table contains 2 million rows with 1536-dimensional embeddings. The developer wants the index to optimize for cosine similarity. Which index metric should they specify?
- A. cosine✓ Correct
- B. manhattan
- C. euclidean
- D. dot_product
Explanation
The cosine metric should be specified when the application computes cosine similarity (or equivalently, cosine distance), which is the standard metric used with text and multimodal embeddings from models like OpenAI's text-embedding-ada-002. The index metric must match the distance function used at query time for the ANN index to accelerate searches correctly. The euclidean (L2) metric measures straight-line distance between vectors and is appropriate for geometric or spatial embeddings but not the typical choice for text embeddings with cosine similarity. The manhattan (L1) metric measures the sum of absolute differences and is rarely used with text embeddings. dot_product measures raw inner product without normalization; while related to cosine similarity for unit-normalized vectors, specifying it when the application uses cosine similarity would produce incorrect ANN results unless vectors are pre-normalized.