Bird
0
0

Which of the following code snippets correctly applies temperature scaling to logits before sampling in Python?

easy📝 Syntax Q12 of 15
NLP - Text Generation
Which of the following code snippets correctly applies temperature scaling to logits before sampling in Python?
Aprobs = softmax(logits / temperature)
Bprobs = softmax(logits * temperature)
Cprobs = softmax(logits + temperature)
Dprobs = softmax(logits - temperature)
Step-by-Step Solution
Solution:
  1. Step 1: Recall temperature scaling formula

    Temperature is applied by dividing logits by temperature before softmax to adjust randomness.
  2. Step 2: Identify correct operation

    Dividing logits by temperature scales the logits correctly; multiplying or adding is incorrect.
  3. Final Answer:

    probs = softmax(logits / temperature) -> Option A
  4. Quick Check:

    Divide logits by temperature before softmax [OK]
Quick Trick: Divide logits by temperature before softmax [OK]
Common Mistakes:
MISTAKES
  • Multiplying logits by temperature instead of dividing
  • Adding temperature to logits
  • Subtracting temperature from logits

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes