embed abstract method

Future<(Float32List, bool)> embed(
  1. String text, {
  2. EmbeddingKind kind = EmbeddingKind.document,
})

Embeds text into a dense float vector.

kind states whether text is being indexed (EmbeddingKind.document, the default) or is a search query (EmbeddingKind.query). Models that require different handling for the two cases (e.g. a mandatory "passage: "/"query: " prefix) branch on kind internally; models that don't need this distinction ignore it entirely, so passing the default is always safe for those models. Callers that know which case they're in (indexing vs. querying) should always pass the matching kind explicitly — silently treating every call as EmbeddingKind.document degrades retrieval quality for models that do use the distinction, without erroring.

Returns a record (embedding, truncated) where:

  • embedding is the float32 embedding vector with exactly dimensions elements.
  • truncated is true if text exceeded the model's context window and was silently truncated before embedding.

Implementation

Future<(Float32List embedding, bool truncated)> embed(
  String text, {
  EmbeddingKind kind = EmbeddingKind.document,
});