Skip to content

Add index to embeddings

Bojan Marjanovic requested to merge bmarjanovic/add-index-to-embeddings into master

What does this MR do and why?

As per https://gitlab.com/gitlab-org/gitlab/-/issues/410581+, we are adding an index to the embeddings.

We changed the distance function to use cosine similarity (cosine) per OpenAI docs.

We refactored the neighbor_for scope, and got rid of select query, since the nearest_neighbors is already returning the nearest and not all the neighbors.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Bojan Marjanovic

Merge request reports