Skip to content

DOC-765 | Cosine similarity fix for vector indexes #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 3 additions & 3 deletions site/content/3.12/aql/functions/vector.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ be found depends on the data as well as the search effort (see the `nProbe` opti
Retrieve the approximate angular similarity using the cosine metric, accelerated
by a matching vector index.

The higher the cosine similarity value is, the more similar the two vectors
are. The closer it is to 0, the more different they are. The value can also
be negative, indicating that the vectors are not similar and point in opposite
The closer the cosine similarity value is to 1, the more similar the two vectors
are. The closer it is to 0, the more different they are. The value can also be
negative up to -1, indicating that the vectors are not similar and point in opposite
directions. You need to sort in descending order so that the most similar
documents come first, which is what a vector index using the `cosine` metric
can provide.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ centroids and the quality of vector search thus degrades.
{{< tabs "interfaces" >}}

{{< tab "Web interface" >}}
{{< comment >}}TODO: Only in v3.12.6+
1. In the **Collections** section, click the name or row of the desired collection.
2. Go to the **Indexes** tab.
3. Click **Add index**.
Expand All @@ -124,8 +123,6 @@ centroids and the quality of vector search thus degrades.
under `param`.
7. Optionally give the index a user-defined name.
8. Click **Create**.
{{< /comment >}}
The web interface does not support vector indexes yet.
{{< /tab >}}

{{< tab "arangosh" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,17 @@ the following steps.
4. Restore the dump to the new deployment. You can directly move from any
3.11 or 3.12 version to 3.12.4 (or later) this way.

## Cosine similarity fix for vector indexes

<small>Introduced in: v3.12.6</small>

A normalization issue has been addressed for the experimental vector index type.
It was possible for the cosine similarity value returned by `APPROX_NEAR_COSINE()`
to be outside the expected range of `[-1, 1]`.

It is recommended to recreate all vector indexes that use the `cosine` metric
after upgrading to v3.12.6 or later.

## HTTP RESTful API

### JavaScript-based traversal using `/_api/traversal` removed
Expand Down
6 changes: 3 additions & 3 deletions site/content/3.13/aql/functions/vector.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ be found depends on the data as well as the search effort (see the `nProbe` opti
Retrieve the approximate angular similarity using the cosine metric, accelerated
by a matching vector index.

The higher the cosine similarity value is, the more similar the two vectors
are. The closer it is to 0, the more different they are. The value can also
be negative, indicating that the vectors are not similar and point in opposite
The closer the cosine similarity value is to 1, the more similar the two vectors
are. The closer it is to 0, the more different they are. The value can also be
negative up to -1, indicating that the vectors are not similar and point in opposite
directions. You need to sort in descending order so that the most similar
documents come first, which is what a vector index using the `cosine` metric
can provide.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,17 @@ the following steps.
4. Restore the dump to the new deployment. You can directly move from any
3.11 or 3.12 version to 3.12.4 (or later) this way.

## Cosine similarity fix for vector indexes

<small>Introduced in: v3.12.6</small>

A normalization issue has been addressed for the experimental vector index type.
It was possible for the cosine similarity value returned by `APPROX_NEAR_COSINE()`
to be outside the expected range of `[-1, 1]`.

It is recommended to recreate all vector indexes that use the `cosine` metric
after upgrading to v3.12.6 or later.

## HTTP RESTful API

### JavaScript-based traversal using `/_api/traversal` removed
Expand Down