A class that provides synthetic embeddings by overriding the embedDocuments and embedQuery methods to generate embeddings based on the input documents. The embeddings are generated by converting each document into chunks, calculating a numerical value for each chunk, and returning an array of these values as the embedding.

Hierarchy

  • Embeddings
    • SyntheticEmbeddings

Implements

  • SyntheticEmbeddingsParams

Constructors

Properties

Methods

Constructors

  • Parameters

    • Optionalparams: SyntheticEmbeddingsParams

    Returns SyntheticEmbeddings

Properties

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.

vectorSize: number

Methods

  • Generates synthetic embeddings for a list of documents.

    Parameters

    • documents: string[]

      List of documents to generate embeddings for.

    Returns Promise<number[][]>

    A promise that resolves with a list of synthetic embeddings for each document.

  • Generates a synthetic embedding for a document. The document is converted into chunks, a numerical value is calculated for each chunk, and an array of these values is returned as the embedding.

    Parameters

    • document: string

      The document to generate an embedding for.

    Returns Promise<number[]>

    A promise that resolves with a synthetic embedding for the document.