Override the default addDocuments
method to embed the documents twice,
once using the larger embeddings model, and then again using the default
embedding model linked to the vector store.
An array of documents to add to the vector store.
Optional
options: AddDocumentOptionsAn optional object containing additional options for adding documents.
A promise that resolves to an array of the document IDs that were added to the vector store.
A retriever that uses two sets of embeddings to perform adaptive retrieval. Based off of the "Matryoshka embeddings: faster OpenAI vector search using Adaptive Retrieval" blog post https://supabase.com/blog/matryoshka-embeddings.
This class performs "Adaptive Retrieval" for searching text embeddings efficiently using the Matryoshka Representation Learning (MRL) technique. It retrieves documents similar to a query embedding in two steps:
First-pass: Uses a lower dimensional sub-vector from the MRL embedding for an initial, fast, but less accurate search.
Second-pass: Re-ranks the top results from the first pass using the full, high-dimensional embedding for higher accuracy.
This code implements MRL embeddings for efficient vector search by combining faster, lower-dimensional initial search with accurate, high-dimensional re-ranking.