Skip to content

Add embedding-anisotropy-check skill 🤖🤖🤖 - #4182

Open
space-bacon wants to merge 4 commits into
github:mainfrom
space-bacon:add-embedding-anisotropy-check
Open

space-bacon wants to merge 4 commits into
github:mainfrom
space-bacon:add-embedding-anisotropy-check

Conversation

@space-bacon

Copy link
Copy Markdown

Adds embedding-anisotropy-check, a skill for checking a cosine similarity over embeddings or transformer hidden states before it is reported.

Most encoders put every vector near one shared direction, so raw cosine is rarely centred on zero: bge-small-en-v1.5 scores an unrelated SciFact half-abstract at 0.60 against 0.86 for the matching half. A model asked to compare embeddings usually reports the raw cosine, and a raw 0.9 or a gap of 0.01 then reads as a result.

The bundled script (numpy only) takes paired rows and reports each side's anisotropy, raw and centred cosine for matched pairs, a permuted floor from the same comparison, and how often the partner ranks first. SKILL.md says when to run it and how to read and report the output; its worked example is reproducible from the first 100 documents of mteb/scifact.

npm run skill:validate passes and npm start regenerated docs/README.skills.md.

I wrote this skill; it comes from the measurement rules we use in our own embedding work at Sunstone North.

Copilot AI balanced review requested due to automatic review settings September 29, 2026 16:31
@github-actions github-actions Bot added new-submission PR adds at least one new contribution skills PR touches skills labels Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🔒 PR Risk Scan Results

Scanned 3 changed file(s).

Severity Count
🔴 High 0
🟠 Medium 0
ℹ️ Info 2
Severity Rule File Line Match
ℹ️ skill-script-touched skills/embedding-anisotropy-check/scripts/anisotropy_check.py 1 skills/embedding-anisotropy-check/scripts/anisotropy_check.py
ℹ️ skill-script-touched skills/embedding-anisotropy-check/scripts/example_scifact_halves.py 1 skills/embedding-anisotropy-check/scripts/example_scifact_halves.py

This is an automated soft-gate report. Findings indicate review targets and do not block merge by themselves.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Contributor Reputation Check: MEDIUM risk

Check Risk
Profile MEDIUM
Credential audit NONE

Maintainers: please review this contributor before merging.
See the workflow run for full details.
Automated check powered by AGT.

@github-actions github-actions Bot added the needs-review:MEDIUM Contributor reputation check flagged MEDIUM risk label Sep 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The advertised cross-model comparison is mathematically unsafe, and the script has correctness, input-validation, provenance, and scalability issues.

Review effort: Balanced
Findings: 1 High severity · 5 Medium severity · 1 Low severity

Open (7)
What changed in this PR

Adds a skill for diagnosing embedding anisotropy before interpreting cosine similarity.

Changes:

  • Documents the analysis workflow and interpretation guidance.
  • Adds a NumPy CLI for cosine, floor, anisotropy, and retrieval metrics.
  • Registers the skill in generated documentation.
File Description
skills/​embedding-anisotropy-check/​SKILL.md Defines usage and interpretation guidance.
skills/​embedding-anisotropy-check/​scripts/​anisotropy_check.py Implements the analysis CLI.
docs/​README.skills.md Adds the skill to the catalog.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread skills/embedding-anisotropy-check/SKILL.md Outdated
Comment thread skills/embedding-anisotropy-check/scripts/anisotropy_check.py Outdated
Comment thread skills/embedding-anisotropy-check/scripts/anisotropy_check.py Outdated
Comment thread skills/embedding-anisotropy-check/scripts/anisotropy_check.py
Comment thread skills/embedding-anisotropy-check/scripts/anisotropy_check.py Outdated
Comment thread skills/embedding-anisotropy-check/scripts/anisotropy_check.py Outdated
Comment thread skills/embedding-anisotropy-check/SKILL.md Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Vally Lint Results

✅ All checks passed

Scope Checked
Skills 1
Agents 0
Total 1
Severity Count
❌ Errors 0
⚠️ Warnings 0
ℹ️ Advisories 0

Summary

Level Finding
ℹ️ ✅ embedding-anisotropy-check (2/2 checks passed)
ℹ️ ✓ [spec-compliance] All 1 skill(s) are spec-compliant.
ℹ️ ✓ spec-compliance: All spec checks passed.
ℹ️ ✓ [valid-refs] All file references across 1 skill(s) are valid.
ℹ️ ✓ valid-refs: All file references resolve to existing files within the skill directory.
ℹ️ 1 skill(s) linted, 1 passed
Full linter output
### Linting skills/embedding-anisotropy-check
✅ embedding-anisotropy-check (2/2 checks passed)
    ✓ [spec-compliance] All 1 skill(s) are spec-compliant.
        ✓ spec-compliance: All spec checks passed.
    ✓ [valid-refs] All file references across 1 skill(s) are valid.
        ✓ valid-refs: All file references resolve to existing files within the skill directory.

