- Categories:
VECTOR_NORMALIZE¶
Normalizes a VECTOR in the L2 vector space, giving its elements values in the range of [0,1] and giving it a magnitude of 1.
- See also:
Syntax¶
VECTOR_NORMALIZE( <vector> )
Arguments¶
vectorA single VECTOR value to normalize.
Returns¶
Returns a VECTOR normalized to the L2 space, with values of type FLOAT.
Usage notes¶
Returns NULL when the input is NULL.
Vector functions are optimized in a way that can reduce floating point precision. This function’s results have a margin of error up to
1e-4.
Examples¶
This example demonstrates normalizing the vector [1, 2, 3]:
SELECT VECTOR_NORMALIZE([1, 2, 3]::VECTOR(INT, 3));
[0.267261, 0.534522, 0.801784]
This example shows how to re-normalize a truncated vector. The original vector is produced by EMBED_TEXT_768 with the snowflake-arctic-embed-m-v1.5 model, and then truncated to 256 elements. The truncated vector is then normalized:
VECTOR_NORMALIZE(
VECTOR_TRUNCATE(
SNOWFLAKE.CORTEX.EMBED_TEXT_768(
'snowflake-arctic-embed-m-v1.5',
'Analytical databases are typically column-oriented rather than row-oriented'
),
256
)
);