llama_get_logits: Get logits from the last decode step

View source: R/llama.R

llama_get_logitsR Documentation

Get logits from the last decode step

Description

Returns the raw logit vector (unnormalized log-probabilities) from the last token position after a decode operation.

Usage

llama_get_logits(ctx)

Arguments

ctx

Context handle returned by [llama_new_context]

Value

A numeric vector of length n_vocab containing the logits.

Examples

## Not run: 
model <- llama_load_model("model.gguf")
ctx <- llama_new_context(model)
result <- llama_generate(ctx, "The capital of France is", max_new_tokens = 1L)
logits <- llama_get_logits(ctx)
# Find top token
top_id <- which.max(logits)

## End(Not run)

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