A language model gives logits (2,1,0,−1) for four tokens. What are the sampling probabilities at temperature T=1, T=0.5 and T=2? What happens as T→0 and as T→∞?

Sequence models and transformers, Decoding
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can apply softmax(z/T) and describe how T sharpens or flattens the distribution.

Key idea

pi(T)=ezi/T∑jezj/T. Small T sharpens the distribution towards the arg-max; large T flattens it towards uniform.

Steps

  1. Divide the logits by T before the softmax.
  2. T=1: p=(0.6439, 0.2369, 0.0871, 0.0321).
  3. T=0.5: logits become (4,2,0,−2), so p=(0.8650, 0.1171, 0.0158, 0.0021). The top token gets more mass.
  4. T=2: logits become (1,0.5,0,−0.5), so p=(0.4551, 0.2760, 0.1674, 0.1015). The distribution is flatter.
  5. As T→0, all mass goes to the largest logit, which is greedy decoding. As T→∞, zi/T→0 and p→(14,14,14,14), which is uniform sampling.

Common mistakes

How long your answer should be

Short table of probabilities and two sentences on limits.

Last checked on 4 December 2026.

Read this

Previous in Sequence models and transformers: Three tokens have embeddings x1=(1,0), x2=(0,1) and x3=(1,1). Take Q=K=V=X (no projection matrices) and dk=2. What are the attention weights and output for token 1 using scaled dot-product attention?
Next in Sequence models and transformers: A weight matrix W0∈R4096×4096 is adapted with LoRA of rank r=8. How many trainable parameters does LoRA add for this matrix, and what fraction of the full matrix is that? If LoRA is applied to the query and value matrices of all 32 layers, how many trainable parameters is that in total?