← Back to article

Equation 8 · How Llama's Architecture Actually Works, Generation by Generation

What does this equation mean?

x2i−1′=x2i−1cos⁡(mθi)−x2isin⁡(mθi)x2i′=x2i−1sin⁡(mθi)+x2icos⁡(mθi)\begin{aligned} x'_{2i-1} &= x_{2i-1}\cos(m\theta_i) - x_{2i}\sin(m\theta_i) \\ x'_{2i} &= x_{2i-1}\sin(m\theta_i) + x_{2i}\cos(m\theta_i) \end{aligned}

Read the formula alongside the article passage below. Each part has a deeper page with its role in the equation, the supporting passage and nearby citations.

This equation states an equality: the expressions on both sides have the same value under the article’s assumptions. Read the equation part by part below; each part has a contextual explanation and a link to its mathematical background.

Read it piece by piece

xx

Symbol x

x is part of the quantity the equation computes from the expression on the right.

Understand this part →

ii

Symbol i

the pair.

Understand this part →

x2i−1x_{2i-1}

Symbol x_2i-1

x2x_2i-1 is one of the signed contributions combined to compute the quantity on the left.

Understand this part →

mm

Symbol m

a position index.

Understand this part →

θi\theta_i

Symbol theta_i

thetaia_i is one of the signed contributions combined to compute the quantity on the left.

Understand this part →

x2ix_{2i}

Symbol x_2i

x2x_2i is one of the signed contributions combined to compute the quantity on the left.

Understand this part →

=

=

The expressions on both sides represent the same quantity under the stated assumptions.

Understand this part →

See an illustrated explanation →
addition

addition

Add the term after the plus sign to the term or group before it.

Understand this part →

subtraction

subtraction

Subtract the following term or group from the preceding one. A leading minus marks a negative quantity.

Understand this part →

subscript

subscript

The lower label selects a particular version, component, or indexed member of the quantity. For example, x₀ and xₜ can be values at different positions.

Understand this part →

How to interpret it

Read it with the definitions, units, and assumptions supplied by the article.

What the article says around this equation

and a vector at sequence position m has its i -th pair rotated by angle mθi\theta_i : x2i−1′=x2i−1cos⁡(mθi)−x2isin⁡(mθi)x2i′=x2i−1sin⁡(mθi)+x2icos⁡(mθi)\begin{aligned} x'_{2i-1} &= x_{2i-1}\cos(m\theta_i) - x_{2i}\sin(m\theta_i) \\ x'_{2i} &= x_{2i-1}\sin(m\theta_i) + x_{2i}\cos(m\theta_i) \end{aligned}. The property that makes this useful rather than merely elegant is that rotating a query at position m and a key at position n by these matrices before taking their dot product leaves a result that depends only on the distance between them:

Read the equation in its article →

Sources cited in the article section

These citations give research context. Read each source to check which claims it supports.

Return to How Llama's Architecture Actually Works, Generation by Generation

See this formula across 1 published context →

Browse the mathematical compendium →