Neighborhoods and Manifolds

Concepts

CHAPTER 06 — NEIGHBORHOODS AND MANIFOLDS

PART II — INSIDE THE SPACE

PURPOSE

Study local structure directly and show it is non-uniform: hubs, anti-hubs, variable density, fuzzy boundaries, and a manifold assumption that holds within clusters and fails between them. Give the visualization trap its full treatment.

CENTRAL QUESTION

How uniform is local structure across an embedding space, and where is it untrustworthy?

UNIQUE CLAIM

Raw kNN quality is regional, not global: hubness (a high-dimensional artifact where a few points enter a large fraction of neighbor lists regardless of topic) inflates apparent relevance and displaces correct answers, and removing hubs can raise Recall@10.

THE OBJECT

Neighborhoods — kNN, local density, clusters, boundaries, hubs, outliers. Demonstration: 1,000-item RELATE space where 5 hubs appear in 40%+ of neighbor lists, ~8% of items are anti-hubs, density varies 4x, and dropping hubs improves retrieval.

CONCEPTS INTRODUCED

k-nearest neighbors; local density (distance-to-kth-neighbor); cluster / boundary; hubness and mitigations (mutual-kNN, local scaling, centering); anti-hubs; manifold assumption and its local-only validity; local intrinsic dimension varying by region; t-SNE/UMAP preserving local topology while distorting global distance and equalizing density.

CONCEPTS DEVELOPED / REUSED

Visualization warning from Ch2 deepened (perplexity/n_neighbors artifacts, noise-as-cluster demo); rare-item noise from Ch3 becomes off-manifold points; boundary items feed Ch15 (neighborhood stability) and Ch12 (retrieval policy); hub mitigation deferred to Ch12.

PREREQUISITES

Ch1–5. Nearest-neighbor search, distance percentiles.

LOCAL INVARIANTS

Do not trust raw kNN uniformly; never read a hub as important; test every visual gap against n_neighbors/perplexity; density is topic frequency, not relevance.

FAILURE MODES

Uniform trust in raw kNN; reading hubs as popular/important; believing a UMAP gap; assuming density equals relevance.

DIAGNOSTIC METHOD

  1. Compute full-space kNN for all items. 2. Histogram in-degree; list and read hubs. 3. Measure anti-hub fraction and density ratio. 4. Flag boundary items (mixed-label neighborhoods). 5. Intervene: drop hubs, re-score retrieval.

RESEARCH-DERIVED IDEAS

Hubness in high-dimensional data (Radovanović, Nanopoulos & Ivanović); hubness reduction (mutual proximity, local scaling); manifold hypothesis for natural data; t-SNE (van der Maaten & Hinton) and UMAP (McInnes et al.) local-structure objectives and known global-distance distortion; “how to use t-SNE effectively” perplexity cautions. Named without citation metadata; hubness skew is MEASURED (Wave 1 row 1.5); at n=1,173 hub removal does not raise Recall@10 (a large-corpus effect).

EXPERIMENT / LAB

Lab 6 (PROPOSED): in-degree histogram + top-10 hub read; anti-hub fraction; density ratio p90/p10; boundary-item fraction; hub-removal intervention with before/after Recall@10. Deliverable: one-page neighborhood map of where kNN is and is not trustworthy.

COMPANION COMPONENT

neighborhood_report(space): hub_list, anti_hub_fraction, density_map, boundary_items, local_id_estimate. Attached to every indexed space; hub list surfaced in retrieval diagnostics.

READER OUTCOME

Reader can produce a neighborhood map of any space, identify its hubs and sparse regions, and predict where retrieval rankings will be unstable.

DEPENDENCIES

Ch1, Ch2, Ch3, Ch4, Ch5.

FORWARD BRIDGE

Ch7 “How Many Dimensions Does Meaning Need?” — variable local dimension and the arbitrary basis both point to: how many degrees of freedom does the representation actually use?

