How Top-P, Top-K, and temperature decide which word comes next
An LLM is a model that 'predicts the word most likely to come next as a continuation of the text so far'. It computes a probability for each candidate next word, selects one word from them to output, and repeats this process to generate text. The three inference parameters that control this 'way of selecting the next word' are top-p, top-k, and temperature.
・top-p (nucleus sampling): narrows the candidates to the top words until the cumulative probability reaches a set value (because it narrows by the sum of probabilities, the number of candidates changes dynamically).
・top-k: narrows the candidates to the top k items by probability (a fixed count).
・temperature: adjusts the overall sharpness of the probability distribution (lower is more certain, higher is more diverse).
All of these operate at inference time. Number of epochs, learning rate, and batch size are settings for 'training time' and are not parameters that narrow output candidates at inference time.