Class that represents a document compressor that uses embeddings to drop documents unrelated to the query.

Hierarchy

Constructors

Properties

embeddings: Embeddings

Embeddings to use for embedding document contents and queries.

similarityFn: ((X, Y) => number[][]) = cosineSimilarity

Type declaration

    • (X, Y): number[][]
    • Similarity function for comparing documents.

      Parameters

      • X: number[][]
      • Y: number[][]

      Returns number[][]

k?: number = 20

The number of relevant documents to return. Can be explicitly set to undefined, in which case similarity_threshold` must be specified. Defaults to 20

similarityThreshold?: number

Threshold for determining when two documents are similar enough to be considered redundant. Must be specified if k is not set.

Methods

  • 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.

    Parameters

    • documents: Document<Record<string, any>>[]

      An array of Document objects to be compressed.

    • query: string

      A query string.

    Returns Promise<Document<Record<string, any>>[]>

    A Promise that resolves with an array of compressed Document objects.

Generated using TypeDoc