ANTI-CLAIMS / LIMITS

Does not claim hubness always harms a given application (measure it) or that clusters equal categories; claims kNN quality is regional and the hub list must be known.

Explain this chapter with AI

Copy this prompt into ChatGPT, Claude, Gemini, a local model, or another AI.

Apply this chapter with AI

Copy this prompt into ChatGPT, Claude, Gemini, a local model, or another AI.

Part II — Inside the Space

The question a vector cannot answer alone

Hand someone a single embedding vector and ask what it means. They cannot say. Hand them the vector and its ten nearest neighbors and they can usually tell you the topic, the register, and roughly what it is.

Meaning, operationally, is locality: a vector is characterized by what it is near. So the honest object of study is not the point — it is the neighborhood.

How uniform is local structure across an embedding space, and where is it untrustworthy?

The vocabulary of local structure

  • k-nearest neighbors. The k closest points to a query. The atomic operation of retrieval, clustering, and deduplication.
  • Local density. How tightly packed a region is. Distance-to-10th-neighbor is a cheap estimate. Dense regions: common topics. Sparse regions: rare or unusual content.
  • Cluster. A connected dense region. May or may not correspond to a human category.
  • Boundary. Where two clusters meet. Items here have mixed neighborhoods and unstable rankings.
  • Hub. A point that appears in an unusually large number of other points’ neighbor lists. Hubs are a high-dimensional pathology, not a sign of importance.
  • Outlier / anti-hub. A point that is in nobody’s neighbor list. Often short, generic, or malformed text.

Hubness: the defect that looks like relevance

In high-dimensional spaces, the distribution of “how often is point p someone’s nearest neighbor” becomes badly skewed. A few points become nearest neighbor to hundreds of queries regardless of the query’s topic.

low-dimensional space:   every point is NN to ~k others, roughly uniform
high-dimensional space:   a few hubs are NN to 100s; many points are NN to 0

Why it matters: a hub near the top of every result list looks like a great match and is actually a geometric artifact. Mitigations exist — mutual-kNN, local scaling, cross-domain similarity normalization, centering — and they belong in the retrieval policy (Chapter 12). Here, the point is to measure hubness before trusting raw kNN.

The manifold assumption, and where it breaks

The comforting story: embeddings of real text lie on a low-dimensional curved surface (a manifold) inside the high-dimensional space, and distances along that surface track meaning. Often roughly true. Where it breaks:

  • Between clusters, there is no surface — the “distance” across a gap between two topic clusters is not a meaningful semantic quantity, just Euclidean space.
  • Rare content sits off the manifold — few similar examples means the local surface is poorly defined.
  • Different regions have different intrinsic dimension — a tight cluster of near-duplicates is locally 1–2 dimensional; a diverse region is locally much higher (Chapter 7).

The visualization trap, revisited with teeth

t-SNE and UMAP optimize to preserve local neighbor relationships and deliberately distort global distance. So:

what a UMAP plot shows well:   which points are in a tight local group
what it shows badly:           how far apart two groups are
                               whether a "gap" is real or an artifact of perplexity/n_neighbors
                               density (both methods equalize it by default)

A demonstration to run once and remember: take three well-separated Gaussian blobs in 50D, plus uniform noise. UMAP will often render the noise as its own tidy “cluster” and place the blobs at arbitrary relative distances. The plot has structure the data does not.

Demonstration: RELATE neighborhoods are lumpy

MEASURED on RELATE v0.1, Wave 1 row 1.5 — artifact experiments/embeddings-from-first-principles/wave1/artifacts/hubness.json.

Embed all 1,173 RELATE items. Compute full-space 10-NN for every item (mean in-degree is 10 by construction).

model               max in-degree   in-degree skew   Recall@10   Recall@10, top-1% hubs removed
all-mpnet-base-v2         31             +0.6           1.000            0.991
all-MiniLM-L6-v2          37             +0.7           0.993            0.990
mxbai-embed-large-v1      35             +1.1           1.000            0.996
bge-small-en-v1.5         45             +1.5           0.971            0.968
bge-large-en-v1.5         49             +1.9           1.000            0.996

