Skip to content
nonconvexcard

Measure anisotropy in an embedding space

CodingIntermediate⏱ 1 hourRAGanisotropywhiteningsimulationdiagnostics

Problem

Write a diagnostic for embedding anisotropy.

  1. Measure the mean and standard deviation of the cosine between random unrelated pairs and compare with the isotropic predictions 00 and 1/d1/\sqrt d.
  2. Compute the spectrum of the embedding covariance and the stable rank ∥Σ∥F2/∥Σ∥2\|\Sigma\|_F^2/\|\Sigma\|^2.
  3. Apply mean-centring and whitening and re-measure.
  4. Report what each step does to the contrast between matched and unmatched pairs.

Implement it, then check the implementation against something you can verify independently.

Write it

Solve it here8 tests · Python runs in your browser
⌘/Ctrl + ↵ to run · limit 60s · draft saved in this browser
8 tests will run against your code. The first run downloads the Python runtime — several megabytes, once per browser.

Solution

Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.

Related problems

All problems
SolvedProblemFieldTypeDifficultyTime
Three similarities agree on the unit sphereRAGProofFoundation15 min
Simulate distance contrast runClassical MLCodingBeginner30 min
A sufficient condition for correct retrievalRAGProofIntermediate30 min
Balls into bins, with one choice and with two runAI SystemsCodingIntermediate1 hour
Cache hit rates under Zipf popularity runAI SystemsCodingIntermediate1 hour