Embeddings to use for embedding document contents and queries.
Optional
kThe number of relevant documents to return. Can be explicitly set to undefined, in which case similarity_threshold` must be specified. Defaults to 20
Similarity function for comparing documents.
This function calculates the row-wise cosine similarity between two matrices with the same number of columns.
The first matrix.
The second matrix.
A matrix where each row represents the cosine similarity values between the corresponding rows of X and Y.
Optional
similarityThreshold for determining when two documents are similar enough
to be considered redundant. Must be specified if k
is not set.
Abstract method that must be implemented by any class that extends
BaseDocumentCompressor
. This method takes an array of Document
objects and a query string as parameters and returns a Promise that
resolves with an array of compressed Document
objects.
An array of Document
objects to be compressed.
A query string.
A Promise that resolves with an array of compressed Document
objects.
Static
is
Class that represents a document compressor that uses embeddings to drop documents unrelated to the query.
Example