llama_get_embeddings_seq: Get pooled embeddings for a sequence

View source: R/llama.R

llama_get_embeddings_seqR Documentation

Get pooled embeddings for a sequence

Description

Returns the pooled embedding vector for a given sequence ID after a batch decode. Only works when the model supports pooling (embedding models).

Usage

llama_get_embeddings_seq(ctx, seq_id)

Arguments

ctx

Context handle returned by [llama_new_context] with embedding = TRUE

seq_id

Integer sequence ID (0-based)

Value

A numeric vector of length n_embd.

Examples

## Not run: 
# Get pooled embedding for sequence 0 (requires embedding context)
model <- llama_load_model("nomic-embed.gguf")
ctx <- llama_new_context(model, embedding = TRUE)
mat <- llama_embed_batch(ctx, "Hello world")
emb <- llama_get_embeddings_seq(ctx, 0L)
cat("Pooled embedding dim:", length(emb), "\n")

## End(Not run)

llamaR documentation built on May 28, 2026, 1:06 a.m.