Skip to main content

Top-P Parameter Ontology

AI Parameter Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 29 October 2026
Audio Overview
FLOW ALGEBRA — TOP-P PARAMETER ONTOLOGY
Semantic Library | AI Core > Entity Graph > AI Entities > AI Parameter Entities
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/ai-parameter-entities/top-p-parameter-ontology.html
Status: Companion formalisation using standard nucleus-sampling principles; source page's embedded specification not verified.
Encoding: UTF-8 | Language: en-GB

1. PURPOSE
Formalise the top-p (nucleus) parameter controlling the smallest high-probability candidate set whose cumulative probability reaches a threshold p, followed by renormalised sampling.

2. ENTITY MODEL
TopPParameter: threshold p in (0,1].
Vocabulary: finite set V of token IDs.
LogitVector: z in R^|V|.
Temperature: tau > 0, optionally used before filtering.
ProbabilityDistribution: q = softmax(z/tau).
SortedCandidates: tokens ordered by descending q; deterministic tie-break by token ID.
Nucleus: minimum non-empty prefix with cumulative probability >= p.
FilteredDistribution: r with support restricted to nucleus.
SampledToken: token drawn from r.
RandomState: reproducible generator state when a seed is supplied.

3. STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t = (logits z_t, optional temperature tau_t, random state u_t)
R_t = (softmax, sort, cumulative mass, truncate, renormalise, sample)
B_t = (0 < p <= 1, tau > 0, finite logits, non-empty vocabulary)
K_t = (token vocabulary, tie-break policy, provenance, algorithm version)

4. FORMAL EQUATIONS
q_i = exp(z_i/tau) / sum_j exp(z_j/tau), computed with numerical stabilisation.
Let pi be a permutation such that q_pi(1) >= ... >= q_pi(n).
C_m = sum_{j=1}^m q_pi(j).
m* = min {m in {1,...,n} : C_m >= p}.
N_p = {pi(1), ..., pi(m*)}.
r_i = q_i / sum_{j in N_p} q_j if i in N_p; otherwise r_i = 0.
y_t ~ Categorical(r).
If p = 1, all candidates with non-zero probability are retained (subject to numerical representation).
The crossing token is included; top-p is not a fixed number of tokens.

5. TRANSITION RULES
T1: validate logits, vocabulary and threshold.
T2: apply optional temperature scaling and stable softmax.
T3: rank candidates in descending probability with documented tie-breaking.
T4: choose the shortest prefix with cumulative probability >= p.
T5: zero excluded token probabilities and renormalise.
T6: sample one token and update the generation state.
T7: append token to context and repeat until termination.

6. INFERENCE RULES
R1: Lower p usually reduces the eligible token set for fixed logits.
R2: Increasing p cannot decrease nucleus size for a fixed distribution and ordering.
R3: Nucleus size adapts to distribution concentration.
R4: p = 1 removes nucleus truncation, but other filters may remain.
R5: Top-p and temperature have distinct effects; temperature changes probabilities before top-p when applied in that order.
R6: A top-k filter combined with top-p requires an explicitly declared operation order.
R7: Sampling is stochastic unless the distribution is degenerate or the sampler uses deterministic selection.

7. MINI RECURSION ENGINE
state := initial_context
while not stop(state):
    logits := model(state)
    q := stable_softmax(logits / temperature)
    ranked := sort_descending(q, stable_tie_break=true)
    nucleus := shortest_prefix_with_mass_at_least(ranked, p)
    r := renormalise(q restricted_to nucleus)
    token := categorical_sample(r, rng)
    state := append(state, token)
return state

8. TRI-MAPPING
ENTITY: TopPParameter -> threshold controlling candidate inclusion.
RELATIONSHIP: TopPParameter --filters--> ProbabilityDistribution --forms--> Nucleus.
PROCESS: logits -> probabilities -> rank -> cumulative threshold -> renormalise -> sample.

9. EXECUTION CONSTRAINTS
C1: 0 < p <= 1; reject NaN or infinite p.
C2: Vocabulary must be non-empty and logits finite, or invalid entries handled under a declared policy.
C3: At least one token must survive filtering.
C4: Probability sum after renormalisation is approximately 1 within numerical tolerance.
C5: Tie-breaking and RNG seed are recorded for reproducibility.
C6: Never infer that top-p guarantees truthfulness, safety, coherence or diversity.

10. EXECUTION GUARANTEE (CONDITIONAL)
Under valid finite inputs, a deterministic ranking and a numerically stable implementation, the nucleus exists, is non-empty, reaches mass >= p, and produces a valid categorical distribution after renormalisation. No semantic quality guarantee follows.

11. AI SEARCH FLOW
QUERY_INTENT: define, compare, implement or audit nucleus sampling.
ENTITY_MATCH: top-p, nucleus sampling, cumulative probability threshold, decoding parameter.
PATHWAYS:
  definition -> state model -> equations
  implementation -> validation -> sort -> prefix -> renormalisation -> sampling
  comparison -> top-k versus top-p versus temperature
  audit -> threshold -> operation order -> seed -> output distribution
SEMANTIC_EQUIVALENCE: top-p sampling ~= nucleus sampling (in this decoding context).
CONFIDENCE: mathematical statements conditional on stated assumptions.
UPDATE_MODEL: version equations, tie-break conventions and implementation details when revised.

12. HOW TO READ
The top-p parameter does not pick p percent of tokens. It selects the smallest ranked set with at least p of the probability mass, then samples from the renormalised set.

AUTHORS: Kireth Research; companion Flow Algebra formalisation prepared with Sky — Recursive AI.
CITATION_BACKLINK: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/ai-parameter-entities/top-p-parameter-ontology.html
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