advanced-cosine

Compute weighted, sparse, BERT embedding, and sqrt cosine similarity.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/lofibrainwav/AFO_Kingdom --skill advanced-cosine
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: advanced-cosine
Source: https://github.com/lofibrainwav/AFO_Kingdom/tree/main/skills/advanced-cosine
Command: npx skills add https://github.com/lofibrainwav/AFO_Kingdom --skill advanced-cosine

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill exposes four advanced cosine similarity techniques to improve semantic matching and stability.

Core Features & Use Cases

  • Weighted Cosine: Reduces gaps by 30%.
  • Sparse Cosine: 5x speed improvement via sparse representations.
  • Embedding Cosine: 768D semantic matching with BERT embeddings.
  • Sqrt Cosine: Stability improvement of about 10%.

Quick Start

sims = advanced_cosine.compute(queries, documents, method="weighted")

Frequently Asked Questions about advanced-cosine

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I improve vector similarity matching for semantic search?

Vector similarity matching evaluates how closely related documents or queries are in high-dimensional space. Advanced cosine techniques—weighted, sparse, embedding-based, and sqrt variants—reduce evaluation gaps by up to 30%, accelerate sparse representations 5x faster, and stabilize results by ~10% across BERT embeddings and other 768D vectors.

Can I use cosine similarity with BERT embeddings?

Yes. Embedding Cosine handles 768-dimensional BERT embeddings natively for semantic matching and retrieval. It pairs with other techniques like weighted and sparse cosine to optimize both accuracy and speed on high-dimensional embedding spaces.

What's the difference between sparse and standard cosine similarity?

Sparse Cosine using scipy optimizes for high-dimensional vectors with many zero values, delivering 5x speedup over standard approaches. It's ideal when your embeddings are sparse and computational efficiency matters for clustering or large-scale retrieval.

How does weighted cosine improve similarity evaluation?

Weighted Cosine assigns importance scores to dimensions, reducing evaluation gaps by 30% compared to uniform weighting. It's useful when certain embedding dimensions carry more semantic value for your matching task.

Why use sqrt cosine over standard cosine similarity?

Sqrt Cosine applies square-root transformation to stabilize similarity scores, improving consistency by ~10%. Use it when you need more robust results across varying embedding magnitudes or noisy high-dimensional data.

Does this Skill work with sparse vector representations?

Yes. The Sparse Cosine technique uses scipy-based sparse representations to handle vectors efficiently. It's designed for workflows where embeddings contain significant zero values, delivering substantial speed gains for retrieval and clustering at scale.