VECTOR_COSINE_SIMILARITY

functionsupportedAI & ML

docs.snowflake.com ↗

Vector functions

Computes the cosine similarity between two vectors. Cosine similarity is based on the angle between two vectors in a multi-dimensional space; the magnitude of the vectors is not considered. The cosine similarity value is the inner product of the vectors divided by the product of their lengths. The cosine similarity is always in the interval [-1, 1]. For example, identical vectors have a cosine similarity of 1, two orthogonal vectors have a similarity of 0, and two opposite vectors have a similarity of -1.

Syntax

VECTOR_COSINE_SIMILARITY( <vector>, <vector> )

Parameters

NameRequiredDescription
vectorrequiredThe VECTOR value to calculate the angle from.
vectorrequiredThe VECTOR value to calculate the angle to.

Returns

Returns a FLOAT value in the interval [-1, 1], which indicates the cosine similarity between the two input vectors.

Usage notes

See also

Referenced by