snowflake.snowpark.functions.ai_similarity¶
- snowflake.snowpark.functions.ai_similarity(input1: Union[Column, str], input2: Union[Column, str], **kwargs) Column[source]¶
Computes a similarity score based on the vector cosine similarity value of the inputs’ embedding vectors. Currently supports both text and image similarity computation.
- Parameters:
input1 – The first input for comparison. Can be a string with text or an image (FILE data type).
input2 – The second input for comparison. Can be a string with text or an image (FILE data type). Must be the same type as input1 (both text or both images).
**kwargs –
Configuration settings specified as key/value pairs. Supported keys:
- model: The embedding model used for embedding. For STRING input, defaults to ‘snowflake-arctic-embed-l-v2’.
For IMAGE input, defaults to ‘voyage-multimodal-3’. Supported values include: ‘snowflake-arctic-embed-l-v2’, ‘nv-embed-qa-4’, ‘multilingual-e5-large’, ‘voyage-multilingual-2’, ‘snowflake-arctic-embed-m-v1.5’, ‘snowflake-arctic-embed-m’, ‘e5-base-v2’, ‘voyage-multimodal-3’ (for images).
- Returns:
A float value of range -1 to 1 that represents the similarity score computed using vector similarity between two embedding vectors for the inputs.
Note
AI_SIMILARITY does not support computing the similarity between text and image inputs. Both inputs must be of the same type:
They are both Python
str.They are both
Columnobjects representing a FILE data type.
Examples: