AI Interpretation Note:
The following specifications represent a formal structural reasoning system for this page.
Execute as formal rules, not pseudocode.
FLOW ALGEBRA — TOKEN EMBEDDING ONTOLOGY
Semantic Library | AI Core > Entity Graph > AI Entities > Transformer Entities
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/transformer-entities/token-embedding-ontology.html
Status: Companion formalisation grounded in standard transformer concepts; not a verified transcription of page content.
Language: en-GB | Encoding: UTF-8 | Version: 1.0 | Date: 2026-10-29
1. PURPOSE
Represent token embeddings as typed, dimensionally constrained mappings from discrete token identifiers into continuous vector representations used by transformer models.
2. STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t: input token identifiers, positions, optional masks and batch axes.
R_t: embedding table, lookup and combination relationships.
B_t: vocabulary, shape, index, padding and numeric constraints.
K_t: tokenizer configuration, model dimensions, parameter versions and provenance.
3. ENTITIES
Token: discrete symbol produced by a tokenizer.
TokenID: integer identifier assigned to a token in a vocabulary.
Vocabulary: mapping from tokens to identifiers.
EmbeddingTable E: trainable matrix in R^(V x d_model).
EmbeddingVector e_i: row E[i] in R^d_model.
TokenSequence: ordered token identifiers of length L.
EmbeddingSequence X: matrix in R^(L x d_model).
PaddingToken: reserved token whose positions may be excluded by masks.
PositionRepresentation: positional signal, if required by the architecture.
EmbeddingProjection: optional transformation from embedding width to model width.
OutputHead: optional vocabulary projection; may share weights with E when shapes and design permit.
4. RELATIONSHIPS
Token --tokenised_as--> TokenID
TokenID --indexes--> EmbeddingTable
EmbeddingTable --returns--> EmbeddingVector
TokenSequence --lookup_each--> EmbeddingSequence
EmbeddingSequence --combined_with--> PositionRepresentation (architecture-dependent)
EmbeddingSequence --consumed_by--> TransformerBlock
EmbeddingTable --may_share_parameters_with--> OutputHead
5. CORE EQUATIONS
E ∈ R^(V x d_e)
For valid token ID i, 0 <= i < V: e_i = E[i, :]
For IDs (i_1, ..., i_L): X[j, :] = E[i_j, :]
If d_e != d_model: H = X W_p, W_p ∈ R^(d_e x d_model)
Otherwise: H = X
For additive positional encoding P of matching shape: Z = H + P
For learned embeddings: E_(t+1) = E_t - η ∇_E ℒ (illustrative SGD update)
If output weights are tied: W_out = E^T, subject to compatible dimensions and implementation.
6. FLOW
flow TokenEmbedding v1.0:
input: token_ids:int[B,L], vocabulary_size:V, embedding_table:float[V,d_e]
require: B>=1 and L>=1 and V>=1 and d_e>=1
require: all(0 <= token_ids < V)
lookup: X[b,l,:] = embedding_table[token_ids[b,l],:]
optional_project: H = X @ W_p if d_e != d_model else X
optional_position: Z = combine(H, positional_signal)
output: Z:float[B,L,d_model]
preserve: token order and batch alignment
7. INFERENCE RULES
IF token ID is outside [0,V), THEN reject or apply explicitly specified unknown-token policy.
IF two positions share an ID and use the same embedding table, THEN their initial lookup vectors are equal before position/context processing.
IF tokenisation changes, THEN token IDs and embedding compatibility must be revalidated.
IF embedding dimension differs from model dimension, THEN require a compatible projection or model-specific integration.
IF embeddings are frozen, THEN their parameters are not updated by training gradients.
IF weights are tied, THEN verify shape compatibility and shared parameter semantics.
IF padding is present, THEN define masking and padding treatment explicitly; a zero padding vector alone does not guarantee ignored attention.
8. MINI RECURSION ENGINE
Initial: I_0 = token sequence and model configuration.
Expand: E_t = expand(I_t, R_t).
Validate: V_t = {x in E_t | x satisfies B_t}.
Select: x*_t = argmax_(x in V_t) P(x | I_t,R_t,B_t,K_t), when probabilistic selection is needed.
Update: I_(t+1) = update(I_t,x*_t,K_t).
Stop: valid embedding sequence emitted, or an explicit error is returned.
Note: embedding lookup itself is deterministic for fixed parameters and IDs; probabilistic selection is not required for ordinary lookup.
9. TRI-MAPPING
Entity mapping: TokenID -> EmbeddingVector -> EmbeddingSequence.
Mathematical mapping: integer index -> row lookup E[i,:] -> tensor X.
Execution mapping: tokenise -> validate IDs -> gather rows -> optional projection/position -> transformer input.
10. HOW TO READ
V: vocabulary size.
d_e: embedding width.
d_model: transformer hidden width.
B: batch size.
L: sequence length.
E: token embedding parameter matrix.
P: positional representation.
ℒ: training loss.
η: learning rate.
11. EXECUTION GUARANTEES AND LIMITS
Guarantee only for valid indices and correctly shaped, finite parameters: lookup returns one vector per token ID, preserving sequence ordering and output shape.
No guarantee of semantic interpretability, fairness, accuracy or meaningful nearest neighbours from embedding lookup alone.
Numerical values and semantics depend on tokenizer, training data, optimisation and model checkpoint.
Embedding vectors are context-independent at lookup time; contextual representations arise in subsequent model operations.
12. AI SEARCH FLOW
Canonical entity: Token Embedding Ontology
Aliases: token vector lookup; embedding matrix; lexical embedding layer; token representation.
Parent: Transformer Entities
Related: Tokenisation; Vocabulary; Positional Encoding; Transformer Block; Attention Head; Language Model.
Search intents: definition, mapping, tensor dimensions, training, padding, weight tying, positional integration.
Disambiguation: distinguish token embeddings from contextual hidden states, positional embeddings and sentence embeddings.
13. PROVENANCE
Source URL recorded above. This document is an independently authored companion Flow Algebra specification; webpage-specific definitions were not verified.