Skip to main content

Layer Normalisation Ontology

Transformer Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 29 October 2026
Audio Overview
FLOW ALGEBRA — LAYER NORMALISATION ONTOLOGY
Semantic Library | AI Core | Entity Graph | AI Entities | Transformer Entities
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/transformer-entities/layer-normalisation-ontology.html
Version: 1.0 | Date: 2026-10-29 | Encoding: UTF-8
Status: Companion formalisation based on established principles; source page content not verified.
Attribution: Kireth Research | Flow Algebra companion | Sky — Recursive AI

1. PURPOSE
Represent layer normalisation as a typed, deterministic feature-wise transformation within transformer architectures. Distinguish LayerNorm from RMSNorm, BatchNorm and residual addition.

2. ENTITY SET
E = {LayerNorm, InputTensor, FeatureAxis, Mean, Variance, Epsilon, Gamma, Beta, NormalisedTensor, OutputTensor, TransformerBlock, ResidualStream, AttentionSublayer, FeedforwardSublayer, Gradient, ParameterSet}.
RELATIONS:
  LayerNorm consumes InputTensor
  LayerNorm reduces_over FeatureAxis
  LayerNorm computes Mean and Variance
  LayerNorm uses Epsilon, Gamma and Beta
  LayerNorm produces OutputTensor
  TransformerBlock contains LayerNorm
  LayerNorm may_precede_or_follow AttentionSublayer and FeedforwardSublayer

3. STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t = input tensor and optional residual stream
R_t = mathematical transformation rules
B_t = numerical, dimensional and masking boundaries
K_t = parameter values, configuration and implementation knowledge
S_(t+1) = Update(S_t, LayerNorm(I_t))

4. FORMAL OPERATIONS
For x in R^(... x d), d >= 1, and each position independently:
  mu = (1/d) * sum_(j=1)^d x_j
  var = (1/d) * sum_(j=1)^d (x_j - mu)^2
  z_j = (x_j - mu) / sqrt(var + epsilon)
  y_j = gamma_j * z_j + beta_j
  LN(x; gamma,beta,epsilon) = y
where gamma,beta in R^d, epsilon > 0 and var is the population variance over the selected features.
Input and output shapes are identical. Statistics are computed separately for each non-normalised index.

5. FLOW ALGEBRA
flow "LayerNormalisation" v1.0
  input: x: Tensor[...,d]
  parameters: gamma: Vector[d], beta: Vector[d], epsilon: PositiveReal
  preconditions:
    - d >= 1
    - x, gamma, beta contain finite numbers
    - gamma and beta match selected feature dimension
    - epsilon > 0
  steps:
    - mu := mean(x, axis=features, keepdims=true)
    - variance := mean((x-mu)^2, axis=features, keepdims=true)
    - centred := x-mu
    - scaled := centred/sqrt(variance+epsilon)
    - output := gamma*scaled+beta
  returns: output: Tensor[...,d]
  postconditions:
    - shape(output) == shape(x)
    - output finite under numerically safe finite arithmetic

6. TRANSFORMER PLACEMENT
Pre-norm attention: h = x + Attention(LN(x))
Pre-norm feedforward: y = h + FFN(LN(h))
Post-norm attention: h = LN(x + Attention(x))
Post-norm feedforward: y = LN(h + FFN(h))
These are architectural alternatives, not interchangeable equations.

7. TRI-MAPPING
Entity -> Mathematical object -> Computational operation
InputTensor -> x in R^(... x d) -> tensor input
FeatureAxis -> last d features -> reduction axis
Mean -> mu -> mean reduction
Variance -> var -> squared-deviation reduction
Epsilon -> epsilon > 0 -> numerical stabiliser
Gamma -> gamma in R^d -> learned scale
Beta -> beta in R^d -> learned shift
NormalisedTensor -> z -> centring and scaling
OutputTensor -> y -> affine transform

8. INFERENCE RULES
R1: If a LayerNorm acts on the last feature axis, output shape equals input shape.
R2: If all features at a position are equal, z is zero and y equals beta at that position.
R3: If gamma and beta are learned, their gradients contribute to training updates.
R4: LayerNorm statistics are position-local and do not depend on other batch elements.
R5: Epsilon stabilises division; it does not guarantee numerical safety for arbitrary overflow or nonfinite inputs.
R6: Normalised z need not have exactly unit variance when epsilon > 0.
R7: RMSNorm is not equivalent to LayerNorm because it generally omits mean subtraction.

9. MINI RECURSION ENGINE
function ApplyBlocks(x, blocks):
  state := x
  for block in blocks:
    state := block(state)
    assert shape_compatible(state)
    assert finite(state)
  return state
Recursion terminates after the finite ordered block list; LayerNorm itself is not a recursive operator.

10. AI SEARCH FLOW
SEARCH_INTENT: explain | define | calculate | compare | implement | debug
ALIASES: layer normalisation | layer normalization | LayerNorm | LN
KEY_ENTITIES: mean | variance | epsilon | gamma | beta | transformer | pre-norm | post-norm
PATHWAYS:
  definition -> entity graph -> formula
  numerical example -> tensor -> per-position statistics -> affine output
  transformer design -> pre-norm/post-norm -> residual connections
  implementation -> axis choice -> epsilon -> precision -> tests
  comparison -> LayerNorm versus RMSNorm versus BatchNorm
CONFIDENCE:
  established mathematical identities: high
  page-specific ontology alignment: unverified

11. VALIDATION EXAMPLES
x=[2,4], gamma=[1,1], beta=[0,0], epsilon=0.00001
mu=3, variance=1
output approximately [-0.999995, 0.999995]
x=[5,5], gamma=[2,3], beta=[1,-1], epsilon=0.00001
output=[1,-1]

12. EXECUTION GUARANTEES AND LIMITS
Guarantees are conditional on valid shapes, epsilon > 0, supported finite precision and safe numeric ranges. The flow defines per-position feature normalisation and preserves tensor shape. It does not guarantee model accuracy, optimisation convergence, exact floating-point reproducibility or cross-architecture equivalence.

13. UPDATE MODEL
Track ontology version, epsilon conventions, axis definitions, parameterisation, precision policies and source changes. Revalidate formulas and tests after updates.

14. CITATION
Reference ontology: Kireth Research, "Layer Normalisation Ontology", URL above.
This TXT is an independent companion formalisation, not a verified transcription of the source webpage.
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