RopeScalingType

RopeScalingType selects the algorithm used to scale RoPE (Rotary Position Embedding) when the effective context size exceeds the model’s training window. Different algorithms produce different quality trade-offs at long contexts.

Quick reference

Type RopeScalingType? enum
Default null (use model default)
Values Unspecified, None, Linear, Yarn, LongRope
Category Position encoding
Field on ContextParameters.RopeScalingType

What it does

Transformer models use RoPE to encode token positions. The frequencies RoPE uses are trained on a specific maximum context. To go beyond that trained maximum, the position encoding must be scaled.

Value Behavior
Unspecified (-1) Use whatever the model’s GGUF metadata specifies.
None (0) No scaling; use raw RoPE. Only valid within the trained context.
Linear (1) Linear interpolation of positions. Simple, moderate quality loss.
Yarn (2) YaRN (Yet another RoPE extensioN) — higher quality at long contexts.
LongRope (3) LongRoPE algorithm for very extended contexts.

Most built-in presets leave this as Unspecified — the model’s metadata declares its own preferred scaling. Override only when you push the model past its declared maximum.

When to change it

Scenario Value
Default Unspecified (model’s metadata wins)
Run a model within its native context window None or Unspecified
Extend context 2-4× training window, simple scaling acceptable Linear
Extend context with better quality Yarn
Push toward 1M+ contexts LongRope (if model supports it)

Example

using Aspose.LLM.Abstractions.Models;

var preset = new Llama32Preset();
preset.ContextParameters.ContextSize = 131072;
preset.ContextParameters.RopeScalingType = RopeScalingType.Yarn;
preset.ContextParameters.YarnOrigCtx = 8192;  // the model's original training context

using var api = AsposeLLMApi.Create(preset);

Interactions

What’s next