class
ion7.llm.Embed
Functions
Embed.new
Build an embedder.
Embed:_ensure_ctx
Lazy : build the embedding context on first use.
Embed:encode
Encode `text` into a Lua array of floats. The array length is the model's output embedding dimension (typically 384 / 768 / 1024 / 1536 / 4096 depending on the model).
Embed:encode_many
Encode a list of texts. Each text gets its own forward pass — no batched packing yet, but the embedding context is reused so the per-call overhead is tokenisation + decode only.
Embed.cosine
Cosine similarity between two equal-length float arrays. Returns a scalar in `[-1, 1]`.
Embed:pooling
Pooling strategy of the underlying context (after lazy creation), as a symbolic string. Useful for diagnostics.
Embed:free
Free the embedding context immediately. The model is left alone (the caller still owns it). Calling `:encode` after `:free` will lazy-rebuild a fresh context.