Class for generating embeddings using the Minimax API. Extends the Embeddings class and implements MinimaxEmbeddingsParams

const embeddings = new MinimaxEmbeddings();

// Embed a single query
const queryEmbedding = await embeddings.embedQuery("Hello world");
console.log(queryEmbedding);

// Embed multiple documents
const documentsEmbedding = await embeddings.embedDocuments([
"Hello world",
"Bye bye",
]);
console.log(documentsEmbedding);

Hierarchy (view full)

Implements

Constructors

Properties

apiUrl: string
batchSize: number = 512

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

model: string = "embo-01"

Model name to use

modelName: string = "embo-01"

Model name to use Alias for model

stripNewLines: boolean = true

Whether to strip new lines from the input text. This is recommended by Minimax, but may not be suitable for all use cases.

type: "query" | "db" = "db"

The target use-case after generating the vector. When using embeddings, the vector of the target content is first generated through the db and stored in the vector database, and then the vector of the retrieval text is generated through the query. Note: For the parameters of the partial algorithm, we adopted a separate algorithm plan for query and db. Therefore, for a paragraph of text, if it is to be used as a retrieval text, it should use the db, and if it is used as a retrieval text, it should use the query.

apiKey?: string

Secret key to use when making requests. Defaults to the value of MINIMAX_API_KEY environment variable.

basePath?: string = "https://api.minimax.chat/v1"
headers?: Record<string, string>
minimaxApiKey?: string

Secret key to use when making requests. Defaults to the value of MINIMAX_API_KEY environment variable. Alias for apiKey

minimaxGroupId?: string

API key to use when making requests. Defaults to the value of MINIMAX_GROUP_ID environment variable.

Methods

  • Method to generate embeddings for an array of documents. Splits the documents into batches and makes requests to the Minimax 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.

""