The in-degree distribution is right-skewed for every model — a handful of items sit in 3–5× as many neighbor lists as the average, and the skew grows with the model’s anisotropy (Chapter 5). Inspect the hubs: they are the short, generic sentences.

MEASURED: hubness is real and structural. But on a 1,173-item index it does not cost retrieval — removing the top-1% hubs leaves Recall@10 essentially unchanged (and slightly lower, because a few hubs were themselves correct answers). The “hubs displace correct answers” effect the literature reports is a property of much larger indexes; RELATE shows the geometry, not yet the damage. The space is still not a uniform fabric — crowded districts, empty lots, a few corners everyone passes through — and averaged metrics hide all of it.

What this chapter establishes and what it does not

Establishes: local structure is non-uniform; hubness is a measurable high-dimensional artifact that inflates apparent relevance; the manifold assumption holds within clusters and fails between them and for rare content; local intrinsic dimension varies.

Does not establish: that hubness always hurts a given application (measure it), or that any clustering corresponds to your categories. It establishes that raw kNN quality varies by region and that you should know your space’s hub list.

Lab 6: map the local structure

PROPOSED, not executed.

Setup. Embed 1,000+ items. Compute full-space k-NN (k = 10) for all.

Task.

  1. Hubness. Histogram of “in-degree” (how many neighbor lists each item appears in). Report skew, list the top 10 hubs, read them.
  2. Anti-hubs. Fraction with in-degree 0. Read a sample.
  3. Density. Distance-to-kth-neighbor per item; ratio of 90th to 10th percentile.
  4. Boundaries. Items whose 10 neighbors span ≥3 labels.
  5. Intervention. Drop the top hubs from the index; re-score retrieval.
Metric Value
in-degree skew (max / mean)
anti-hub fraction
density ratio (p90 / p10)
boundary-item fraction
Recall@10 before / after hub removal … / …

Success criterion. A one-page “neighborhood map” of your space: where kNN is trustworthy, where it is not, and the hub list to watch.

Companion component: the neighborhood report

neighborhood_report(space):
  hub_list:            top-k items by in-degree
  anti_hub_fraction:   float
  density_map:         per-item distance-to-kth-neighbor
  boundary_items:      ids with mixed-label neighborhoods
  local_id_estimate:   intrinsic dimension per region (from Ch7)

The Observatory attaches this to every indexed space and surfaces the hub list in retrieval diagnostics.

Failure modes

  • Trusting raw kNN uniformly. Quality is regional. Hubs and sparse zones need different handling.
  • Reading hubs as popular/important. They are geometric sinks.
  • Believing a UMAP gap. Change n_neighbors/perplexity and see if it survives.
  • Assuming density = relevance. Dense regions are common topics, not better answers.

What this chapter established

  • The unit of meaning is the neighborhood, not the point.
  • Vocabulary: kNN, local density, cluster, boundary, hub, anti-hub.
  • Hubness is a measurable high-dimensional artifact; a few points become everyone’s neighbor (in-degree skew grows with anisotropy). On the 1,173-item RELATE index removing the top-1% hubs did not change Recall@10 — the “hubs displace correct answers” damage is an effect of much larger indexes; RELATE shows the geometry, not yet the cost.
  • The manifold assumption is local: fine within clusters, meaningless between them, weak for rare content; local intrinsic dimension varies.
  • The neighborhood report: hub list, anti-hub fraction, density map, boundary items — attached to every indexed space.

Next

Chapter 5 said the basis is arbitrary; Chapter 6 said local dimension varies. Both point at one question: how many dimensions does the representation actually use? The next chapter measures intrinsic dimension, effective rank, and the singular-value spectrum — and finds a 1,536-dimensional vector living in far fewer.