# Similarity Metrics ExplainedBETA

Similarity metrics are used to measure similarities among vectors. Choosing an appropriate distance metric helps improve classification and clustering performance significantly.

Currently, Zilliz Cloud supports three types of similarity Metrics: **Euclidean distance (L2)**, **Inner product (IP)**, and **Cosine similarity (COSINE)**.

## Euclidean distance (L2)

Essentially, Euclidean distance measures the length of a segment that connects 2 points.

The formula for Euclidean distance is as follows:

where **a = (a _{0}, a_{1},..., a_{n-1})** and

**b = (b**are two points in n-dimensional Euclidean space.

_{0}, b_{1},..., b_{n-1})It's the most commonly used distance metric and is very useful when the data are continuous.

Zilliz Cloud only calculates the value before applying the square root when Euclidean distance is chosen as the distance metric.

## Inner product (IP)

The IP distance between two embeddings is defined as follows:

IP is more useful if you need to compare non-normalized data or when you care about magnitude and angle.

If you use IP to calculate similarities between embeddings, you must normalize your embeddings. After normalization, the inner product equals cosine similarity.

Suppose X' is normalized from embedding X:

The correlation between the two embeddings is as follows:

## Cosine similarity

Cosine similarity uses the cosine of the angle between two sets of vectors to measure how similar they are. You can think of the two sets of vectors as line segments starting from the same point, such as [0,0,...], but pointing in different directions.

To calculate the cosine similarity between two sets of vectors **A = (a _{0}, a_{1},..., a_{n-1})** and

**B = (b**, use the following formula:

_{0}, b_{1},..., b_{n-1})The cosine similarity is always in the interval **[-1, 1]**. For example, two proportional vectors have a cosine similarity of **1**, two orthogonal vectors have a similarity of **0**, and two opposite vectors have a similarity of **-1**. The larger the cosine, the smaller the angle between the two vectors, indicating that these two vectors are more similar to each other.

By subtracting their cosine similarity from 1, you can get the cosine distance between two vectors.

This is currently in beta. Upgrade your cluster to the beta version to utilize this new similarity metric.