llama_memory_seq_add: Shift token positions in a sequence

View source: R/llama.R

llama_memory_seq_addR Documentation

Shift token positions in a sequence

Description

Adds a position delta to all tokens in the given sequence within [p0, p1). This is useful for implementing context shifting (sliding window).

Usage

llama_memory_seq_add(ctx, seq_id, p0, p1, delta)

Arguments

ctx

Context handle returned by [llama_new_context]

seq_id

Sequence ID

p0

Start position (inclusive)

p1

End position (exclusive)

delta

Position shift amount (can be negative)

Value

No return value, called for side effects.

Examples

## Not run: 
# Shift positions left by 100 for context window management
llama_memory_seq_add(ctx, seq_id = 0L, p0 = 100L, p1 = -1L, delta = -100L)

## End(Not run)

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