lucidrains/rotary-embedding-torch
A standalone PyTorch library implementing rotary positional embeddings from the Roformer paper for transformer architectures.

This library provides an efficient implementation of rotary embeddings (RoPE), a technique that rotates information into tensor axes to encode relative positional information in transformers. It integrates into attention mechanisms by rotating queries and keys prior to the dot-product attention operation. The approach improves upon traditional positional encodings by enabling seamless generalization to sequence lengths not seen during training.