Generate embeddings from text using an embedding model.
Summary
Types
@type t() :: [float()]
Functions
@spec embed(LlamaCppEx.Model.t(), String.t(), keyword()) :: {:ok, t()} | {:error, String.t()}
Computes an embedding for a single text.
Options
:n_ctx- Context size. Defaults to2048.:pooling_type- Pooling type. Defaults to:unspecified(model's default). Values::unspecified,:none,:mean,:cls,:last.:normalize- Normalization mode.2= L2 (default),0= max-abs,-1= none.
@spec embed_batch(LlamaCppEx.Model.t(), [String.t()], keyword()) :: {:ok, [t()]} | {:error, String.t()}
Computes embeddings for multiple texts.
Packs multiple texts into a single context as distinct sequences and decodes
them in batches, rather than allocating a fresh context (and KV cache) per
text. Accepts the same options as embed/3, plus:
:max_batch_sequences- Max texts per decode batch. Defaults to64.
Pooled embeddings only. When :pooling_type is :none (no per-sequence pooled
vector exists), falls back to one context per text.