Skip to main content

Transformer Architecture 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 — TRANSFORMER ARCHITECTURE ONTOLOGY
Semantic Library | AI Core | Entity Graph | AI Entities | Transformer Entities
SOURCE: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/transformer-entities/transformer-architecture-ontology.html
AUTHORS: Mark Anthony Higgins; Sky — Recursive AI
SOURCE PAGE: originally 11 October 2025; revised 29 July 2026
FLOW VERSION: 1.0 | 29 October 2026 | LANGUAGE: en-GB
STATUS: Companion formalisation; the webpage's complete embedded specification was not available in the retrieved HTML.

1. PURPOSE
Represent transformer architectures as typed component graphs with explicit tensor dimensions, information-flow constraints, attention operations, residual pathways, normalisation, and inference modes.

2. ONTOLOGY
TransformerArchitecture := (Modules, Edges, Parameters, Config, Constraints)
Modules := {Embedding, PositionRepresentation, Attention, FeedForward, Normalisation, Residual, OutputHead}
OptionalModules := {EncoderStack, DecoderStack, CrossAttention, Cache, Router, Expert}
ArchitectureKind := {EncoderOnly, DecoderOnly, EncoderDecoder, Hybrid}
AttentionKind := {BidirectionalSelf, CausalSelf, Cross, Sparse, Local}
Entity relations:
  hasModule(Architecture, Module)
  connectsTo(Module, Module)
  hasParameter(Module, Parameter)
  hasAttentionKind(Attention, AttentionKind)
  consumes(Module, Tensor)
  produces(Module, Tensor)
  hasShape(Tensor, Shape)
  constrainedBy(Architecture, Constraint)

3. STATE MODEL
S_t = (I_t, R, B, K)
I_t := current token sequence, embeddings, masks, and intermediate activations
R := architecture graph, typed operators, and connectivity rules
B := computational, context, causal, memory, and dimensional constraints
K := model parameters, architectural configuration, and verified facts
Expand: E_t = expand(I_t, R)
Validate: V_t = {x in E_t | satisfies(x, B) and typeSafe(x)}
Select: x*_t = argmax_{x in V_t} P(x | I_t, R, B, K)
Update: I_{t+1} = update(I_t, x*_t)
Note: argmax expresses constrained selection over candidate interpretations, not a claim that every transformer uses this algorithm internally.

4. TENSOR CONTRACTS
Input token IDs: X in Integer[B, L]
Embedding output: H_0 in Real[B, L, d_model]
Number of heads: h >= 1; d_model mod h = 0 for equal-width heads
Head width: d_head = d_model / h
Q_i = H W_Qi; K_i = H W_Ki; V_i = H W_Vi
Head_i = softmax((Q_i K_i^T)/sqrt(d_head) + M) V_i
MultiHead(H) = concat(Head_1,...,Head_h) W_O
M := attention mask; disallowed positions receive negative infinity before softmax
For cross-attention, Q comes from the decoder and K,V from encoder representations.

5. ARCHITECTURE TRANSITIONS
Embedding: X -> token embeddings plus positional information
Pre-norm attention block: U = H + Attention(Norm(H), mask)
Pre-norm feed-forward block: H_next = U + FFN(Norm(U))
Typical FFN: FFN(z) = W_2 activation(W_1 z + b_1) + b_2
Post-norm and alternative residual layouts are valid distinct configurations.
Encoder-only: bidirectional attention -> contextual representations
Decoder-only: causal attention -> next-token logits or other task heads
Encoder-decoder: encoder representations -> decoder causal self-attention -> cross-attention -> output
Position representations may be absolute, relative, rotary, or attention-bias based.

6. INFERENCE RULES
R1: if kind=DecoderOnly and autoregressive=true, future-token attention must be masked.
R2: if kind=EncoderDecoder, cross-attention keys and values derive from encoder output.
R3: if h equal-width heads are used, d_model must be divisible by h.
R4: every residual addition requires broadcast-compatible, normally identical, shapes.
R5: a module edge is valid only when producer and consumer tensor contracts match.
R6: padding positions must be excluded where the task requires padding masks.
R7: attention visibility is determined by the configured mask, not by the word 'transformer' alone.
R8: KV caching reuses previously computed keys and values only where attention semantics permit it.
R9: a claimed model architecture must distinguish specified components from inferred defaults.

7. TRI-MAPPING
Entity -> Graph -> Execution
AttentionHead -> query/key/value relations -> scaled dot-product attention
ResidualConnection -> skip edge -> tensor addition
LayerNormalisation -> feature normalisation relation -> normalise activation
DecoderBlock -> causal dependency graph -> masked attention and feed-forward computation
CrossAttention -> decoder-to-encoder dependency -> queries against encoder keys/values

8. MINI RECURSION ENGINE
Input: architecture description A and candidate interpretation c
Step 1: parse modules and typed relations.
Step 2: expand reachable module dependencies.
Step 3: verify shapes, masks, causal direction, and graph connectivity.
Step 4: reject contradictory candidates with explicit reasons.
Step 5: select a valid interpretation supported by evidence.
Step 6: emit architecture graph, trace, and unresolved assumptions.
Termination: no new validated relations, or configured depth/compute budget reached.

9. EXECUTION GUARANTEES AND LIMITS
Guarantee (conditional): a validated graph preserves declared module connectivity and tensor contracts.
Not guaranteed: empirical model accuracy, training convergence, calibration, safety, or universal correctness.
Report unknown details rather than inventing model depth, head counts, parameter sizes, or training objectives.

10. AI SEARCH FLOW
QUERY_CLASSES: architecture definition; encoder versus decoder; attention heads; masks; residual pathways; positional representation; tensor dimensions; cross-attention; inference caching
ENTITY_ALIASES: transformer network; transformer stack; attention-based neural architecture
RETRIEVAL_PATH: query -> identify architecture kind -> extract modules -> validate constraints -> explain information flow
ANSWER_POLICY: separate canonical transformer principles from model-specific variations; state assumptions.
CONFIDENCE: high for algebraic definitions and standard architectural distinctions; conditional for unspecified implementations.
SEMANTIC_EQUIVALENCE: 'causal self-attention' ~= 'masked autoregressive self-attention' in autoregressive decoder contexts.
UPDATE_MODEL: revise module graph and constraints when architecture evidence changes; preserve source provenance.
CITATION_BACKLINK: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/transformer-entities/transformer-architecture-ontology.html
FLOW_HASH: not assigned; calculate from final published bytes if required.

END FLOW
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