Embeddings to use for embedding document contents and queries.
Similarity function for comparing documents.
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
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