# Fix Embedding Anisotropy & Narrow-Cone Cosine Collapse in Domain Corpora

> On homogeneous legal, SEC 10-K, medical, or monorepo corpora, OpenAI text-embedding-3-large and Google gemini-embedding-001 pack every passage into a narrow anisotropic cone where completely unrelated chunks score 0.78 to 0.88 cosine similarity. Subtracting the corpus mean vector and projecting out dominant boilerplate directions restores angular separation, while Voxell Forge automates C_corpus dialect conditioning natively.

Canonical URL: https://voxell.ai/optimize/embedding-anisotropy-mean-centering-domain-drift/


## Diagnosing Narrow-Cone Collapse in Production

Sample `1,000` random, **unrelated** chunk pairs from your production vector table (`ORDER BY random() LIMIT 2000`) and inspect their cosine similarity distribution. On general web text, random pairs hover around `0.15 - 0.32`. On specialized enterprise corpora (Delaware M&A agreements, Kubernetes YAML + Go monorepos, FDA 510(k) dockets, or SEC 10-K footnotes), `text-embedding-3-large` and `gemini-embedding-001` routinely produce:

- **Random unrelated pair mean cosine:** `0.76 - 0.84`
- **True top-1 relevant match cosine:** `0.85 - 0.89`
- **Effective discriminative margin:** `< 0.05`!

Three things break immediately when `90%` of vector energy points along a single domain-boilerplate centroid $\mu_{\text{corpus}}$:
1. **Hard similarity cutoffs (`WHERE 1 - (emb <=> q) > 0.78`)** admit thousands of irrelevant chunks or reject valid cross-terminology queries.
2. **1-bit binary quantization (`binary_quantize`)** collapses because every vector shares identical signs on the dominant coordinates, destroying Hamming selectivity.
3. **Boilerplate headers dominate signal:** Shared disclaimers (*"Forward-Looking Statements"*, copyright headers) overpower 4-token numeric or identifier differences.

## Runnable Fix: All-but-the-Top (`Mu` Subtraction + Top-$k$ PCA Projection)

Mu & Viswanath's *All-but-the-Top* post-processing removes the corpus mean $\mu$ and projects out the top $k$ (`k = 2..5`) shared syntax/boilerplate principal components fitted **once** on a sample of `20,000` corpus vectors. Crucially, apply the exact same $(\mu, U_k)$ transform to **both** corpus chunks and incoming queries, followed by L2 normalization:

```python
import numpy as np

class AnisotropyConditioner:
    """Zero-LLM post-processor for OpenAI / Gemini narrow-cone corpora."""

    def __init__(self, n_remove_components: int = 3):
        self.k = n_remove_components
        self.mu: np.ndarray | None = None      # shape (D,)
        self.top_pcs: np.ndarray | None = None # shape (k, D)

    def fit(self, sample_embeddings: np.ndarray) -> "AnisotropyConditioner":
        # sample_embeddings: (N, D) float32, unit-normalized
        x = sample_embeddings.astype(np.float64)
        self.mu = x.mean(axis=0)
        centered = x - self.mu
        # Economy SVD to extract top-k boilerplate directions
        _, _, vt = np.linalg.svd(centered, full_matrices=False)
        self.top_pcs = vt[: self.k]  # (k, D)
        return self

    def transform(self, embeddings: np.ndarray) -> np.ndarray:
        assert self.mu is not None and self.top_pcs is not None
        centered = embeddings.astype(np.float64) - self.mu
        # Subtract projection onto top-k boilerplate components: c - (c @ U^T) @ U
        proj = (centered @ self.top_pcs.T) @ self.top_pcs
        cleaned = (centered - proj).astype(np.float32)
        norms = np.linalg.norm(cleaned, axis=1, keepdims=True)
        return cleaned / np.maximum(norms, 1e-12)
```

## Benchmark Impact on Specialized Enterprise Corpora (`SEC 10-K` + Monorepo)

