MoonSay /Tutorials/Machine Learning Interview #1
Contents
  1. 01Introduction
  2. 02The learning signal
  3. 03Supervised learning
  4. 04Clustering
  5. 05Dimensionality reduction
  6. 06Semi-supervised learning
  7. 07Label propagation
  8. 08Self-training, consistency and FixMatch
  9. 09Self-supervised learning
  10. 10Putting it all together
  11. 11Interview questions and model answers
  12. 12Summary
  13. References

11Interview questions and model answers

10 questions · click a question to see a brief answer
Q1How do supervised, unsupervised, semi-supervised and self-supervised learning differ?
Brief answer

They differ in where the learning signal comes from. Supervised learning uses human labels for every example; unsupervised learning uses only the inputs and finds structure such as clusters or principal directions; semi-supervised learning combines a few labels with many unlabeled inputs; self-supervised learning creates targets from the inputs themselves, for example by masking words and predicting them. Finish with the big picture: pretrain with self-supervision, then fine-tune with supervision.

Q2Is self-supervised learning a kind of unsupervised learning?
Brief answer

By data, yes, since no person labels anything. By training, it is supervised: there is a target and a supervised loss, such as cross-entropy over the vocabulary in masked language modeling. A good definition is “supervised learning with labels computed from the inputs”.

Q3Why can unlabeled data improve a classifier, and when can it hurt?
Brief answer

Unlabeled data reveal the input distribution p(x). That helps when p(x) is linked to p(y\mid x): nearby points share labels (smoothness), boundaries lie in low-density regions, or data lie on manifolds. It can hurt when these assumptions fail, when the unlabeled data contain other classes or come from a different distribution, or when confident wrong pseudo-labels reinforce themselves (confirmation bias).

Q4Explain K-means. Does it always converge, and to what?
Brief answer

Alternate two steps: assign each point to its nearest centre, then move each centre to the mean of its points. Both steps minimize the within-cluster sum of squares exactly over one set of variables, so the objective never increases, and since there are finitely many assignments the algorithm stops. It reaches a local minimum, so use k-means++ seeding and restarts; choose K by elbow, silhouette or the application.

Q5Derive PCA. How is it related to the SVD?
Brief answer

Maximize the variance u^\top\Sigma u of the projections subject to \|u\|=1; the Lagrangian gives \Sigma u=\lambda u, and the variance equals \lambda, so the first component is the top eigenvector of the covariance matrix. Equivalently it minimizes the squared reconstruction error, by Pythagoras. In practice use the SVD of the centred data matrix: its right singular vectors are the components. Centre, and standardize features with different units.

Q6How does label propagation work?
Brief answer

Build a k-nearest-neighbour graph with weights that decay with distance and let labels spread: each point repeatedly averages its neighbours’ label scores while labeled points are pulled back to their labels, F\leftarrow\alpha SF+(1-\alpha)Y. The fixed point is (1-\alpha)(I-\alpha S)^{-1}Y, the minimizer of a smoothness-plus-fit objective. Labels travel along many short paths through dense regions, so the boundary falls in low-density gaps.

Q7Compare pseudo-labeling, consistency regularization and FixMatch.
Brief answer

Pseudo-labeling trains on the model’s own confident predictions; it is a form of entropy minimization and risks confirmation bias. Consistency regularization requires the same prediction under small perturbations of the input. FixMatch combines them: a pseudo-label from a weakly augmented view, kept only if its confidence exceeds a threshold such as 0.95, is used as the target for a strongly augmented view.

Q8What is contrastive learning, and what does the temperature do?
Brief answer

Make two augmented views of each image, and train an encoder so that each view picks out its partner among all views in the batch, using the InfoNCE loss: a softmax cross-entropy over cosine similarities divided by a temperature. It maximizes a lower bound on the mutual information between views. A small temperature sharpens the softmax and focuses on hard negatives; larger batches give more negatives.

Q9What is the difference between BERT’s and GPT’s pretraining objectives?
Brief answer

BERT masks 15% of the tokens and predicts them from context on both sides (masked language modeling), which suits understanding tasks. GPT predicts each token from the tokens before it (next-token prediction), which by the chain rule is maximum likelihood for the text and lets the model generate text. Both are self-supervised: the targets are words of the input.

Q10You have a million unlabeled images and a thousand labeled ones. What would you do?
Brief answer

First train a supervised baseline on the thousand labels, ideally starting from a model pretrained on a large dataset, and keep a labeled validation set. Then use the unlabeled images: self-supervised pretraining or continued pretraining on them, followed by fine-tuning, and/or a semi-supervised method such as FixMatch. Check that the unlabeled images match the target distribution, and label next the examples the model is least sure about (active learning).