Why does KNN often perform much better on learned embeddings than on raw input features?

Quick Overview

Asks why k-nearest neighbors works much better on learned embeddings than on raw features such as pixels or word counts. Tests understanding of distance geometry, learned invariances, dimensionality, metric-learning objectives, normalization, and when off-domain embeddings fail.

Why does KNN often perform much better on learned embeddings than on raw input features?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why does KNN often perform much better on learned embeddings than on raw input features? ```hint What KNN assumes KNN assumes that points close under the chosen distance share a label. Ask whether that holds when the distance is computed on pixels or word counts. ``` ```hint Look at the training loss Think about what the loss used to train an embedding model rewards in terms of distances between examples. ``` ### What a Strong Answer Covers - KNN's dependence on the distance function and the assumption that nearby points share labels - Concrete ways raw-feature distance fails (nuisance variation, sparse vocabularies, irrelevant or unscaled features) - What a learned embedding changes: invariances, a lower and denser space, and objectives trained for neighbor structure - Practical choices such as normalization and the distance metric - When embeddings do not help, such as a domain mismatch or a training objective unrelated to the task ### Follow-up Questions - After L2 normalization, do cosine distance and Euclidean distance return different neighbors? - An off-the-shelf text embedding gives poor KNN results on legal documents. What would you try? - How would you run KNN over 100 million embeddings within a tight latency budget, and what do you give up?

Overview: Asks why k-nearest neighbors works much better on learned embeddings than on raw features such as pixels or word counts. Tests understanding of distance geometry, learned invariances, dimensionality, metric-learning objectives, normalization, and when off-domain embeddings fail.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Why does KNN often perform much better on learned embeddings than on raw input features?

What a Strong Answer Covers Guidance

  • KNN's dependence on the distance function and the assumption that nearby points share labels
  • Concrete ways raw-feature distance fails (nuisance variation, sparse vocabularies, irrelevant or unscaled features)
  • What a learned embedding changes: invariances, a lower and denser space, and objectives trained for neighbor structure
  • Practical choices such as normalization and the distance metric
  • When embeddings do not help, such as a domain mismatch or a training objective unrelated to the task

Follow-up Questions Guidance

  • After L2 normalization, do cosine distance and Euclidean distance return different neighbors?
  • An off-the-shelf text embedding gives poor KNN results on legal documents. What would you try?
  • How would you run KNN over 100 million embeddings within a tight latency budget, and what do you give up?