---
title: Transformer Initialization
url: https://www.emergentmind.com/topics/transformer-initialization
type: topic
---

# Transformer Initialization

A transformer’s initialization strategy determines the inductive bias, signal propagation, and learning dynamics at the onset of training, directly affecting everything from convergence speed and stability to the regime (memorization vs. reasoning) in which the model operates. The design and selection of transformer initialization is thus an active and diversified research area encompassing variance-preserving schemes, structural and transfer-based initializations, and task-specific or architecture-dependent methods.

## 1. Mathematical Principles of Transformer Initialization

For a transformer with $L$ layers, hidden dimension $d$, and projection or feed-forward weights $W \in \mathbb{R}^{d_{\text{out}} \times d_{\text{in}}}$, the overarching objective of initialization is to keep both the forward signal variance and backward gradient variance bounded over depth. This requires careful selection of the variance, or occasionally spectral norm, of each parameter group based on the architecture’s recursion relations.

Key variance propagation equations at initialization are:
\[
\mathrm{Var}[y_j] = d_{\mathrm{in}}\;\mathrm{Var}[w]\;\mathrm{Var}[x] \stackrel{!}{=}\; \mathrm{Var}[x]
\implies \mathrm{Var}[w] = \frac{1}{d_{\mathrm{in}}}
\]
for linear layers, with generalization to nonlinear blocks by correcting for the second moment $\mathbb{E}[F(x)^2]$ of the nonlinearity $F$. For MLPs with ReLU or GELU, the critical constants are $c_{\phi} = \mathbb{E}[\phi(z)^2]/\mathrm{Var}[z]$ and $d_{\phi} = \mathbb{E}[\phi'(z)^2]$; fan-in scaling is then given by $\sigma_w^2 = 2/\mathrm{fan\_in}$ (He/Kaiming) for ReLU and $\sigma_w^2 \approx 1/(0.475\,\mathrm{fan\_in})$ for GELU [2510.09423]. 

In multi-head self-attention, Q/K/V projections follow a similar fan-in/fan-out scaling, often defaulting to $\sigma=0.02$ [2602.05927], while the output projection $W_O$ may receive additional scaling (e.g., $1/\sqrt{2L}$) in deeper transformers to stabilize residual magnitudes.

LayerNorm or pre-LayerNorm placement further regularizes activation variances, promoting power-law (rather than exponential) scaling of the averaged partial Jacobian norm (APJN) [2604.11890]. Normalization-free transformers require stricter control on initialization scale to avoid exponential or stretched-exponential signal amplification.

## 2. Structured Initialization: Encoding Inductive Bias

Standard initialization (e.g., Xavier/Glorot, He/Kaiming) treats weights as i.i.d. elements without architectural structure. However, inductive bias can be encoded at the initialization phase to enhance data efficiency or facilitate learning in challenging regimes, particularly for small datasets or data-limited tasks.

In vision transformers (ViTs), crafting $Q$, $K$ matrices per head to induce a softmax attention map mirroring a convolutional impulse filter—$H_\text{impulse} \in \{0,1\}^{N \times N}$—imposes spatial locality akin to CNNs [2505.19985, 2404.01139, 2401.12511]. The procedure computes
\[
P Q_{\mathrm{init}} K_{\mathrm{init}}^\top P^\top \approx \alpha\, H_\text{impulse} + \beta\, Z
\]
followed by SVD and normalization, with hyperparameters typically $(\alpha:\beta, \gamma, f) = (40:1, 2, 3)$. The attention maps constructed in this manner initialize the transformer to mimic local, shift-invariant receptive fields without modifying its architecture. This locality bias sharply increases small-data generalization and convergence (by 2–25% accuracy improvements on tasks like CIFAR, STL-10, Flowers, and Pets), while maintaining or slightly improving performance on large-scale datasets such as ImageNet-1K [2505.19985].

The structural approach can be extended to Swin Transformers (relative position biases), MLP-Mixer (factorizing token mixers to match convolution), and batch-specific setups.

## 3. Initialization Scale and Learning Regimes: Reasoning vs. Memorization

The scale parameter $\gamma$ in the standard deviation $\sigma = d_\mathrm{in}^{-\gamma}$ for weight initialization induces a bifurcation in training behavior: large $\gamma$ ($\sigma \ll d_\mathrm{in}^{-1/2}$) biases the transformer toward reasoning-driven, compositional, low-complexity solutions, while small $\gamma$ ($\sigma \sim d_\mathrm{in}^{-1/2}$ or larger) pushes the model toward symmetric, memorization-centric solutions [2405.05409, 2502.04375].

Empirical phase diagrams reveal a critical $\gamma_c \in (0.6, 0.7)$ for $L=2$–$12$ transformer blocks; for $\gamma > \gamma_c$, the model learns to generalize via inference over compositional primitives, while for $\gamma < \gamma_c$, it memorizes seen mappings with poor out-of-distribution generalization. The embedding and early attention matrices condense to low-rank, interpretable structures only in the inferential regime [2405.05409, 2502.04375]. These findings are validated across both synthetic compositional benchmarks and real-world datasets, providing actionable guidance for setting initialization variance to match the desired inductive learning regime.

## 4. Specialized Initialization Techniques for Deep and Variant Architectures

Transformers with large depth and modern variants (normalization-free, dynamic nonlinearities, etc.) encounter nontrivial optimization pathologies unless initialization is carefully tuned.

- **Depth-Scaled Initialization (DS-Init):** To counteract vanishing gradients in deep post-norm transformers (residuals + LayerNorm), DS-Init scales parameter variance in layer $l$ by $1/\sqrt{l}$:
  \[
  W^{(l)} \sim \mathrm{Uniform}\left(-\frac{\gamma \cdot \alpha}{\sqrt{l}}, \frac{\gamma \cdot \alpha}{\sqrt{l}}\right)
  \]
  yielding stable gradient flow and enabling training up to 24 layers [1908.11365].

- **Lipschitz-Constrained Parameter Initialization (LCPI):** All projection and feedforward matrices $W$ are initialized so that $\|W\|_2 \leq 1$ (e.g., $W \sim \mathrm{Uniform}(-1/\sqrt{\mathrm{fan_{in}}}, +1/\sqrt{\mathrm{fan_{in}}})$), ensuring every sublayer is $1$-Lipschitz at outset [1911.03179]. This prevents vanishing/shrinking of residuals post-LayerNorm for arbitrarily deep stacks.

- **Normalization-Free Transformers:** In architectures without LayerNorm (e.g., dynamic $\tanh$-like nonlinearities), initial weight scales $(\sigma_1,\sigma_2)$ must be reduced and managed carefully to avoid subcritical stretched-exponential gradient amplification across depth [2604.11890]. APJN analysis provides explicit recurrence relations and scaling laws.

- **Variance-Preserving Initialization for KANs in Transformers (KAT):** When Transformer MLPs are replaced by Kolmogorov-Arnold Networks (with learnable rational activations), weight scaling follows $\mathrm{Var}[w] = 1/(d_{\mathrm{in}} \cdot \mathbb{E}[F(x)^2])$, linking the initialization tightly to the activation's second moment [2409.10594].

## 5. Transfer and Meta-Initialization: Subcloning and Expansibility

Modern application scenarios often demand transformers at multiple sizes or with limited resources for pretraining.

- **Weight Subcloning:** To initialize a target transformer of reduced depth/width, neuron importance ranking and pruning identify the most salient output neurons for each layer in a large, pretrained “parent” model. The weights, reordered and scaled by $\sqrt{d/d'}$, are directly copied to the destination model, with Transformer blocks pruned by omitting blocks (preferably from the middle). This method preserves both variance structure and channel identity, yielding $4\times$ faster convergence in language and vision models [2312.09299].

- **Linear Expansion of “Learngene” (TLEG):** Observation of linearly-varying principal component projections across layers motivates representing all $L$ layer-parameters as interpolations between two learned “basis-layers” $(\theta_A, \theta_B)$. After a soft-distilled pretraining of an auxiliary network whose layers are linearly expanded from these bases, transformers of arbitrary depth $L$ can be initialized as $\theta_l = \theta_B + \frac{l-1}{L} \theta_A$ and fine-tuned for specific tasks. This achieves drastic reductions in pretraining and parameter storage cost while providing high transferability and competitive accuracy across downstream tasks [2312.05614].

## 6. Impact of Initialization on Model Bias and Identity

Contrary to the common assumption that random initialization confers only “neutral” priors to transformer models, mechanistic analysis shows that untrained transformers exhibit strong, seed-dependent structural biases. Two interacting forces—representation contraction via MLP nonlinearities and amplification by self-attention—cause output token probabilities to be highly non-uniform and persistently coupled to the initialization seed. This identity persists throughout training, enabling “birth-to-life” fingerprinting (SeedPrint), which robustly distinguishes between models initialized with different seeds even after extensive fine-tuning [2602.05927]. Additionally, these seed-dependent contractions explain the persistent “attention-sink” phenomena (e.g., variance concentration at the first token), which can be mitigated at initialization by explicit variance alignment interventions.

## 7. Practical Guidelines and Comparative Synthesis

A multifaceted summary of best practices is as follows:

| Initialization Type     | Recipe / Rationale                                          | When to Use / Outcome                  |
|------------------------|-------------------------------------------------------------|----------------------------------------|
| Variance-preserving (He, Xavier) | $\mathrm{Var}[w]=2/\mathrm{fan\_in}$ (ReLU), $1/\sqrt{0.475\,\mathrm{fan\_in}}$ (GELU) [2510.09423] | Default for stable signal and gradient propagation in standard architectures |
| Structured Impulse     | $Q,K$ engineered to produce impulse (convolutional) softmax maps [2505.19985] | Vision transformers on small data; outperforms standard, mimetic, or random init |
| Depth-Scaled (DS-Init) | $W^{(l)} \sim$ Uniform($-\gamma \alpha/\sqrt{l},+\gamma \alpha/\sqrt{l}$) [1908.11365] | Deep post-norm transformers; enables depth $>$12 |
| Lipschitz-Constrained  | $W \sim$ Uniform($-1/\sqrt{\mathrm{fan_{in}}},+1/\sqrt{\mathrm{fan_{in}}}$) [1911.03179] | Ensures sublayer Lipschitzness; deep encoders/decoders |
| Reasoning/Memory Bias  | $\sigma=d_{\mathrm{in}}^{-\gamma}$, set $\gamma>0.6$ for reasoning, $\gamma<0.6$ for memorization [2405.05409, 2502.04375] | Language models, compositional tasks: tune for desired inductive regime |
| Subcloning             | Pruning+scaling weights from a larger pretrained parent [2312.09299] | Rapid training of scaled-down models; resource scaling, transfer |
| Linear Expansion/TLEG  | Each layer $\theta_l = \theta_B + \frac{l-1}{L} \theta_A$, learned via distillation [2312.05614] | Elastic initialization for arbitrary depth; parameter efficiency |
| Variance-preserving KAN| $\mathrm{Var}[w]=1/(d_{\mathrm{in}} \mathbb{E}[F(x)^2])$ [2409.10594] | KATs/KAN-based architectures; stable training of learnable activation models |
| Positional Variance Calibration | Multiply $o_i \leftarrow \sqrt{i} o_i$ [2602.05927] | Remove attention sinks; improved token variance balance                 |

Parameter initialization thus operates beyond mere numerical stability, providing a mechanism to induce inductive biases, control learning regimes, fingerprint model identity, facilitate transfer, and optimize architectural scaling—all validated empirically with state-of-the-art results across language, vision, and multimodal benchmarks.

---

See [2505.19985], [2405.05409], [2502.04375], [2510.09423], [2602.05927], [1908.11365], [1911.03179], [2312.09299], [2312.05614], [2404.01139], [2401.12511], [2304.02034], [2406.03072], [2604.11890], [2409.10594], [2310.10353] for full technical and empirical details.

Source: https://www.emergentmind.com/topics/transformer-initialization