IA3 › The IA3 Formulation

Michael BrenndoerferDecember 6, 202511 min read
Language AI HandbookAll chapters
Part 35 of 67Parameter-Efficient Fine-tuning
Chapter 261IA3 › The IA3 Formulation
Reading section 2 of 11 · The IA3 Formulation · 11 minSection 2 of 11 · 11 min

Book contents

Section 2 of 11 · 11 min read

IA3 › The IA3 FormulationOne section · Sections in this chapter2 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

To understand IA3 precisely, we need to first establish where in the transformer architecture it intervenes and why those specific locations were chosen. The choice of intervention points is not arbitrary: the IA3 authors made deliberate decisions based on where learned rescaling would have the most impact on downstream task performance, and understanding their reasoning deepens your intuition for the method as a whole.

A transformer block processes input through two major computational streams. The first is multi-head self-attention, which mixes information across positions. The second is the position-wise feed-forward network, which applies learned nonlinear transformations to each position independently. IA3 intervenes at three points: the key projections of attention, the value projections of attention, and the intermediate activations of the feed-forward network. Each intervention point controls a different aspect of how information flows through the model.

Skipping the query projection is a deliberate choice. Queries encode what a position is searching for, and modifying them would change the pattern of what information each position attends to. But keys and values play complementary roles that are arguably more important for task adaptation. Keys determine which other positions appear needed to each query. Values determine what information gets retrieved when attention weights are high. By rescaling keys, IA3 can change the effective relevance of token positions without changing the queries themselves. By rescaling values, IA3 can change the magnitude of information retrieved from different positions. Together, these two interventions give IA3 fine-grained control over what information each position collects from the context. The decision to include feed-forward intermediate activations reflects the fact that feed-forward networks in transformers function as key-value memories that store factual knowledge; rescaling their intermediate activations allows IA3 to selectively activate or suppress learned knowledge pathways.

Transformer Layer Computations

In multi-head attention, the model begins by computing queries, keys, and values through linear projections of the input:

Q=XWQK=XWKV=XWV\begin{aligned} Q &= XW_Q \\ K &= XW_K \\ V &= XW_V \end{aligned}

where:

  • QQ: the query matrix, shape (n×d)(n \times d)
  • KK: the key matrix, shape (n×d)(n \times d)
  • VV: the value matrix, shape (n×d)(n \times d)
  • XX: the input sequence matrix, shape (n×d)(n \times d)
  • WQW_Q: the query projection weight, shape (d×d)(d \times d)
  • WKW_K: the key projection weight, shape (d×d)(d \times d)
  • WVW_V: the value projection weight, shape (d×d)(d \times d)
  • nn: the number of tokens in the sequence
  • dd: the model hidden dimension

These projections then participate in scaled dot-product attention, where the query-key dot product determines attention weights and those weights are used to aggregate the values. The feed-forward network applies to each position independently after the attention output is combined and normalized, transforming the representation through a higher-dimensional space before projecting back down.

IA3 Rescaling Vectors

IA3 introduces three learned vectors per transformer layer:

  • ℓK∈Rd\ell_K \in \mathbb{R}^{d} for rescaling the key projections
  • ℓV∈Rd\ell_V \in \mathbb{R}^{d} for rescaling the value projections
  • ℓff∈Rdff\ell_{ff} \in \mathbb{R}^{d_{ff}} for rescaling feed-forward intermediate activations

The modified key and value computations become:

K′=ℓK⊙(XWK)V′=ℓV⊙(XWV)\begin{aligned} K' &= \ell_K \odot (XW_K) \\ V' &= \ell_V \odot (XW_V) \end{aligned}

where:

  • K′K': the rescaled key matrix, shape (n×d)(n \times d)
  • V′V': the rescaled value matrix, shape (n×d)(n \times d)
  • ℓK\ell_K: the learned rescaling vector for keys, shape (d,)(d,)
  • ℓV\ell_V: the learned rescaling vector for values, shape (d,)(d,)
  • XWKXW_K: the standard key projection of the input
  • XWVXW_V: the standard value projection of the input
  • ⊙\odot: element-wise multiplication, broadcast across the sequence length dimension nn

