Skip to main content
skill CX Codex official · GitHub

embedding-anisotropy-check — GitHub Copilot skill: setup & use

embedding-anisotropy-check — a GitHub Copilot skill that measures embedding anisotropy and calculates a baseline floor for unrelated vectors. Runs before reporting cosine similarities across models, layers, or retrieval runs.

MIT ★ 41,430 updated 2026-10-23

Install into GitHub Copilot · GitHub CLI All methods and platforms ↓
gh skill install github/awesome-copilot skills/embedding-anisotropy-check
Open on GitHub

What embedding-anisotropy-check does

The skill measures vector anisotropy before any cosine similarity scores are reported. Many sentence encoders and transformer layers point embeddings toward a single shared direction, causing unrelated inputs to score 0.6 or even 0.9. The tool centres vectors using a population mean and evaluates matched pairs against a permuted floor computed from unrelated pairs.

Execution relies on scripts/anisotropy_check.py, which processes two (n, d) arrays named A.npy and B.npy. The script can compute a single mean with --shared or fit domain means using --fit-a and --fit-b. Its report includes anisotropy metrics, raw and centred floors, Cohen's d, and the partner_ranked_first retrieval ranking rate.

The check does not work on two independently trained models without prior space alignment. You must first fit an explicit map such as orthogonal Procrustes. Running the script requires Python 3.9+ and numpy.

What it helps with

  • calculate cosine similarity floor for unrelated vector pairs
  • measure anisotropy across transformer hidden states
  • center embedding spaces using population means
  • verify representation drift across model precisions or runtimes

Example prompts for the agent

  • Run the anisotropy check on A.npy and B.npy before reporting similarity
  • Check if representations in the 4-bit export match bf16 using our train split
  • Evaluate representation shifts between two hidden layers with anisotropy_check.py

How to install embedding-anisotropy-check

1GitHub CLI

gh skill install github/awesome-copilot skills/embedding-anisotropy-check

2Manually: put the files in place

.github/skills/embedding-anisotropy-check/SKILL.md

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about embedding-anisotropy-check

How to install embedding-anisotropy-check in GitHub Copilot?

Run gh skill install github/awesome-copilot skills/embedding-anisotropy-check in your terminal.

What does embedding-anisotropy-check do?

Raw cosine similarity is often biased because models cluster embeddings along a shared direction. The skill computes a baseline similarity floor using unrelated pairs to verify whether high scores reflect genuine alignment.

What are the requirements for embedding-anisotropy-check?

It requires Python 3.9 or higher and numpy. Rebuilding the bundled SciFact example additionally requires datasets, sentence-transformers, and torch.

Source text

SKILL.md · MIT
---
name: embedding-anisotropy-check
description: 'Use before reporting any cosine similarity computed over embeddings or transformer hidden states, whether the agent computed the vectors or loaded them. Measures the anisotropy of each side, centres by the population mean, and scores matched pairs against a permuted floor taken from the same comparison. Use when comparing one model''s embeddings across precisions, runtimes or layers, when evaluating retrieval, probes or adapters, or before calling a similarity high, two conditions in agreement, or a small gap a null.'
license: MIT
compatibility: Python 3.9+ with numpy
---

# Embedding anisotropy check

Raw cosine between embeddings is rarely centred on zero. Most sentence encoders and most hidden-state layers place
every vector near one shared direction, so two unrelated inputs can score 0.6, 0.9 or 0.99. A matched pair at 0.9 is
then not evidence of anything by itself, and a gap of 0.01 between two conditions can be the whole signal or none of
it. This skill makes every such comparison carry its own floor.

## How an agent reaches this skill

The agent does not vectorise anything here. The skill applies at the point where the agent is about to report a cosine
number, whoever produced the vectors:

- **The agent wrote the evaluation.** A request such as "write a retrieval eval for our index" or "check that the 4-bit
  export of this encoder still matches bf16" ends in a script that prints a mean cosine. Before the agent says
  "0.91, the export is fine", it runs the same model's unrelated pairs through the script and reports the floor beside
  the matched figure.
- **The vectors already exist in the workspace.** An `embeddings.npy`, a probe or adapter evaluated on saved hidden
  states, a vector-store dump. Asked "are these two layers encoding the same thing" or "did the fine-tune move the
  representations", the agent loads the arrays and runs the check before answering.
- **A claim is being written.** The agent is drafting a README, a PR description or a results table that calls a
  similarity high, says two conditions agree, or calls a small difference a null. The number in that sentence is the
  trigger.

## When to use this skill

- The same inputs under one model at two precisions (bf16 against 4-bit), in two runtimes, or at two nearby layers,
  which share one coordinate space.
- Query and passage, image and caption, or any other paired evaluation inside one embedding space.
- Any sentence claiming that a similarity is high, that two conditions agree, or that a small difference is a null.

Not for two independently trained models as they stand. A rotation of one model's space keeps its geometry and changes
every cosine against the other model, and centring does not align the two bases. Fit an explicit map first, for
example orthogonal Procrustes on a train split of paired rows, and compare the mapped rows; or compare each model's
own within-space similarities instead.

## Procedure

1. Save the compared rows as two `.npy` arrays of shape `(n, d)`, row `i` of A paired with row `i` of B.
2. Choose where the means come from. The best source is a train split from the same domain, model and modality as the
   compared rows. A mean fitted on another domain mis-centres: it can leave part of the shared direction in place,
   remove too much of it, or add a direction of its own, and what it leaves then looks like an effect of whatever
   differs between the domains.
