Sampling the next token

Reshape a next-token distribution with temperature, top-k, and top-p, then draw from it and compare the counts.

AdvancedExplained in Predicting the next token

From scores to a chosen token

The bars show the probability of each candidate after temperature, top-k, and top-p. Then one token is drawn at random.

The capital of France is?
Candidate next tokens with their probabilities after your settings
TokenProbabilitypDraws
␣Paris77.9%
␣a7.1%
␣the5.2%
␣located2.6%
␣known1.7%
␣home1.4%
␣one1.2%
␣not0.9%
␣also0.7%
␣called0.6%
␣beautiful0.5%
␣Lyon0.3%

after your settings at temperature 1, before any cuts

Prompt
1.00
off
off
Tokens still in play12 of 12
Uncertainty (entropy)1.39 bits
Most likely␣Paris 77.9%

Try this

  • Compare the Fact and Story prompts at temperature 1. Which has the higher entropy, and why does that match how many good continuations each prompt has?
  • Set temperature to 0.3 and draw 100 times. Then try 1.8. Watch how the counts follow the bars.
  • With top-p at 0.8, switch between prompts and count how many tokens survive each time.

Try "embedding", "softmax", "overfitting", or "backpropagation".