← Openai Interview Insights

Openai·Machine Learning Engineer·Onsite - Coding / Algorithms·Senior

Senior
Jul 2026

Summary

ML coding round at OpenAI for an MLE role. The whole thing centered on one meaty calibration problem and then a discussion portion that went places I wasn't fully ready for.

Questions Asked (2)

Q1

Implement a calibration utility for LLM outputs: given logit/probability and ground-truth label pairs from a held-out set, fit a calibration map using temperature scaling, Platt scaling, or isotonic regression so that reported confidence matches empirical accuracy. Then write a function that takes a new logit vector and returns a calibrated probability distribution.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

I went straight to temperature scaling because it's the simplest and I could actually derive the optimization cleanly under time pressure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: the utility should fit a calibration map on a held-out set and then apply it to new logits. Discuss the trade-offs between temperature scaling, Platt scaling, and isotonic regression, and justify your choice based on data size and model output characteristics. Then outline the implementation steps, including fitting the calibrator and applying it to produce calibrated probabilities.

Pro tip: Emphasize that calibration should be evaluated on a separate validation set to avoid overfitting, and mention that temperature scaling is often preferred for neural networks due to its simplicity and effectiveness, but isotonic regression can be better with abundant data.

1. Clarify requirements and data

Confirm the input format (logits or probabilities), the size of the held-out set, and whether the task is binary or multiclass. Discuss the need for a separate calibration set.

2. Choose calibration method

Compare temperature scaling, Platt scaling, and isotonic regression in terms of assumptions, data requirements, and computational cost. Select one and justify.

3. Implement fitting procedure

Describe how to fit the chosen calibrator: for temperature scaling, optimize a single temperature parameter by minimizing NLL on the calibration set; for Platt scaling, fit a logistic regression on the logits; for isotonic regression, fit a non-decreasing function.

4. Implement prediction function

Write a function that takes new logits, applies the fitted calibration map, and returns calibrated probabilities (e.g., softmax with temperature, sigmoid with Platt parameters, or isotonic interpolation).

5. Evaluate and validate

Assess calibration using metrics like Expected Calibration Error (ECE) or reliability diagrams on a validation set. Discuss potential pitfalls like overfitting and how to mitigate them.

Key Points to Mention

  • Temperature scaling: a single scalar parameter that scales logits before softmax; preserves argmax but changes confidence.
  • Platt scaling: fits a logistic regression model to the logits (or scores) to produce calibrated probabilities; can be extended to multiclass via one-vs-all.
  • Isotonic regression: non-parametric, fits a piecewise-constant non-decreasing function; requires more data to avoid overfitting.
  • Evaluation metrics: Expected Calibration Error (ECE), Maximum Calibration Error (MCE), reliability diagrams, and negative log-likelihood (NLL).
  • Implementation details: use a separate calibration set, handle numerical stability (e.g., log-sum-exp), and consider vectorization for efficiency.
  • Trade-offs: temperature scaling is simple and effective for neural networks but assumes a single temperature; Platt scaling is more flexible but may overfit with small data; isotonic regression is flexible but data-hungry.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Walk through how you'd construct a reliability diagram and compute expected calibration error (ECE), and discuss the trade-offs between temperature scaling, Platt scaling, and isotonic regression as calibration methods.

Technical Trade-offsA/B Testing & Experimentation
Author's notes

Reliability diagrams I knew cold, bucketing predictions and plotting mean confidence vs accuracy per bin.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining reliability diagrams and ECE, then walk through the construction steps with attention to binning choices and their impact. Compare temperature scaling, Platt scaling, and isotonic regression in terms of flexibility, data requirements, and performance, and discuss trade-offs in the context of real-world deployment.

Pro tip: Emphasize that calibration should be evaluated on a held-out set and that the choice of binning scheme (e.g., equal-width vs. equal-frequency) can significantly affect ECE; mention that adaptive binning or kernel density estimators can provide more reliable estimates.

1. Define Reliability Diagram and ECE

Explain that a reliability diagram plots predicted probability vs. observed accuracy, and ECE is the weighted average of the absolute difference between confidence and accuracy across bins.

2. Construct Reliability Diagram

Describe binning predictions (e.g., into 10 equal-width bins), computing the average confidence and accuracy per bin, and plotting them with the identity line for reference.

3. Compute ECE

Detail the formula: ECE = sum over bins of (|B_m|/n) * |acc(B_m) - conf(B_m)|, and discuss how binning choices affect the result.

4. Compare Calibration Methods

Discuss temperature scaling (single parameter, preserves accuracy, requires logits), Platt scaling (logistic regression on scores, works for binary/multiclass), and isotonic regression (non-parametric, flexible but prone to overfitting with limited data).

5. Discuss Trade-offs and Practical Considerations

Highlight trade-offs: temperature scaling is simple and effective for neural networks but assumes a single temperature; Platt scaling is more flexible but can overfit; isotonic regression is highly flexible but needs lots of data and can produce non-monotonic calibrations. Mention evaluation on validation set and potential need for recalibration over time.

Key Points to Mention

  • Binning strategies for reliability diagrams (equal-width vs. equal-frequency) and their impact on ECE
  • ECE formula and its sensitivity to bin size and number of samples
  • Temperature scaling: single scalar parameter, optimizes NLL, preserves argmax accuracy
  • Platt scaling: fits logistic regression to model scores, can be applied to multiclass via one-vs-all
  • Isotonic regression: non-parametric, monotonic, but requires sufficient data to avoid overfitting
  • Evaluation of calibration on a held-out set and potential need for recalibration due to distribution shift

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.