Hierarchy (view full)

Implements

Constructors

Properties

apiKey: string
batchSize: number = 24

The maximum number of documents to embed in a single request. This is limited by the AlibabaTongyi API to a maximum of 2048.

modelName: "text-embedding-v2" = "text-embedding-v2"

Model name to use

parameters: undefined | {
    text_type?: "text" | "document";
}

Type declaration

  • Optional text_type?: "text" | "document"

    取值:query 或者 document,默认值为 document 说明:文本转换为向量后可以应用于检索、聚类、分类等下游任务, 对检索这类非对称任务为了达到更好的检索效果建议区分查询文本(query)和 底库文本(document)类型, 聚类、分类等对称任务可以不用特殊指定, 采用系统默认值"document"即可

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 AlibabaTongyi 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