A class for generating embeddings using the DeepInfra API.

Example

// Embed a query using the DeepInfraEmbeddings class
const model = new DeepInfraEmbeddings();
const res = await model.embedQuery(
"What would be a good company name for a company that makes colorful socks?",
);
console.log({ res });

Hierarchy (view full)

Implements

Constructors

Properties

apiToken: string

The API token to use for authentication. If not provided, it will be read from the DEEPINFRA_API_TOKEN environment variable.

batchSize: number

The maximum number of texts to embed in a single request. This is limited by the DeepInfra API to a maximum of 1024.

modelName: string

The model ID to use for generating completions. Default: sentence-transformers/clip-ViT-B-32

Methods

  • Generates embeddings for an array of texts.

    Parameters

    • inputs: string[]

      An array of strings to generate embeddings for.

    Returns Promise<number[][]>

    A Promise that resolves to an array of embeddings.

  • Generates an embedding for a single text.

    Parameters

    • text: string

      A string to generate an embedding for.

    Returns Promise<number[]>

    A Promise that resolves to an array of numbers representing the embedding.

Generated using TypeDoc