| llama_get_embeddings_ith | R Documentation |
Returns the embedding vector for a specific token position after a decode call with embeddings enabled. Negative indices count from the end (-1 = last token).
llama_get_embeddings_ith(ctx, i)
ctx |
Context handle returned by [llama_new_context] |
i |
Integer index of the token (0-based, or negative for reverse indexing) |
A numeric vector of length n_embd.
## Not run:
model <- llama_load_model("model.gguf")
ctx <- llama_new_context(model)
llama_generate(ctx, "Hello world", max_new_tokens = 1L)
# Get the embedding of the last decoded token
emb <- llama_get_embeddings_ith(ctx, -1L)
cat("Embedding dim:", length(emb), "\n")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.