To see exactly how the broadcasting works, think about the shapes involved. The standard key projection XWKXW_K has shape (n×d)(n \times d): one dd-dimensional key vector per token. The rescaling vector ℓK\ell_K has shape (d,)(d,). When you broadcast this multiplication, ℓK[i]\ell_K[i] multiplies the ii-th dimension of every token's key vector simultaneously. If ℓK[i]=2.0\ell_K[i] = 2.0, the ii-th coordinate of every key in the sequence gets doubled. If ℓK[j]=0.3\ell_K[j] = 0.3, the jj-th coordinate of every key gets compressed to 30% of its original value. Every token in the sequence experiences the same rescaling, which is both a strength and a limitation: the rescaling is consistent and interpretable, but it cannot adapt differently to different positions.

Hadamard Product

The Hadamard product, denoted ⊙\odot, performs element-wise multiplication between vectors or matrices of the same shape. For two vectors a,b∈Rda, b \in \mathbb{R}^d, the Hadamard product gives (a⊙b)i=ai⋅bi(a \odot b)_i = a_i \cdot b_i for each index ii. For matrices, the operation applies to corresponding elements. This differs from the standard matrix product, which sums over the inner dimension. In IA3, the Hadamard product is applied with broadcasting: the scalar rescaling vector ℓ\ell of shape (d,)(d,) is broadcast across the sequence dimension to multiply a matrix of shape (n×d)(n \times d).

Feed-Forward Rescaling

For the feed-forward network, recall the standard two-layer structure. The input first passes through a linear projection to a higher-dimensional intermediate space, then through a nonlinearity, and finally through a second projection back to the original dimension:

h=γ(XW1)output=hW2\begin{aligned} h &= \gamma(XW_1) \\ \text{output} &= hW_2 \end{aligned}

where γ\gamma is the activation function (typically GELU in modern transformers), W1W_1 maps from dd to dffd_{ff}, and W2W_2 maps from dffd_{ff} back to dd. The intermediate representation hh lives in the larger dffd_{ff}-dimensional space, which is where the model stores much of its factual and contextual knowledge.

IA3 applies its rescaling to this intermediate representation:

h′=ℓff⊙hh' = \ell_{ff} \odot h

where:

  • h′h': the rescaled intermediate activation, shape (n×dff)(n \times d_{ff})
  • ℓff\ell_{ff}: the learned rescaling vector for feed-forward, shape (dff,)(d_{ff},)
  • hh: the original intermediate activation γ(XW1)\gamma(XW_1), shape (n×dff)(n \times d_{ff})
  • ⊙\odot: element-wise multiplication, broadcast across sequence positions
  • γ\gamma: the activation function, such as GELU
  • W1W_1: the first feed-forward projection, shape (d×dff)(d \times d_{ff})

The full modified feed-forward computation then becomes:

h=γ(XW1)h′=ℓff⊙houtput=h′W2\begin{aligned} h &= \gamma(XW_1) \\ h' &= \ell_{ff} \odot h \\ \text{output} &= h' W_2 \end{aligned}

The choice to rescale after the activation function rather than before is real. Before the activation, the values are linear projections with no sparsity structure. After the activation, especially with GELU or ReLU-like functions, many dimensions are near zero and a few are strongly activated. Rescaling after the activation means IA3 is working with the already-processed, nonlinearly transformed intermediate representations. It can amplify dimensions that are already highly activated (meaning the model found them relevant) or further suppress dimensions that are already near zero.

The key insight is that these rescaling operations work entirely in activation space. No weight matrix is ever modified. The model's learned linear transformations, its attention patterns in the absence of rescaling, and its feed-forward computations all remain perfectly intact. IA3's vectors form a thin layer of per-dimension "volume controls" that sit on top of the existing computations, redirecting information flow without changing the underlying computational primitives.

Initialization Strategy

IA3 initializes all rescaling vectors to all-ones: ℓK=ℓV=ℓff=1\ell_K = \ell_V = \ell_{ff} = \mathbf{1}. This is not a minor implementation detail; it is the key to why IA3 starts training from a stable, interpretable baseline.

