Top-p keeps the shortest sorted prefix whose cumulative assigned weight reaches the stated threshold. The weights here are exact assigned weights, not computed softmax probabilities.

highlighted = computed this step

Assigned weights are sorted

For this lesson, the sorted assigned weights are A:1/2, B:1/4, C:1/8, and D:1/8. These are assigned exact weights, not computed softmax probabilities.

A:1/2,B:1/4,C:1/8,D:1/8A:1/2,B:1/4,C:1/8,D:1/8
Top-p prefixAssigned exact weights determine the shortest sorted prefix.Top-p prefixAssigned exact weights determine the shortest sorted prefix.Top-p takes a prefixassigned exact weights, not computed softmax probabilitiessorted assigned weightsA1/2B1/4C1/8D1/8thresholdcumulative prefixkept setrulep=3/4A=1/2; A+B=3/4A,Bshortest prefixp=7/8A=1/2; A+B=3/4; A+B+C=7/8A,B,Cshortest prefixtop-k keeps a fixed count; top-p keeps the shortest sorted prefix reaching passigned exact weights, not computed softmax probabilities; deterministic set construction;NOT sampled token; NOT model quality; NOT future behavior

Threshold three-fourths

For p=3/4, token A gives cumulative weight 1/2. A plus B reaches 3/4, so the kept prefix is A,B.

p=3/4:A=1/2,A+B=3/4p=3/4:\quad A=1/2,\quad A+B=3/4
Top-p prefixAssigned exact weights determine the shortest sorted prefix.Top-p prefixAssigned exact weights determine the shortest sorted prefix.Top-p takes a prefixassigned exact weights, not computed softmax probabilitiessorted assigned weightsA1/2B1/4C1/8D1/8thresholdcumulative prefixkept setrulep=3/4A=1/2; A+B=3/4A,Bshortest prefixp=7/8A=1/2; A+B=3/4; A+B+C=7/8A,B,Cshortest prefixtop-k keeps a fixed count; top-p keeps the shortest sorted prefix reaching passigned exact weights, not computed softmax probabilities; deterministic set construction;NOT sampled token; NOT model quality; NOT future behavior

Threshold seven-eighths

For p=7/8, A plus B is still 3/4, and A plus B plus C reaches 7/8. Top-k keeps a fixed count; top-p keeps the shortest sorted prefix whose cumulative assigned weight reaches the stated threshold. This is deterministic set construction, not a sampled token and not a model-quality or future-behavior claim.

p=7/8:A+B+C=7/8p=7/8:\quad A+B+C=7/8
Top-p prefixAssigned exact weights determine the shortest sorted prefix.Top-p prefixAssigned exact weights determine the shortest sorted prefix.Top-p takes a prefixassigned exact weights, not computed softmax probabilitiessorted assigned weightsA1/2B1/4C1/8D1/8thresholdcumulative prefixkept setrulep=3/4A=1/2; A+B=3/4A,Bshortest prefixp=7/8A=1/2; A+B=3/4; A+B+C=7/8A,B,Cshortest prefixtop-k keeps a fixed count; top-p keeps the shortest sorted prefix reaching passigned exact weights, not computed softmax probabilities; deterministic set construction;NOT sampled token; NOT model quality; NOT future behavior