Position Interpolation › Key Parameters
Language AI HandbookAll chapters Position Interpolation › Key ParametersOne section · Sections in this chapter10 / 12 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
When implementing Position Interpolation, the following parameters control the behavior:
-
train_length: The maximum sequence length the model was originally trained on (e.g., 2048 for LLaMA). This defines the upper bound of positions the model has learned to interpret during pretraining. It is typically documented in the model's configuration file and is not something you change; it is a property of the pretrained model. -
target_length: The extended context length you want to support (e.g., 8192). Must be greater thantrain_lengthfor interpolation to apply. Choosing this value requires thinking about your actual use case: what is the longest document or conversation you expect to encounter? Setting this too large degrades performance at all lengths; setting it too small may leave some inputs truncated. -
scale: Computed astrain_length / target_length. This determines how much to compress positions. A scale of 0.25 means 4x context extension. Smaller scale values enable longer contexts but reduce positional resolution proportionally. You do not set this directly; it is derived from the other two parameters. -
base: The RoPE base constant (typically 10000). Position Interpolation effectively increases this tobase / scale, slowing all rotations uniformly. You normally leave this at the model's default; it only matters if you are experimenting with modified base values. -
d_model: The embedding dimension. Must be even since RoPE operates on dimension pairs. Each pair rotates at a different frequency determined by its index. This is fixed by the model architecture and cannot be changed during inference.
When selecting parameters, consider the trade-off between context length and positional resolution. Extending by 2x is generally safe with minimal fine-tuning. Extensions of 4x-8x work well but require more fine-tuning to recover performance. Extensions beyond 8x may significantly degrade the model's ability to distinguish nearby positions. There is also a practical memory consideration: quadrupling the context length requires roughly quadrupling the memory for the KV cache, assuming standard multi-head attention. Techniques like sliding-window attention or sparse attention can help here, but they are orthogonal to the position encoding question.