Hierarchy

  • Embeddings
    • BaiduQianfanEmbeddings

Implements

Constructors

Properties

accessToken: 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.

caller: AsyncCaller

The async caller should be used by subclasses to make any async calls, which will thus benefit from the concurrency and retry logic.

embeddings: any
modelName:
    | "Embedding-V1"
    | "bge-large-zh"
    | "bge-large-en"
    | "tao-8k" = "Embedding-V1"

Model name to use

qianfanAK: undefined | string
qianfanAccessKey: undefined | string
qianfanSK: undefined | string
qianfanSecretKey: undefined | string
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.