Interface EmbeddingClient

All Known Implementing Classes:
OnnxEmbeddingClient, OpenAiEmbeddingClient

public interface EmbeddingClient
Pluggable backend that converts text into dense floating-point vectors.

All implementations must be thread-safe (the index build may call batchEmbed(List) from a background thread while searches run on the calling thread).

Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    List<float[]>
    Embeds multiple text chunks in one or more batched calls.
    float[]
    embed(String text)
    Embeds a single text chunk and returns a unit-length float vector.
    int
    Gets the number of dimensions in every returned vector.
    Gets the model identifier for this embedding client.
  • Method Details

    • embed

      float[] embed(String text) throws IOException
      Embeds a single text chunk and returns a unit-length float vector.
      Parameters:
      text - the text to embed (non-null, non-blank)
      Returns:
      float vector of length getDimension()
      Throws:
      IOException - on transport or API errors
    • batchEmbed

      List<float[]> batchEmbed(List<String> texts) throws IOException
      Embeds multiple text chunks in one or more batched calls.

      The returned list has the same size and ordering as texts.

      Parameters:
      texts - the texts to embed
      Returns:
      list of float vectors, one per input text
      Throws:
      IOException - on transport or API errors
    • getDimension

      int getDimension()
      Gets the number of dimensions in every returned vector.
      Returns:
      number of dimensions in every returned vector
    • getModelId

      String getModelId()
      Gets the model identifier for this embedding client.
      Returns:
      human-readable model identifier (e.g. "text-embedding-3-small")