Decoding sampling hyperparameters
This is a vibe-coded toy to play with decoding hyperparameters; one could maybe call it decoding decoding hyperparameters. Anyway, the below is a first attempt to try and understand how top_k, top_p, and
temperature influence the result of next token prediction.
So, there is not yet any guarantee on the validity of the approximately 100 lines of JavaScript code underpinning this toy.
I will now yield the floor to GPT 5.6 Sol.
Language models choose each new token from a probability distribution. Temperature reshapes that distribution, top-k keeps the most likely candidates, and top-p keeps the smallest group whose combined probability reaches a chosen threshold.
Prompt: Once upon a time in …
Tokens removed by top-k or top-p are shown with a probability of zero.