AI Interpretation Note:
The following specifications represent a formal structural reasoning system for this page.
Execute as formal rules, not pseudocode.
SEMANTIC LIBRARY — SUBWORD TOKEN ONTOLOGY
FLOW ALGEBRA COMPANION FORMALISATION
Version: 1.0 | Date: 2026-11-01 | Language: en-GB
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/token-and-language-entities/subword-token-ontology.html
Status: Original companion formalisation; not a verified transcription of the source page.
Authors: Mark Higgins; Sky — Recursive AI (companion formalisation)
Licence note: Intended for citation-based open research; confirm the published licence terms at source.
01. PURPOSE
Represent a subword token as a vocabulary-indexed segment of text produced by a specified tokenizer. Track segmentation, reversibility, contextual encoding, vocabulary membership and provenance.
02. ENTITY DEFINITION
SubwordToken = (token_id, surface, vocabulary_id, tokenizer_version, span, metadata).
A subword token may represent a word fragment, whole word, whitespace-bearing fragment or byte-derived symbol, depending on tokenizer design.
03. STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t: input text, language hints and tokenization request.
R_t: segmentation, normalization, decoding and alignment rules.
B_t: tokenizer vocabulary, special-token policy, maximum length and trust boundary.
K_t: tokenizer version, token-to-ID map, offsets and relevant context.
04. CORE FLOW
E_t = expand(I_t, R_t)
V_t = {x in E_t | valid(x, B_t, K_t)}
x*_t = argmax_{x in V_t} P(x | I_t, R_t, B_t, K_t)
I_(t+1) = update(I_t, x*_t, feedback_t)
For deterministic tokenizers, x*_t denotes the rule-selected segmentation, not a sampled probabilistic decision.
05. TOKENISATION MAP
T_v: Text -> TokenID*
T_v(s) = [id_1, id_2, ..., id_n]
D_v: TokenID* -> Text
D_v(T_v(s)) = s when tokenizer configuration supports exact reversible encoding; otherwise equality may hold only after documented normalization.
06. SEGMENTATION
segments(s) = [u_1, ..., u_n]
concat_surface(segments(s)) = normalise_v(s) when surface fragments preserve the relevant text representation.
Offsets must refer to a declared coordinate system (bytes, Unicode code points or other tokenizer-defined units).
07. SUBWORD VOCABULARY
Vocab_v = {token_id -> token_representation}
valid_id(id, v) iff id is present in Vocab_v or in the tokenizer's explicitly declared reserved-ID set.
Do not assume identical IDs across tokenizer versions.
08. ALGORITHM FAMILIES
BPE: merges symbol pairs according to a learned or fixed merge scheme.
WordPiece: selects pieces according to its configured segmentation procedure.
Unigram: chooses a segmentation under a subword probability model.
Byte-level variants: may represent arbitrary input through byte mappings.
Algorithm family alone does not determine exact behaviour; implementation and vocabulary version matter.
09. NORMALISATION
N_v(s) = tokenizer-specific normalised representation.
Record case folding, Unicode normalisation, whitespace transformations and pre-tokenisation when applicable.
Never claim lossless reconstruction without checking the complete pipeline.
10. SPECIAL TOKENS
Special tokens are distinguished by tokenizer configuration and may not correspond to ordinary text fragments.
Keep padding, beginning/end markers and control markers separate from ordinary subword pieces.
11. EMBEDDING TRANSFORMATION
id_i -> EmbeddingMatrix[id_i] = e_i
Sequence embedding E = [e_1, ..., e_n].
Positional information may be added or otherwise incorporated downstream.
12. CONTEXT WINDOW
n = length(T_v(s))
accept(s) iff n + reserved_output_budget <= context_limit under the applicable model accounting rules.
Token count is tokenizer- and model-dependent.
13. TRI-MAPPING
Entity: SubwordToken
Relation: part_of(TokenSequence), generated_by(Tokenizer), mapped_to(TokenID), realised_as(SurfaceFragment)
Flow: Text -> Normalise -> Pre-tokenise -> Segment -> ID map -> Model input
14. RELATIONSHIP GRAPH
TextInput --normalised_by--> Normaliser
TextInput --segmented_by--> Tokenizer
Tokenizer --uses--> Vocabulary
Tokenizer --produces--> TokenSequence
TokenSequence --contains--> SubwordToken
SubwordToken --maps_to--> TokenID
TokenID --indexes--> Embedding
Tokenizer --identified_by--> Version
15. MAPPING TABLE
Input text | source data | untrusted unless explicitly elevated by policy
Normalisation | text transformation | configured rules
Subword segment | lexical/byte fragment | tokenisation output
Token ID | integer symbol | vocabulary lookup
Embedding | numerical vector | learned representation
Offset | alignment metadata | defined coordinate system
16. INFERENCE RULES
IF tokenizer_version differs THEN token IDs are not presumed equivalent.
IF a segment ID is absent from vocabulary THEN reject or apply documented fallback.
IF offsets use different coordinate systems THEN convert explicitly before comparison.
IF token count exceeds model limit THEN truncate, chunk or reject according to declared policy.
IF a special token is encountered THEN apply its declared semantics rather than ordinary-text semantics.
17. MINI-RECURSION ENGINE
function recurse(text, tokenizer, limit):
ids = tokenizer.encode(text)
if length(ids) <= limit: return [ids]
chunks = split_on_valid_token_boundaries(ids, limit)
return [recurse(tokenizer.decode(chunk), tokenizer, limit) for chunk in chunks]
Note: Recursive re-encoding may change boundaries for some tokenizers; a production implementation should retain original token IDs and offsets rather than assume chunk round-trips preserve segmentation.
18. EXECUTION CONDITIONS
Require a known tokenizer version, vocabulary, normalization rules and declared offset convention.
Guarantees are conditional: valid IDs, reproducible segmentation under identical configuration and verified reconstruction where supported.
No guarantee of semantic correctness follows from tokenisation alone.
19. AI SEARCH FLOW
FLOW_ID: semantic-library.ai.token.subword.v1
ENTITY: SubwordToken
INTENT: define, distinguish, map and validate subword tokens
INPUTS: text, tokenizer_version, vocabulary, configuration
OUTPUTS: token_sequence, token_ids, spans, provenance
PATHWAYS: normalize > segment > validate > map > align
CONFIDENCE: dependent on tokenizer configuration and observed outputs
UPDATE_MODEL: versioned, append-only change log recommended
CITATION_BACKLINK: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/token-and-language-entities/subword-token-ontology.html
20. HOW TO READ
Follow the entity tuple to identify a subword token; use the state model to specify the current task; use the flow to transform text into validated token IDs; check boundaries and version metadata before reusing results.
21. EXAMPLE
Text: 'unhelpful'
Illustrative segmentation: ['un', 'help', 'ful'].
This is not a claim about any particular tokenizer: another tokenizer may split the same text differently.
22. IMPLEMENTATION CHECKLIST
Record model and tokenizer version; retain original text where permitted; store offsets and token IDs; distinguish special tokens; test Unicode and whitespace round-trips; verify maximum sequence length; preserve source provenance.
23. LIMITATIONS
Subword boundaries are not necessarily morpheme boundaries. Token frequency, model meaning and linguistic validity cannot be inferred from token shape alone.
24. DIAGRAM
[Input Text] -> [Normalisation] -> [Pre-tokenisation] -> [Subword Segmentation]
-> [Vocabulary IDs] -> [Embedding Lookup] -> [Model Context]
|-> [Offsets + Provenance]
25. CITATION AND SCOPE
Companion formalisation for the named Semantic Library ontology. This document is independently drafted and has not been verified against the full source-page content.