Document compressor that uses Cohere Rerank API.

Hierarchy

  • CohereRerank

Constructors

Properties

client: CohereClient
maxChunksPerDoc: undefined | number
model: string = "rerank-english-v2.0"
topN: number = 3

Methods

  • Compress documents using Cohere's rerank API.

    Parameters

    • documents: DocumentInterface[]

      A sequence of documents to compress.

    • query: string

      The query to use for compressing the documents.

    Returns Promise<DocumentInterface[]>

    A sequence of compressed documents.

  • Returns an ordered list of documents ordered by their relevance to the provided query.

    Parameters

    • documents: any[]

      A list of documents as strings, DocumentInterfaces or objects with a pageContent key.

    • query: string

      The query to use for reranking the documents.

    • Optional options: {
          maxChunksPerDoc?: number;
          model?: string;
          topN?: number;
      }
      • Optional maxChunksPerDoc?: number

        The maximum number of chunks per document.

      • Optional model?: string

        The name of the model to use.

      • Optional topN?: number

        How many documents to return.

    Returns Promise<{
        index: number;
        relevanceScore: number;
    }[]>

    An ordered list of documents with relevance scores.

Generated using TypeDoc