3. Run the bundled script:

   ```bash
   python scripts/anisotropy_check.py A.npy B.npy --fit-a trainA.npy --fit-b trainB.npy
   ```

   Pass `--shared` when A and B come from one model and one population, so that both sides are centred by one mean.
   Without `--fit-a` and `--fit-b` the means are fitted on the compared rows themselves, and the output's `means`
   field says, for each side, which rows its mean came from.
4. Report, side by side: the anisotropy of each side, matched against floor before centring, matched against floor
   after centring, and `partner_ranked_first` against its chance rate `1/n`.

## Reading the output

- `anisotropy` is the mean cosine between different rows of one side. For large `n` it is close to the squared length
  of the mean of the unit rows, so it measures how much the rows share one common direction, which is what centring
  removes. It does not detect every departure from isotropy: rows spread along one axis in both directions score near
  0 and still give raw cosines of +1 and -1. A value near 0 says there is little within-side mean direction to remove,
  not that raw cosine can be read without its floor. Above about 0.3, rows within that side cluster strongly around a
  mean direction (the script adds a warning); check `raw.floor` to see how much of that direction is shared across
  sides, and report both the raw and centred matched-versus-floor readings (centring changes the scoring function and
  does not replace evaluating an index that searches by raw cosine).
- `raw.floor` is what an unrelated pair scores in this comparison. A matched cosine means something only through its
  distance from this floor.
- `centred.gap_over_floor_sd` and `centred.cohens_d` say whether matched pairs separate from unrelated ones at all.
  When unrelated pairs all score the same, the floor has no spread and `gap_over_floor_sd` is `null`: the gap cannot
  be expressed in floor standard deviations, and the plain `gap` is the figure to read.
- `partner_ranked_first` is the retrieval view of the same pairs. Centring can move a ranking either way, so report it
  both ways rather than assuming it transfers.

## Rules that go with the numbers

- Average the signed difference across seeds or items, then take its absolute value. Averaging absolute differences
  is biased upward, and the bias is greatest when the gap is small relative to its noise.
- Give a gap with its spread and the smallest effect the test could have detected. An underpowered comparison is not
  a refutation, and the report should say which of the two it is.
- Put the floor from the same comparison beside every result. A floor copied from another run, model or domain does
  not correct this one.

## Example

bge-small-en-v1.5 on the first 100 documents of `mteb/scifact`'s corpus, each split into its first and second half at
the middle sentence boundary, with the halves of one abstract as the matched pair and one mean shared by both sides
(`--shared`). `scripts/example_scifact_halves.py` rebuilds it: it pins the corpus at revision `cf10ab6` and the model
at `5c38ec7`, states the sentence split, and needs `datasets` and `sentence-transformers` besides numpy. With datasets
5.0.1, sentence-transformers 6.0.1, torch 2.13.0 and numpy 2.5.1 it gives (rounded to four decimal places):

| | matched | floor (unrelated halves) | gap over floor sd |
| --- | ---: | ---: | ---: |
| raw cosine | 0.8636 | 0.6024 | 4.38 |
| centred cosine | 0.6487 | -0.0131 | 5.87 |

The anisotropy is 0.5956 and 0.6148, and here the two sides share one space, so before centring an unrelated half
already scores 70% of what the matching half scores. Both spaces separate matched from unrelated halves (4.38 floor sd
raw and 5.87 centred) and put the partner first for most abstracts (97 and 98 of 100), while centring removes the
0.6024 baseline offset.

© github · MIT · github/awesome-copilot

Similar skills

All skills for AI and ML →

From the same set993

The whole set →
logicapps-custom-code-net10-migration The logicapps-custom-code-net10-migration GitHub Copilot skill migrates Azure Logic Apps Standard custom-code projects from .NET 8 to .NET 10. It adjusts project files, publication targets, and VS Code debugging configs. CX Codex +1 ★ 41,430repo stars lightweight-charts-react-components The lightweight-charts-react-components GitHub Copilot skill helps build and fix financial charts in React with lightweight-charts. It activates for requests about TradingView charts in React or the package’s chart features. CX Codex +1 ★ 41,430repo stars globestudio Skill for GitHub Copilot and Claude Code designs dotted world maps and animated 3D globes via Globestudio. Builds shareable URL configs and web embed snippets. CX Codex +1 ★ 41,430repo stars foundry-agentic-loop The foundry-agentic-loop GitHub Copilot skill coordinates agent solutions built with Microsoft Foundry and Azure. It handles rapid prototyping, spec-driven development, or improvements based on earlier runs. CX Codex +1 ★ 41,430repo stars diagnose-ci-gate The diagnose-ci-gate GitHub Copilot skill investigates failed CI checks and traces them to a cause. It compares the failure with the base branch and recommends one next action. CX Codex +1 ★ 41,430repo stars caption-qa caption-qa — a skill for GitHub Copilot and other AI platforms that validates .srt and .vtt files against Netflix, BBC, and DCMP standards. It fixes timing and formatting issues while preserving the original dialogue. CX Codex +1 ★ 41,430repo stars azure-logic-apps-standard-cli The azure-logic-apps-standard-cli GitHub Copilot skill manages Azure Logic Apps Standard projects through the Azure CLI extension. It covers workflow authoring, validation, testing, and deployment preparation. CX Codex +1 ★ 41,430repo stars adobe-illustrator-integrations The adobe-illustrator-integrations skill supports building and debugging Adobe Illustrator extensions, plugins, and MCP servers. It streamlines project automation via scripts and external control tools. CX Codex +1 ★ 41,430repo stars

Project sponsors

Companies that keep this analytics open