← Newsbreak Interview Insights
Start by clearly defining temperature scaling as a post-hoc calibration method that rescales logits by a single scalar T, then derive the NLL loss and its gradient with respect to T. Finally, implement gradient descent to learn T on a validation set and apply it to calibrate new predictions, emphasizing that T is learned without changing the model's parameters.
Pro tip: Mention that temperature scaling preserves the argmax (accuracy) while improving calibration, and that T is typically optimized on a validation set to avoid overfitting. Also, note that T > 1 softens probabilities, while T < 1 sharpens them.
Introduce temperature scaling as a post-processing step where logits z_i(x) are divided by a scalar T, and probabilities are computed via softmax(z_i(x)/T). Emphasize that T is a single parameter learned on a validation set.
Write the NLL loss on a held-out validation set: L(T) = -Σ log p_{y_i}(x_i; T), where p_{y_i} is the temperature-scaled probability for the true class y_i.
Compute ∂L/∂T by applying the chain rule: ∂L/∂T = (1/T^2) Σ (z_{y_i} - Σ_j p_j z_j), where p_j are the temperature-scaled probabilities. Show that this gradient is used for optimization.
Write Python code that initializes T=1, computes the loss and gradient on validation logits, and updates T using gradient descent (or a library optimizer) until convergence.
Use the learned T to calibrate new predictions by computing softmax(z_i(x)/T). Highlight that this does not change the predicted class, only the confidence estimates.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.