1 skill(s) linted, 1 passed

…on, bounded-memory ranking, shared derangements, per-side mean provenance, pinned example
@space-bacon space-bacon changed the title Add embedding-anisotropy-check skill Add embedding-anisotropy-check skill 🤖🤖🤖 Sep 29, 2026
Copilot AI balanced review requested due to automatic review settings September 29, 2026 18:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Centring can produce zero-length vectors and invalid JSON output, and several documentation claims need correction.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (7)
Previously missed (2)

In code that hasn't changed since last review

Low severity Describe cross-domain means as mis-centring

skills/​embedding-anisotropy-check/​SKILL.md:32

A mean from another domain does not necessarily under-correct: depending on its direction and magnitude, subtracting it can also over-correct or introduce a new direction. Describe this as mis-centring rather than asserting one failure mode.

This issue also appears on line 78 of the same file.

Low severity Clarify reporting rule for greatest bias

skills/​embedding-anisotropy-check/​SKILL.md:58

The phrase “and most where” is grammatically incomplete, which makes this reporting rule hard to parse. State that the bias is greatest when the gap is small relative to its noise.

Comment thread skills/embedding-anisotropy-check/scripts/anisotropy_check.py Outdated
Copilot AI balanced review requested due to automatic review settings September 29, 2026 18:53
…h, never emit NaN; cross-domain means mis-centre; state where the bias is greatest

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The interpretation overstates the anisotropy metric, and zero-variance floors produce misleading output.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Clarify that zero floor variance makes the standardized gap undefined

skills/​embedding-anisotropy-check/​scripts/​anisotropy_check.py:132

For valid inputs whose unrelated-pair cosines have zero variance, compare intentionally returns None for gap_over_floor_sd, but this sentence renders that as None floor sd apart. This occurs, for example, with paired orthogonal basis vectors, and leaves users with a misleading interpretation instead of explaining that the standardized gap is undefined.

Low severity Avoid overstating mean cosine as a general anisotropy measure

skills/​embedding-anisotropy-check/​SKILL.md:49

This guidance overstates what the reported statistic establishes. The implementation's mean off-diagonal cosine is algebraically (||sum(u)||² - n) / (n(n-1)), so it detects a shared mean direction but not anisotropy generally: for example, a balanced cloud containing only +v and -v has a value approaching zero while remaining confined to one axis and producing raw cosines of ±1. A near-zero value therefore does not make raw cosine directly interpretable; users still need the floor and its spread.

…misses; a floor without spread leaves the standardized gap undefined, including at rounding level
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🚦 Submission status: ⏳ Awaiting automation

Risk tier: merge-risk:high — Privileged execution, automation, or review-policy change
Required to merge: passing submission-gate checks plus 2 approvals from reviewers with write access, including a maintainer with admin or maintain permission.

Why this tier
  • skills/embedding-anisotropy-check/scripts/anisotropy_check.py is a high-risk path (automation, scripts, MCP config, hooks, or review policy)
  • skills/embedding-anisotropy-check/scripts/example_scifact_halves.py is a high-risk path (automation, scripts, MCP config, hooks, or review policy)

Automated checks

Check Status Details
Line endings ✅ Passed Passed · logs
Spelling ✅ Passed Passed · logs
Generated README consistency ✅ Passed Passed · logs
Skill validation ⏳ Pending Waiting for the check to start
Skill lint (vally) ✅ Passed Passed · logs
Risk scan ✅ Passed Passed · logs
Contributor reputation ✅ Passed Passed · logs
Duplicate resource scan ✅ Passed Passed · logs
PR quality signal ⏭️ Skipped Skipped by its workflow · logs
Contributor risk signal 🔧 Infrastructure failure The contributor check succeeded but its result artifact was missing, unreadable, or for another commit · logs

Action needed

  • 🔧 Contributor risk signal hit an automation problem that is not caused by your contribution. Comment /rerun-checks to retry; maintainers are notified if it keeps failing.

Review

  • Approvals: 0/2
  • Assigned reviewer: aaronpowell
  • Review target date: not set
  • Still needed: 2 more approval(s); an approval from a maintainer with admin or maintain permission
  • The core-maintainers pool is not staffed yet; an approver with admin or maintain permission is required instead.

Commands

Command Who What it does
/rerun-checks PR author, maintainers Re-runs failed or incomplete checks and re-evaluates this gate
/request-review PR author, maintainers Asks the review rotation to assign a reviewer (adds needs-reviewer)

Updated for 7ced8bc · This comment is maintained automatically — see submission gate docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-automation merge-risk:high needs-review:MEDIUM Contributor reputation check flagged MEDIUM risk new-submission PR adds at least one new contribution skills PR touches skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants