Transformers and LLMs · 2021

RoFormer: Enhanced Transformer with Rotary Position Embedding

Jianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, Yunfeng Liu

Neurocomputing 2024 · arXiv 2104.09864 · Read the paper ↗

Encode position by rotating queries and keys, so attention scores depend on relative distance. Used by Llama and most open LLMs.

2 steps + 3 beyond the paper · 0 solved

Start: Rotary position embedding →
  1. 1Rotary position embeddingRotate each pair of dimensions by position times frequency.Rotate a vector by its position (RoPE)HardPro
  2. 2RoPE inside a blockUse RoPE with RMSNorm and SwiGLU in a Llama-style block.Convert a GPT block to a Llama-style block (RMSNorm, RoPE, SwiGLU)HardPro

Beyond the paper

Follow-up ideas that build on this paper. Each blurb names the follow-up work.

  1. 3Position interpolationExtension: stretch context by scaling positions (Chen et al., 2023).Position Interpolation for RoPE anglesEasy
  2. 4NTK-aware scalingExtension: scale the base instead of the positions.Scale RoPE frequencies with NTK-aware interpolationMedium
  3. 5YaRN frequency rampExtension: per-frequency interpolation (Peng et al., 2023).YaRN frequency ramp and attention temperatureHardPro

More transformers and llms papers