llama_encode: Encode tokens using the encoder (encoder-decoder models only)

View source: R/llama.R

llama_encodeR Documentation

Encode tokens using the encoder (encoder-decoder models only)

Description

Runs the encoder pass for encoder-decoder architectures (e.g. T5, BART). The encoder output is stored internally and used by subsequent decoder calls.

Usage

llama_encode(ctx, tokens)

Arguments

ctx

A context pointer (llama_context).

tokens

Integer vector of token IDs to encode.

Value

Integer return code (0 = success, negative = error).

Examples

## Not run: 
model  <- llama_load_model("t5-model.gguf")
ctx    <- llama_new_context(model)
tokens <- llama_tokenize(ctx, "Hello world")
llama_encode(ctx, tokens)

## End(Not run)

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