> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# ai_similarity

> Asks a chat model to evaluate the semantic similarity of two texts.

Asks a chat model to evaluate the semantic similarity of two texts.

## Syntax

```sql theme={null}
ai_similarity(input, other[, provider[, model]])
```

## Arguments

* `input`: A VARCHAR expression containing the first text.
* `other`: A VARCHAR expression containing the second text.

For the types and default behavior of `provider` and `model`, see [Common calling rules](/documents/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#common-calling-rules).

## Return value

Returns a nullable FLOAT in the range `[0, 1]`. A higher value indicates greater semantic similarity according to the model. Responses that cannot be parsed or are outside this range are treated as row-level errors.

The score is generated by a chat model; it is not a distance calculation between embedding vectors.

## Examples

```sql theme={null}
SELECT ai_similarity('A cat is sleeping.', 'A kitten is taking a nap.');

SELECT ai_similarity(
    input => 'A cat is sleeping.',
    other => 'A kitten is taking a nap.',
    provider => 'support_chat'
);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.