Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the role of temperature in sampling from a language model?
Temperature controls how random or focused the model's predictions are. A low temperature (<1) makes the model more confident and conservative, picking high-probability words. A high temperature (>1) makes the model more creative and random by flattening the probabilities.
Click to reveal answer
beginner
Explain sampling in the context of generating text from a language model.
Sampling means picking the next word based on the model's predicted probabilities instead of always choosing the most likely word. This adds variety and creativity to the generated text.
Click to reveal answer
intermediate
How does increasing temperature affect the probability distribution during sampling?
Increasing temperature makes the probability distribution more even, so less likely words have a higher chance to be picked. This leads to more diverse and surprising outputs.
Click to reveal answer
intermediate
What happens if temperature is set to 0 during sampling?
Setting temperature to 0 means always picking the word with the highest probability (greedy decoding). This removes randomness and can make the output repetitive or dull.
Click to reveal answer
beginner
Why might you want to use a moderate temperature (e.g., 0.7) instead of very low or very high?
A moderate temperature balances creativity and coherence. It allows some randomness for interesting text but keeps the output sensible and relevant.
Click to reveal answer
What does a temperature of 1.0 mean when sampling from a language model?
AProbabilities are flattened to be more even
BThe original predicted probabilities are used without change
COnly the highest probability word is chosen
DProbabilities are sharpened to favor the top word
✗ Incorrect
A temperature of 1.0 means the model uses the original predicted probabilities as they are, without scaling.
What is the effect of setting temperature to a very high value (e.g., 5)?
AModel always picks the most likely word
BOutput becomes very predictable and repetitive
CModel ignores probabilities and picks words randomly
DOutput becomes more random and diverse
✗ Incorrect
High temperature flattens the probability distribution, increasing randomness and diversity in output.
Which sampling method removes randomness completely?
AGreedy decoding (temperature = 0)
BRandom sampling without temperature
CSampling with temperature = 1
DSampling with temperature > 1
✗ Incorrect
Greedy decoding always picks the highest probability word, removing randomness.
Why is sampling preferred over always picking the highest probability word?
AIt makes the output more creative and less repetitive
BIt guarantees the most accurate output
CIt speeds up the generation process
DIt reduces the model size
✗ Incorrect
Sampling adds randomness, making generated text more varied and interesting.
What does lowering temperature below 1 do to the output?
AMakes output more random
BMakes output longer
CMakes output more focused and conservative
DMakes output shorter
✗ Incorrect
Lower temperature sharpens the probability distribution, making the model pick more likely words.
Describe how temperature affects the randomness of text generated by a language model.
Think about how temperature changes the chance of picking less likely words.
You got /4 concepts.
Explain why sampling is used instead of always choosing the most likely word in text generation.
Consider how always picking the top word might affect the text.
You got /4 concepts.
Practice
(1/5)
1. What does increasing the temperature parameter in text generation usually do?
easy
A. Makes the output more predictable and repetitive
B. Stops the model from generating any text
C. Makes the output more random and creative
D. Always selects the most probable next word
Solution
Step 1: Understand temperature effect on randomness
Temperature controls how much randomness is added to the word selection process in text generation.
Step 2: Relate temperature to creativity
Higher temperature increases randomness, making the output more creative and less predictable.
Final Answer:
Makes the output more random and creative -> Option C
Quick Check:
Higher temperature = more randomness [OK]
Hint: Higher temperature means more randomness in output [OK]
Common Mistakes:
Thinking higher temperature makes output more predictable
Confusing temperature with model size
Assuming temperature stops generation
2. Which of the following code snippets correctly applies temperature scaling to logits before sampling in Python?
easy
A. probs = softmax(logits / temperature)
B. probs = softmax(logits * temperature)
C. probs = softmax(logits + temperature)
D. probs = softmax(logits - temperature)
Solution
Step 1: Recall temperature scaling formula
Temperature is applied by dividing logits by temperature before softmax to adjust randomness.
Step 2: Identify correct operation
Dividing logits by temperature scales the logits correctly; multiplying or adding is incorrect.
Final Answer:
probs = softmax(logits / temperature) -> Option A
Quick Check:
Divide logits by temperature before softmax [OK]
Hint: Divide logits by temperature before softmax [OK]
Common Mistakes:
Multiplying logits by temperature instead of dividing
Adding temperature to logits
Subtracting temperature from logits
3. Given logits = [2.0, 1.0, 0.1] and temperature = 0.5, what is the approximate probability of the first token after applying softmax with temperature scaling?
medium
A. About 0.30
B. About 0.60
C. About 0.50
D. About 0.84
Solution
Step 1: Scale logits by dividing by temperature
Divide each logit by 0.5: [2.0/0.5=4.0, 1.0/0.5=2.0, 0.1/0.5=0.2]
Step 2: Calculate softmax probabilities
Compute exp values: exp(4.0)=54.6, exp(2.0)=7.39, exp(0.2)=1.22; sum=63.21; probability first token = 54.6/63.21 ≈ 0.86 (approx 0.86 considering rounding)
Final Answer:
About 0.86 -> Option D
Quick Check:
Lower temperature sharpens distribution, first token ~0.86 [OK]
Hint: Divide logits by temperature, then softmax to find probabilities [OK]
Common Mistakes:
Multiplying logits by temperature instead of dividing
Skipping exponentiation step
Using temperature incorrectly in softmax
4. A developer writes this code to sample a token with temperature 1.5 but always gets the same token. What is the likely bug?