A retriever that uses two stores, a large and small (dictated by their dimensions) to retrieve documents.

Based off of the "Matryoshka embeddings: faster OpenAI vector search using Adaptive Retrieval" blog post https://supabase.com/blog/matryoshka-embeddings.

The MatryoshkaRetrieval retriever performs two semantic searches. The first uses the smaller store which returns many results, but is less accurate. Then, using the documents returned from the smaller store, the larger store is used to perform a more accurate search over the smaller set of documents.

The vector store must contain an id field in the metadata of each document. This is used to filter the results from the large store. You may override this metadata key by passing a custom idKey to the constructor.

Type Parameters

Hierarchy

  • Toolkit<Store>
    • MatryoshkaRetrieval

Constructors

Properties

Methods

Constructors

Properties

idKey: string = "id"
largeK: number = 5
largeStore: Store
smallK: number = 20

Methods

Generated using TypeDoc