Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AymanMahfuz27/modern_llm/llms.txt
Use this file to discover all available pages before exploring further.
RMSNorm
Root Mean Square Layer Normalization (Zhang & Sennrich, 2019). RMSNorm is a simplified normalization layer that scales activations by their RMS (root mean square) rather than using mean-centered variance like LayerNorm. This reduces computation while maintaining training stability.Mathematical formulation
Constructor
Dimension of the input vectors. Must be positive.
Small constant added to denominator for numerical stability. Must be positive.
Attributes
Input dimension size.
Epsilon value for numerical stability.
Learnable scale parameter γ of shape (hidden_dim,). Initialized to ones.
forward
Input tensor of shape (…, hidden_dim). The last dimension must match hidden_dim.
Returns
Normalized tensor with same shape as input.
Example
Complexity
O(hidden_dim) per token - linear in the feature dimension.SwiGLU
SwiGLU feedforward network (Shazeer, 2020; Chowdhery et al., 2022). SwiGLU combines the Swish activation function with a gating mechanism (GLU - Gated Linear Unit). It has been shown to improve model quality compared to traditional GELU or ReLU feedforward networks.Mathematical formulation
- W_g and W_v are the gate and value projections
- ⊙ is element-wise multiplication
- swish(x) = x · sigmoid(x)
Constructor
Input dimension. Must be positive.
Hidden dimension for intermediate projections. Must be positive. Typically 4x the in_features.
Output dimension. Defaults to in_features if not specified.
Whether to include bias terms in linear layers.
Attributes
Input dimension size.
Hidden dimension for gate/value projections.
Output dimension size.
Combined gate and value projection: in_features -> (hidden_features * 2).
Output projection: hidden_features -> out_features.
forward
Input tensor of shape (…, in_features).
Returns
Output tensor of shape (…, out_features).