CourseTransformers: From Attention to Trained, Served and Interpreted Models · Module 4: Positional Information · part 29 of 111
Part 29 · Module 4: Positional Information

Lesson 2: Positions inside attention: relative, ALiBi and rotary

24 min read·13 Oct 2026
Module 4 · Lesson 2 · About 55 minutes · Needs: Module 4, Lesson 1 (the position switch, AbsolutePositions, PosLab); Module 2, Lesson 5 (grouped-query attention)

The situation

Lesson 1 left Kofi Mensah a red row: past the trained length, both absolute methods failed. Yet base uses rotary positions, a choice nobody at Aurora Station has measured. "Earn it," Kofi says. "Build the methods that act inside attention, check rotary's claim in code, and race them all, three seeds each."

This lesson adds relative positions, ALiBi and rotary embeddings to tinyformer/positions.py, behind the same position switch.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.