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/8
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/4
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.