When all rescaling values equal 1, the operation ℓ⊙h\ell \odot h simplifies to 1⊙h=h1 \odot h = h. Every activation passes through unchanged. The adapted model at initialization is therefore identical in behavior to the original pretrained model. There are no random perturbations, no scaling factors that might shift training dynamics, no initial distortion of the representations the model has learned over many billions of pretraining tokens. The first gradient step moves the rescaling vectors slightly away from the all-ones vector in whatever directions the task loss indicates are beneficial, and training proceeds from there.

This initialization strategy contrasts thoughtfully with LoRA's approach. In LoRA, matrix BB is initialized to all zeros and matrix AA is initialized with small random Gaussian values. The initial adaptation BA=0⋅A=0BA = 0 \cdot A = 0, so the LoRA-adapted model is also identical to the pretrained model at initialization. But LoRA reaches this through cancellation (zero times anything is zero), while IA3 reaches it through identity scaling (one times anything is itself). Both approaches reach the same goal of starting from the pretrained model, but through philosophically different mechanisms. The IA3 approach is arguably more direct: the adaptation starts as a no-op because every individual scaling value is exactly one, not because two matrices happen to multiply to zero.

Out[4]:
Visualization
Scatter plot of 50 points forming a roughly circular shape centered at the origin in 2D space with axes labeled Dimension 1 and Dimension 2.
Original activation vectors in 2D space form an isotropic circle before task-specific adaptation begins.
Scatter plot of 50 coral-colored points forming an ellipse stretched horizontally and compressed vertically, illustrating IA3 diagonal scaling with factors 1.8 and 0.5.
After IA3 diagonal scaling with factors 1.8 and 0.5, the circle becomes an axis-aligned ellipse. Dimension 1 is amplified while Dimension 2 is suppressed. Unlike LoRA, which can rotate the representation space into new orientations, IA3 only stretches or compresses along the existing coordinate axes, reweighting learned features while keeping the geometric structure built during pretraining.

Reformulation as Diagonal Matrix Multiplication

The element-wise multiplication in IA3 has an elegant matrix-algebraic interpretation that reveals its basic constraints and expressivity. If we define LK=diag(ℓK)L_K = \text{diag}(\ell_K) as the d×dd \times d diagonal matrix with the rescaling vector ℓK\ell_K on its main diagonal and zeros everywhere else, then the element-wise multiplication ℓK⊙(XWK)\ell_K \odot (XW_K) is equivalent to right-multiplying the projected representation by this diagonal matrix:

K′=ℓK⊙(XWK)(element-wise multiplication)=(XWK)LK(rewrite as diagonal matrix multiplication)\begin{aligned} K' &= \ell_K \odot (XW_K) && \text{(element-wise multiplication)} \\ &= (X W_K) L_K && \text{(rewrite as diagonal matrix multiplication)} \end{aligned}

where:

  • K′K': the rescaled key matrix
  • ℓK\ell_K: the rescaling vector, shape (d,)(d,)
  • XX: the input sequence, shape (n×d)(n \times d)
  • WKW_K: the pretrained key projection, shape (d×d)(d \times d)
  • LKL_K: the diagonal matrix formed from ℓK\ell_K, shape (d×d)(d \times d)

This reformulation exposes a key algebraic fact: we could equivalently think of IA3 as right-multiplying the weight matrix WKW_K by the diagonal matrix LKL_K. The effective weight matrix after IA3 adaptation would be WKLKW_K L_K. Each column of WKW_K gets scaled by the corresponding entry of ℓK\ell_K. This observation is what lets inference-time merging of IA3 into the base model, which we will cover later.

More importantly, this reformulation reveals the expressivity class that IA3 belongs to. A diagonal matrix can only stretch or compress coordinates independently along the existing axes. It cannot rotate the coordinate system. It cannot mix information between dimensions. It cannot create new directions in the representation space. Compare this to LoRA's update BABA, where BB and AA are general d×rd \times r and r×dr \times d matrices respectively. The product BABA can express any linear transformation of rank at most rr: rotations, reflections, projections onto arbitrary subspaces, and more. IA3's diagonal update is strictly less expressive than LoRA's rank-1 update for any d>1d > 1. Yet IA3 often performs comparably in practice, which tells us something deep about the nature of fine-tuning.