| Pipeline Configuration | Unrelated Pair Cosine Mean | Relevant vs Noise Margin | `1-Bit` Binary `Recall@20` | Stage-1 Dense `nDCG@10` |
| :--- | :--- | :--- | :--- | :--- |
| Raw `text-embedding-3-large` (`3072d`) | `0.81` | `0.06` | `78.4%` | `0.582` |
| Raw `gemini-embedding-001` (`3072d`, `RETRIEVAL_*`) | `0.79` | `0.08` | `81.1%` | `0.604` |
| OpenAI `3-large` + `v - mu_corpus` (`k=3` All-but-Top) | `0.04` | `0.41` | `95.6%` | `0.629` |
| **Voxell Forge `Pro` (`2560d` + native `C_corpus`)** | **Zero-centered dialect space** | **`0.49`** | **`99.04% Recall@20` (Play 1 AMQ)** | **`0.6652` (`0.8849` w/ `Max`)** |

## Architectural Upgrade: Native `C_corpus` Without State-Sync Drift

Shipping `.npz` mean/PCA artifacts across Python workers, Go API gateways, and background re-indexers introduces silent version skew: if a query service loads `v1` of `(mu, top_pcs)` while an ingestion worker writes `v2`, recall craters overnight.

**Voxell Forge** runs **zero-LLM `C_corpus` dialect conditioning** natively inside the storage-coupled GPU pipeline, pairing `99.04% Recall@20` Stage-1 dense retrieval (**$0.25/1M** tokens on `Pro`; **$0** forever on `Turbo`) with Stage-2 `Max` cross-encoder reranking (`0.8849 nDCG@10`, `75.93% Strict@1`) from **$199/mo** annual. Verify on overlapping legal boilerplate right now:

```bash
curl -sS -X POST https://api.voxell.ai/api/v1/agent/bakeoff \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [
      {"name": "note-12-debt.md", "text": "Pursuant to the Amended Credit Facility dated March 15, 2026, Senior Term Loan B bears SOFR + 275 bps maturing 2030."},
      {"name": "note-13-leases.md", "text": "Pursuant to the Amended Facility Agreement dated March 15, 2026, Marysville data center lease obligations use a 6.1% incremental borrowing rate."}
    ],
    "queries": ["What interest spread applies to Senior Term Loan B under the March 2026 credit facility?"]
  }'
```

Size your index in the **[Vector RAM & TCO Calculator](/tools/vector-calculator/)**, compare against **[Contextual Retrieval LLM Ingest Taxes](/optimize/contextual-retrieval-vs-late-chunking-vs-zero-llm/)**, or open the **[Forge Console](https://dash.voxell.ai/home)** (**[v4.0 Pricing](/pricing/)**).

## Frequently Asked Questions

### Why do two completely unrelated legal or code chunks have 0.82 cosine similarity?

Pretrained transformer embeddings allocate dominant high-variance directions to shared domain syntax, boilerplate legalese, and token frequency statistics. Inside a specialized single-domain corpus, every vector shares a large common mean component mu_corpus, compressing pairwise cosines into a narrow [0.78, 0.94] band.

### Does corpus mean-centering hurt binary quantization or cosine thresholds?

Mean-centering dramatically improves both! Shifting the centroid to the origin balances positive and negative coordinate signs (maximizing 1-bit binary quantization entropy in Guide 05) and spreads cosine similarity cleanly across [-0.30, +0.85] so abstention thresholds stop misfiring.

### How does Voxell Forge C_corpus conditioning improve over offline PCA whitening?

Manual PCA whitening requires fitting and versioning external numpy matrices across ingestion and query microservices. Voxell Forge computes C_corpus zero-LLM dialect conditioning natively inside the GPU pipeline, lifting Stage-1 dense nDCG@10 to 0.6652 and Recall@20 to 99.04% ($0.25/1M on Pro).

---

## Zero-Install Model Context Protocol (MCP) & Keyless Agent Verification

```bash
claude mcp add --transport http voxell-forge https://api.voxell.ai/mcp/try
```

- Keyless Retrieval Bake-Off: `POST https://api.voxell.ai/api/v1/agent/bakeoff`
- Keyless Contradiction X-Ray: `POST https://api.voxell.ai/api/v1/agent/xray`
- Machine-Readable Pricing JSON: `https://voxell.ai/api/v1/agent/pricing.json`
- Full LLM Authority Map: `https://voxell.ai/llms-full.txt`
