How to use the Temperature and Top-p Playground
- 1. Set the candidatesUse the example tokens and logits or type your own, like word: 2.5.
- 2. Show probabilitiesSee the softmax, the effect of temperature and the final chance for each token.
- 3. Move the slidersChange temperature, top-k and top-p and watch the table and samples update.
How sampling works
At each step a language model scores every possible next token; these raw scores are called logits. To pick one, the logits are divided by the temperature and passed through softmax to become probabilities. Low temperature sharpens the distribution towards the top token; high temperature flattens it. Top-k keeps only the k most likely tokens. Top-p (nucleus sampling) keeps the smallest set whose probabilities add up to p. What's left is renormalised and one token is drawn at random. Temperature 0 means always taking the top token.
Worked example
The example asks what follows "My favourite programming language is" with eight made-up logits, from Python 3.2 down to COBOL −1.0. At temperature 1 with no cut-offs, Python has a 40.7% chance and the entropy is 2.32 bits. Lower the temperature to 0.5 and Python rises to 65.1% (entropy 1.48 bits). Set top-p to 0.9 at temperature 1 and the last three tokens are removed, leaving 5, with Python at 43.9%. With top-k = 3 only Python, JavaScript and Java remain, at 51.1%, 28.1% and 20.8%.
Practical settings
- For facts, code and extraction, use a low temperature (0–0.3) so answers are steady.
- For brainstorming and creative writing, 0.7–1.0 gives more variety.
- Many providers suggest changing temperature or top-p, not both.
- Some newer reasoning models fix or ignore these settings; check your provider's docs.
Frequently asked questions
Are these real model probabilities?
No. The logits are a made-up example so the effect is easy to see. Edit them to experiment; the maths is the same that real samplers use.
Which order are the filters applied in?
Temperature, then softmax, then top-k, then top-p, then renormalise, the order used by Hugging Face Transformers. Some APIs differ slightly.
Is the temperature and top-p playground free?
Yes. You can open the temperature and top-p playground and fill in everything without signing up. When you show probabilities for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.