Skip to content

Main content

Top P Boundary Token Residual Mass Tool

Find the smallest descending-probability nucleus reaching a supplied top-p threshold, including its boundary token.

Loading tool…

Description

Return the boundary token of a sorted top-p mass prefix.

Language-model bookkeeping separates scores, probabilities, dimensions, capacity and positional transforms. A local ranking, padding or coordinate operation can illustrate a model component without running a model, sampling a token, fitting calibration or demonstrating output quality.

Return the boundary token of a sorted top-p mass prefix.

When to use this tool

Use Top P Boundary Token Residual Mass when checking the stated model-dimension, ranking, probability-prefix or local transform convention.

How to use the tool and how it works

  1. Enter probabilities, threshold. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read boundaryIndex, massBefore, massThrough, excess. Use the output convention below.

Return the boundary token of a sorted top-p mass prefix. Require nonempty descending probabilities in [0,1], total within 1e-12 of one and threshold in (0,1]; select first cumulative sum >= threshold, falling back to last index, return before/through masses and excess.1

Nucleus sampling selects a probability-mass prefix. This helper identifies a supplied sorted distribution’s boundary and mass; it does not sample a token or run a language model.2

Input fieldMeaning and unitsAccepted input
probabilitiesProbabilitiesRequired. Array of finite number; maximum items 256.
thresholdThresholdRequired. Finite number.
Output fieldInterpretationReturned shape
boundaryIndexBoundary IndexRequired. Safe integer.
massBeforeMass BeforeRequired. Finite number.
massThroughMass ThroughRequired. Finite number.
excessmassThrough-threshold; may be slightly negative at the last-token fallback under accepted normalization tolerance.Required. Finite number.
json
{
  "input": {
    "probabilities": [
      0.5,
      0.3,
      0.2
    ],
    "threshold": 0.7
  },
  "output": {
    "boundaryIndex": 1,
    "massBefore": 0.5,
    "massThrough": 0.8,
    "excess": 0.10000000000000009
  }
}

Limitations and assumptions

  • The last-index fallback can give a tiny negative excess under allowed roundoff; no token is sampled and no language model is executed.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use a complete implementation with verified tensor/token conventions and appropriate model evaluation when actual inference, memory, sampling or quality results are required.

References

  1. Calculation and input contract: artificial-intelligence/top-p-boundary-token-residual-mass — tool.io

  2. The Curious Case of Neural Text Degeneration — Ari Holtzman and coauthors

Similar or alternative tools