← Back to LLMs Mind Map
中文·English
⚡ LLMsID: positional-encoding

Positional Encoding RoPE/ALiBi

位置编码 RoPE/ALiBi
🎯Core Definition
RoPE (Rotary Position Embedding) rotates the 2j2j-th and 2j+12j+1-th dims of Q/K by angle mθjm \theta_j with θj=10000−2j/d\theta_j = 10000^{-2j/d}, so the inner product of any positions mm, nn depends only on their relative distance m−nm - n; ALiBi instead adds a linear bias −m⋅∣i−j∣-m \cdot |i - j| to attention scores with zero parameters.
💡Use Cases
RoPE is used by essentially all mainstream models (LLaMA/Qwen/Mistral/Gemma; LLaMA-3 raises the base to 500000); ALiBi appears in BLOOM/MPT-style models that emphasize extrapolation and low cost; RoPE's formula, wavelength properties and extrapolation are staple interview topics.
⚡Key Problems Solved
learnable/absolute position embeddings fit a fixed length and fail beyond it; RoPE bakes position into a rotation that composes naturally with the dot product for relative positions, and its low-frequency dims rotate slowly (wavelength λj=2π⋅100002j/d\lambda_j = 2\pi \cdot 10000^{2j/d}, lowest freq ~62832 tokens), giving a local "recency" prior; ALiBi needs no parameters and extrapolates natively, but its long-range relative discrimination is weak.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Positional Encoding RoPE/ALiBi.
Use Cases
In production engineering, what are the primary use cases for Positional Encoding RoPE/ALiBi and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
RoPE rotation formula? Why does the inner product depend only on the relative offset m−nm - n?
2
RoPE wavelength: period of the lowest-frequency dim? When does base=10000 cause periodic ambiguity (~62K tokens; LLaMA-3 uses 500000)?
3
RoPE vs absolute and learnable position embeddings?
4
How ALiBi works, and its pros and cons?
5
Why can't RoPE extrapolate directly to longer sequences (leading to PI/NTK/YaRN)?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Positional Encoding RoPE/ALiBi"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice ➔
← Previous CardSSM & Hybrid ArchitecturesNext Card →RoPE Extrapolation PI/NTK/YaRN

🔗 More LLMs Knowledge Cards

Agent & Tool CallingAlignment Tax & Preference DataScaled Dot-Product AttentionAttention Variants MHA/MQA/GQA