Hierarchy (view full)

Implements

Constructors

Properties

accessToken: string
baiduApiKey: string
baiduSecretKey: string
batchSize: number = 16

The maximum number of characters allowed for embedding in a single request varies by model:

  • Embedding-V1 model: up to 1000 characters
  • bge-large-zh model: up to 2000 characters
  • bge-large-en model: up to 2000 characters
  • tao-8k model: up to 28000 characters

Note: These limits are model-specific and should be adhered to for optimal performance.

modelName: "embedding-v1" | "bge_large_zh" | "bge_large_en" | "tao-8k" = "embedding-v1"

Model name to use

stripNewLines: boolean = true

Whether to strip new lines from the input text.

Methods

  • Method to generate embeddings for an array of documents. Splits the documents into batches and makes requests to the BaiduQianFan API to generate embeddings.

    Parameters

    • texts: string[]

      Array of documents to generate embeddings for.

    Returns Promise<number[][]>

    Promise that resolves to a 2D array of embeddings for each document.

  • Method to generate an embedding for a single document. Calls the embeddingWithRetry method with the document as the input.

    Parameters

    • text: string

      Document to generate an embedding for.

    Returns Promise<number[]>

    Promise that resolves to an embedding for the document.

Generated using TypeDoc