Version: 1.0 Status: Draft
This document specifies the mathematical objects and observable behaviors that constitute a generative process system. The specification is intended to be sufficient for an independent ground-up reimplementation in any language or framework.
The core specification covers:
- Generalized hidden Markov models (GHMMs)
- Operations that must be possible on any generative process
- Composition schemes: factored processes and nonergodic mixtures
- Conditional dependency schemes for factored processes
- Conformance test vectors for verifying correctness
The core specification does not cover:
- Software architecture, programming language, or framework choices
- Algorithms or internal representations
- Implementation-specific conveniences or optimizations
Optional runtime interoperability conventions are collected in Appendix A and are not part of the mathematical or conformance requirements.
The following conventions are used within this document. They are not prescriptions for implementations.
| Symbol | Meaning |
|---|---|
| Vocabulary size (number of distinct observations) | |
| State space size | |
| Observation token | |
| Transition tensor in |
|
| The |
|
| Net transition matrix: |
|
| Spectral radius of |
|
| Normalizing right eigenvector of |
|
| Stationary left eigenvector of |
|
| GHMM state representative (row vector of dimension |
|
| Canonically normalized GHMM state representative | |
| Initial state representative | |
| Mixture-weight vector for a nonergodic mixture | |
| Current component-belief vector in a nonergodic mixture | |
| State of component |
|
| Set of per-factor tuples present in the authoritative composite-token encoding | |
| Number of variants for factor |
|
| Number of factors in a factored process | |
| Number of components in a nonergodic mixture |
Conventions:
- Mathematical indexing is 1-based throughout the spec unless a section explicitly states otherwise.
- For per-factor observations and states, the factor label is written as a superscript, e.g.
$x^i$ ,$\boldsymbol{\eta}^i$ , and$s^i$ . These superscripts are labels, not powers. - For per-component observations and states in nonergodic mixtures, the component label is written as a superscript where that notation is used, e.g.
$x^c$ and$s^c$ . - Subscripts are used for indexed families, metadata, and time indices, e.g.
$K_i$ ,$\sigma_i$ , $\mathrm{deps}i$, $T{i \mid k}$,$\boldsymbol{\eta}_t^i$ , and$x_t^i$ . - A superscript
$\uparrow$ on a tuple means its entries are ordered by increasing factor index. - GHMM state representatives are row vectors. Two nonzero nonnegative row vectors
$\boldsymbol{\eta}$ and$c \boldsymbol{\eta}$ with$c > 0$ represent the same predictive state. - The formulas in §§3.4-3.6 are invariant under positive rescaling of the GHMM state representative.
- In the HMM subclass, the canonical representative coincides with the usual sum-to-1 hidden-state distribution.
- Input transition matrices use row-vector convention: the
$(i, j)$ entry of$T^{(x)}$ is the nonnegative weight for transitioning from state$i$ to state$j$ while emitting observation$x$ .
Given a generative process (base GHMM or composite), it must be possible to obtain the following results. The spec defines what results are required, not how they are organized or computed.
Given a process state, compute the probability distribution over observations:
The result is a categorical distribution over the process vocabulary.
Given a probability distribution over observations, sample an observation. This is standard categorical sampling and is not specific to generative processes.
Given a prior process state and an observed token, compute the updated process state after conditioning on that observation.
Given an observation sequence
Some process types define stationary objects; others do not.
- For a base GHMM or HMM, the stationary objects are the stationary left eigenvector
$\boldsymbol{\pi}$ and the associated canonical stationary state representative$\boldsymbol{\eta}_*$ of §3.8. - For factored processes, see §4.7.
- For nonergodic mixtures, see §5.7.
The v1.0 conformance suite requires the stationary_distribution operation only for base ghmm and hmm process definitions.
3 Generalized Hidden Markov Model
A GHMM is a positive operator model. Its predictive state is represented by a nonzero nonnegative row vector up to positive scale. Only in the HMM subclass does the canonical representative coincide with an ordinary hidden-state probability distribution.
At each step, the current predictive state determines a distribution over observations. After observing a token, the state updates by applying the corresponding operator slice and re-normalizing in the
A GHMM is defined by transition matrices
has spectral radius 1.
An optional initial state representative
The transition matrices
- Every entry is finite and nonnegative.
- The net transition matrix
$T = \sum_x T^{(x)}$ has spectral radius 1. - The right eigenspace of
$T$ at eigenvalue 1 is one-dimensional and admits a strictly positive eigenvector$\mathbf{w}$ . - The left eigenspace of
$T$ at eigenvalue 1 is one-dimensional and admits a nonnegative eigenvector$\boldsymbol{\pi}$ .
These eigenvectors are normalized as follows:
and
A nonnegative irreducible
Non-normative note: A producer may obtain the spectrally normalized form by dividing all
3.2.1 Hidden Markov Model
An HMM is the GHMM subclass with the additional constraint
In that case,
From the net transition matrix
- Normalizing eigenvector
- Stationary left eigenvector
Given a GHMM state representative
Because all matrices are nonnegative and
Given a state representative
This returns a concrete representative of the posterior predictive state.
Zero-denominator case: If
the update is undefined. This corresponds to conditioning on an observation with zero probability under the current predictive state, or to numerical failure.
Given an observation sequence
For the empty sequence
GHMM state representatives are defined up to positive scale. For any
When a canonical representative is needed, use
which satisfies
In the HMM subclass, this reduces to ordinary sum-to-1 normalization.
The stationary left eigenvector
It represents the stationary predictive state. The canonical representative of this same predictive state is
This canonical representative satisfies
When initial_state is omitted, the default predictive state is this stationary predictive state. Using
A factored process in v1.0 is defined by
sharing a common local observation alphabet
Equivalently, the variants of a single factor are alternative dynamics for one fixed local factor, not different local factors. Token identities and hidden-state coordinates are therefore shared across variants of that factor.
v1.0 factored processes are therefore GHMM/HMM-factor compositions. A more general factor-interface abstraction is reserved for a future version.
A factored process is defined by:
-
$F$ factor families, one per factor - an emission selector for each factor
- a transition selector for each factor
- a composite-token encoding (§4.3.2)
The single-selector case is the special case
For every factor, parent observations are ordered by increasing factor index when they are supplied to a selector. Write this ordered tuple as
for emission selectors, and analogously for transition selectors.
If initial_state, its default state is the stationary predictive state of its sole local variant. If
The only exact emission schemes normatively defined in v1.0 are the supported ones in §4.6.1: independent emissions and sequential-chain emissions. The transition dependency graph induced by
If the emission dependency graph is cyclic, the only defined v1.0 semantics is the fully conditional approximation of §4.6.3.
For each factor
- Every variant acts on the same local state space
$\mathbb{R}_{\ge 0}^{S_i}$ in the same coordinate basis. If a producer's internal variants differ only by a hidden-state relabeling, they must be converted to one common basis before serialization. - Every variant uses the same local observation alphabet
${1, \ldots, V_i}$ with common token identities. Different variants may assign different probabilities to a token, including zero, but they must not reinterpret what that token ID means. - Every variant uses the same state-representation convention for
$\boldsymbol{\eta}^i$ : a nonzero nonnegative row vector with the GHMM projective semantics of §3. - Every variant is individually valid as a local process of its declared type, i.e. each per-variant family
${T_{i \mid k}^{(x^i)}}_{x^i=1}^{V_i}$ satisfies the validity conditions of §3 forghmm, or §3.2.1 forhmm.
Variants of a factor are not required to share the same normalizing eigenvector $\mathbf{w}{i \mid k}$, stationary left eigenvector $\boldsymbol{\pi}{i \mid k}$, stationary canonical representative, support, or transition structure.
Except in the
When the selected variant changes, the factor state is carried forward directly in the common factor coordinate system. If two variants have different normalizing eigenvectors, the same concrete row vector may be canonical for one variant gauge and non-canonical for another. This is valid in v1.0; canonical normalization is always relative to the variant whose
The runtime state of a factored process therefore contains a single current factor-state representative
A valid runtime factor-state representative for factor
The observation law of a factored process is a joint distribution over composite tokens, assembled from per-factor emission distributions according to the chosen emission dependency scheme.
For factor
Its local emission distribution is
Each
The composite-token encoding is part of the authoritative process definition.
- If no explicit encoding is supplied, the composite vocabulary is the full product space and uses the mixed-radix encoding of §4.3.3.
- If a strict subset of tuples is encoded, the process definition must provide an explicit bijection between composite token IDs and per-factor tuples.
Full-product encodings may include tuples that are unreachable and therefore always have zero probability. Sparse encodings may exclude them, but then the explicit map is mandatory. A composite token outside the declared encoding is outside the process vocabulary and therefore invalid.
When the composite vocabulary is the full product
Encoding:
where
Decoding:
Invariant:
Conformance JSON uses 0-based serialized token IDs; see §7.1 for the serialization convention.
For supported DAG emission topologies, the joint distribution is computed exactly by evaluating factors in emission topological order. For the fully conditional approximation, the joint is defined by §4.6.3.
Given a composite observation
where
If the process is using the fully conditional approximation of §4.6.3 and the pre-normalization constant
Otherwise each factor updates by
Outside the
Given a composite observation sequence
where
For the empty sequence
A factored process may use distinct selectors for same-step emissions and post-observation transitions. Emission selectors determine the joint observation law for the current time step. Transition selectors determine how factor states are updated after the full observation tuple is known. The single-selector case is the special case where the two selector families are identical.
No factor's emission depends on any other factor's same-step emission. Then
Factor 1 has no emission parents, and factor
Other DAG topologies are reserved for a future version and are not normatively defined in v1.0. v1.0 normatively defines only:
- independent emissions
- sequential-chain emissions
- the fully conditional emission approximation
- hybrid conditional-transition schemes built on those emission modes
For every factor, the codomain of each selector must be contained in
When every factor's emission depends on the other factors' same-step emissions, the emission dependency graph is cyclic and the true joint is not available in closed form. v1.0 defines the following product-of-conditionals approximation:
and
Here $\mathcal{X}{\mathrm{enc}}$ is the set of per-factor tuples that are present in the authoritative composite-token encoding. For the default dense encoding, $\mathcal{X}{\mathrm{enc}}$ is the full product space. For a sparse encoding, the sum is taken only over explicitly encoded tuples.
Zero-mass fallback: If
In this branch, observing any composite token leaves all factor states unchanged.
A hybrid factored process may use one supported emission scheme (fixed or sequential in v1.0) together with an arbitrary transition-selector family, including selectors conditioned on all non-self observations in the current tuple. For v1.0 conditional_transitions serialization, factor
A factored process has a default initial state whenever every factor has a defined default initial state. In that case, the default composite initial state is the ordered tuple of the per-factor defaults.
For independent factors with a single variant each, this default composite initial state is stationary and equals the tuple of the per-factor stationary predictive states.
If a factor has multiple variants, those variants may have different stationary predictive states and different normalizing gauges. Accordingly, v1.0 does not define a single variant-independent stationary object or canonical default state for that factor; this is why §4.1 requires an explicit initial_state when
For other factored-process couplings, v1.0 does not define a general stationary object. The existence of a default initial state does not imply stationarity.
A nonergodic mixture combines
A nonergodic mixture is defined by:
- component processes, each independently defined under its own process type
- component weights $\boldsymbol{\alpha}{\text{mix}} \in \mathbb{R}^C$ with $\alpha{\text{mix},c} \ge 0$ for all
$c$ and$\sum_c \alpha_{\text{mix},c} = 1$ - vocabulary mappings
For each component
be an injective local-to-global token map, and let
denote its image. The images
The state of a nonergodic mixture consists of:
- component beliefs
$\boldsymbol{\beta} \in \mathbb{R}^C$ with$\beta_c \ge 0$ for all$c$ and$\sum_c \beta_c = 1$ - per-component states
$(s^1, \ldots, s^C)$ , using the state representation appropriate to each component process
\sum_{c=1}^{C} \beta_c , \mathbf{1}{x \in S_c} , P_c(\phi_c^{-1}(x) \mid s^c), $$
where
Define
If
then
Each component state updates by its own process update rule:
If
Given an initial mixture state
For the empty sequence
Under the default initial state of §5.7, $\boldsymbol{\beta}0 = \boldsymbol{\alpha}{\text{mix}}$.
Generation from an initial mixture state samples one component once from the initial component-belief vector
If a generation API exposes a final state, the normative final state is the public process state obtained by filtering the emitted global sequence under the mixture update rule above, not merely the latent chosen component. An implementation may additionally expose the latent chosen component as auxiliary output.
A nonergodic mixture does not define a unique global stationary state for the Bayesian-tracking process.
Its default initial state is
where each component uses its own default initial state when not explicitly provided. This default is not generally stationary.
The preceding sections define the mathematical objects and their properties. This section specifies additional behavior for generating finite sequences from those processes.
Given a generative process and an initial state, generate a sequence of
Raw generated sequences may be augmented with framing tokens:
- BOS: prepended before the first body token
- EOS: appended after the last body token
- PAD: fills remaining positions to reach a target length
BOS, EOS, and PAD token indices must lie outside the process vocabulary. They do not participate in process-state updates.
When all augmentations are applied, the output layout is
padded to total length
Sequences must be producible in batches: a collection of generated sequences, all with the same total output length
Index convention note: The mathematics in this document is 1-based. JSON serialization is 0-based.
- Array positions in JSON are 0-based in the usual programming sense.
- Variant IDs stored in JSON scalar fields such as
control_mapsoutputs andemission_variant_indicesare also 0-based. - Serialized token IDs in the conformance fixtures are 0-based unless a test explicitly states otherwise.
Process definitions are encoded as JSON objects with a type discriminator.
Base GHMM:
{
"type": "ghmm",
"transition_matrices": [[[...]]]
}transition_matrices is a 3D array of shape [V, S, S] in row-vector convention and must already be in the spectrally normalized gauge of §3.1. An optional initial_state field provides a GHMM state representative. When omitted, the default predictive state is the stationary predictive state of §3.8.
HMM:
{
"type": "hmm",
"transition_matrices": [[[...]]]
}The hmm tag indicates that the HMM-specific validity constraints of §3.2.1 apply.
Factored process:
{
"type": "factored",
"factors": [
{
"component_type": "hmm",
"transition_matrices": [[[[...]]]],
"initial_state": [...],
"vocab_size": 2
}
],
"structure": {
"type": "independent"
}
}For each factor, transition_matrices is a 4D array of shape [K, V, S, S]. For v1.0 factored processes, each factor's component_type must be either "ghmm" or "hmm", and all of that factor's variants live under that one declared type. For each factor, each per-variant [V, S, S] block of transition_matrices must already be in the spectrally normalized gauge of §3.1 and must be individually valid for the declared component_type. The variants of a factor share one local token alphabet and one hidden-state coordinate system; they need not share the same normalizing eigenvector or stationary distribution. If vocab_size is present, it must equal the V dimension of that factor's transition_matrices. If a factor has K = 1 and omits initial_state, it defaults to the stationary predictive state of its sole local variant. If a factor has K > 1, its initial_state must be explicit. A factored process may additionally include a composite_encoding object when it uses a sparse composite vocabulary.
Nonergodic mixture:
{
"type": "nonergodic",
"components": [...],
"weights": [...],
"vocab_maps": [[...], ...]
}Here the serialized weights field stores the mixture-weight vector vocab_maps, each inner array stores 0-based global token IDs. For component vocab_maps[i] must equal that component's local vocabulary size, and the entries of vocab_maps[i] must be distinct.
-
GHMM state: a 1D array of dimension
$S$ representing a nonzero nonnegative row vector - Factored state: an ordered list of factor-state encodings
-
Nonergodic state: an object with
component_beliefsandcomponent_states
GHMM state outputs in conformance fixtures are serialized in canonical form
unless a test explicitly states otherwise. GHMM state inputs may use any valid nonzero nonnegative representative.
Whenever a GHMM state appears anywhere in an expected output state encoding, whether as a top-level GHMM state, as a factor state inside a factored state, or as a component state inside a nonergodic state, it is serialized in canonical form unless a test explicitly states otherwise. This requirement applies recursively.
{"type": "independent"}
{"type": "independent", "variant_indices": [0, 2, 0]}
{"type": "sequential", "control_maps": [null, [0, 1, ...]]}
{"type": "fully_conditional", "control_maps": [[...], [...]]}
{"type": "conditional_transitions",
"transition_control_maps": [[...], [...]],
"emission_control_maps": [null, [1, 0]]}control_maps is shorthand for the single-selector case where emission and transition selectors are identical.
The supported structure types determine the parent tuple for each selector:
-
independent: every selector is parentless and constant. Ifvariant_indicesis omitted, every factor uses constant selector value0. If present,variant_indices[i]is the 0-based selected variant for factoriin the single-selector case. -
sequential: factor 1 has a constant emission selector; factor$i \ge 2$ uses parent tuple$(x^{i-1})$ -
fully_conditional: factor$i$ uses the ordered tuple of all factor observations except$x^i$ -
conditional_transitions: emissions are either constant (emission_variant_indices) or sequential (emission_control_maps), while transition selectors for factor$i$ use the ordered tuple of all factor observations except$x^i$
For conditional_transitions, emissions are determined by exactly one of emission_variant_indices or emission_control_maps, while transitions are determined by transition_control_maps.
For every factor, parent observations are serialized as 0-based local token IDs ordered by increasing parent factor index. If factor
\sum_{r=1}^{m} \tilde{x}^{p_r} \prod_{q=r+1}^{m} V_{p_q}. $$
Then the relevant control-map entry at that index returns a 0-based serialized variant ID. The required control-map length is therefore
For a parentless constant selector, the serialized form is:
variant_indices[i]for theindependentsingle-selector caseemission_variant_indices[i]when fixed emissions are being used inconditional_transitions- otherwise a length-1 array containing the selected 0-based variant ID
If a factored process uses a sparse composite vocabulary, its process definition must include an explicit composite-token encoding object, for example:
"composite_encoding": {
"type": "explicit",
"token_to_tuple": [[0, 0], [0, 1], [1, 0]]
}where the composite token ID is the 0-based array position.
Initial state convention: When a process definition omits initial_state, the process uses its own default initial-state rule. For a base GHMM, that is the stationary predictive state of §3.8. The stationary_distribution operation is defined in v1.0 conformance only for base ghmm and hmm process definitions. It returns
All numerical comparisons use both relative and absolute tolerance. A computed scalar
Unless otherwise noted, use
For vectors, matrices, and tensors, apply this criterion elementwise.
Conformance vectors cover deterministic operations. Sequence-generation augmentations (§6) are behaviorally specified but not numerically tested, because sampling depends on RNG implementation.
Unless a category explicitly tests a specified fallback (fully_conditional_zero_fallback or nonergodic_zero_likelihood), conformance vectors use valid process definitions and valid operation inputs. Behavior on invalid process definitions, out-of-range selector outputs, composite tokens outside the declared encoding, and base-GHMM zero-denominator updates is outside v1.0 conformance.
Test vectors are provided in the companion file conformance-tests.json. Each test vector has these required fields:
id: unique identifiercategory: which aspect is being testeddescription: human-readable descriptionoperation: which operation is being testedinput: operation-specific inputexpected: expected output
And these optional fields:
process: process definition (§7.1.1)tolerance: relative tolerance overrideabs_tolerance: absolute tolerance overridenotes: human-readable explanation of the expected value
Categories covered:
- ghmm_observation_distribution: observation distribution from a GHMM
- ghmm_belief_update: GHMM state update after observing a token
- ghmm_sequence_probability: probability of an observation sequence
-
ghmm_hmm_case: HMM special case where
$\mathbf{w} = \mathbf{1}$ - ghmm_nontrivial_w: GHMM with nontrivial normalizing eigenvector
- ghmm_stationary_distribution: stationary left eigenvector computation
- ghmm_projective_invariance: invariance under positive rescaling of GHMM states
- factored_token_encoding: token encoding and decoding
- factored_sparse_encoding: explicit sparse composite encodings
- factored_independent: independent factored joint distribution
- factored_sequential: sequential-chain factored joint distribution
- factored_belief_update: factored-process state updates
- factored_sequence_probability: multi-step factored sequence probability
- factored_fully_conditional: fully conditional approximation
- factored_conditional_transitions: hybrid conditional-transition scheme
-
fully_conditional_zero_fallback: uniform fallback when
$Z = 0$ - nonergodic_observation_distribution: mixture observation distribution
- nonergodic_belief_update: mixture Bayesian component update
- nonergodic_sequence_probability: mixture sequence probability
- nonergodic_zero_likelihood: zero-likelihood fallback
- nonergodic_vocab_mapping: differing component vocabulary maps
- generation_layout: BOS/EOS/PAD layout verification
| Term | Definition |
|---|---|
| Belief state ( |
The predictive state of a GHMM, represented by a nonzero nonnegative row vector up to positive scale. In the HMM subclass, the canonical representative is the usual hidden-state probability distribution. |
| BOS | Beginning-of-sequence token; a framing token prepended to generated sequences |
| Component | One constituent process in a nonergodic mixture |
| Composite token | A single integer encoding the joint observation tuple of all factors in a factored process |
| Control map | A lookup-table encoding of an emission selector or transition selector used in the conformance tests |
| Emission selector ( |
A function selecting the emission variant for factor |
| EOS | End-of-sequence token; a framing token appended after the last body token |
| Factor | One constituent process in a factored process |
| GHMM | Generalized hidden Markov model; a positive operator model with projective state representatives |
| HMM | Hidden Markov model; the GHMM subclass where |
| Net transition matrix | |
| Normalizing eigenvector | The strictly positive right eigenvector |
| Observation | A discrete token emitted by the process |
| PAD | Padding token used to extend generated sequences to a target length |
| Perron root | For a nonnegative matrix, the eigenvalue equal to its spectral radius |
| Radix encoding | Mixed-radix positional encoding of per-factor tokens into a composite token |
| Spectral radius | The maximum absolute value of the eigenvalues of a matrix |
| Stationary distribution | The normalized left eigenvector |
| Transition selector ( |
A function selecting the transition variant for factor |
| Variant | One of the alternative transition-matrix families available to a factor |
| Vocabulary mapping ( |
An injective map from a component's local token indices to global token indices in a nonergodic mixture |
This appendix is not part of the mathematical or conformance requirements. It describes optional runtime conventions that implementations may choose to support.
An implementation may choose to expose generated batches on CPU, NVIDIA GPUs (CUDA), or both.
An implementation may choose to expose generated tensors through DLPack so they can be consumed by other frameworks without copying.