embed abstract method
- String text, {
- 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:
embeddingis the float32 embedding vector with exactly dimensions elements.truncatedistrueiftextexceeded the model's context window and was silently truncated before embedding.
Implementation
Future<(Float32List embedding, bool truncated)> embed(
String text, {
EmbeddingKind kind = EmbeddingKind.document,
});