algo-ecom-bm25

Solid

"Implement BM25 ranking function for e-commerce product search relevance scoring. Use this skill when the user needs to build a text-based product search engine, improve search result relevance, or replace basic TF-IDF with a more robust ranking function — even if they say 'product search ranking', 'search relevance', or 'BM25 implementation'.".

AI & Automation 22 stars 8 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
45
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# BM25 Ranking Function ## Overview BM25 (Best Matching 25) is an improved TF-IDF ranking function that adds term frequency saturation and document length normalization. Score = Σ IDF(t) × (TF(t,d) × (k₁+1)) / (TF(t,d) + k₁ × (1 - b + b × |d|/avgdl)). Standard parameters: k₁=1.2, b=0.75. The backbone of most text search engines (Elasticsearch, Solr). ## When to Use **Trigger conditions:** - Building product search with text-based relevance ranking - Replacing basic TF-IDF with better document length normalization - Tuning search relevance in Elasticsearch/Solr **When NOT to use:** - When semantic similarity matters more than keyword matching (use embeddings) - For single-field exact matching (simpler methods suffice) ## Algorithm ``` IRON LAW: BM25 Has Two Critical Parameters — k₁ and b k₁ controls term frequency saturation: higher k₁ = more weight to repeated terms. k₁=0 ignores TF entirely (boolean). b controls document length normalization: b=1 fully normalizes by length, b=0 ignores length. Default k₁=1.2, b=0.75 works for most cases but MUST be tuned for your specific corpus. ``` ### Phase 1: Input Validation + Tokenization Tokenize each document to lowercase word tokens. **Remove stop words** before counting — the bundled script drops a standard English stop list (`the, a, an, and, or, but, of, in, on, at, to, for, with, by, from, as, is, are, was, were, be, been, being`). Then build an inverted index: term → list of (document, term frequency). Compute: document...

Details

Author
charlieviettq
Repository
charlieviettq/awesome-agent-skill
Created
2 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

algo-ecom-ranking

"Design multi-objective e-commerce product ranking combining relevance, conversion, and business metrics. Use this skill when the user needs to build a product ranking system beyond text relevance, balance relevance with commercial objectives, or implement learning-to-rank — even if they say 'product sorting', 'search result ranking', or 'how to rank products'.".

22 Updated 1 weeks ago
charlieviettq
Data & Documents Solid

bm25

Ranked content search over any text corpus using BM25 (via xhluca/bm25s). Corpus-agnostic: works on cloned repos, project knowledge stores, uploaded files/archives, and any local directory. Stateless — builds an in-memory index each invocation, no cache, no persistence. Use when you need ranked multi-word content search beyond grep, or when picking the "most relevant files for these terms" across a corpus. Triggers on "rank these documents", "search this corpus", "find content about X", "which files are most about Y", or multi-word concept queries against a known body of text.

134 Updated yesterday
oaustegard
AI & Automation Solid

algo-ecom-search

"Optimize e-commerce search relevance across the full pipeline from query understanding to result presentation. Use this skill when the user needs to improve search quality, implement query processing features, or diagnose search relevance issues — even if they say 'search results are bad', 'improve product search', or 'search relevance optimization'.".

22 Updated 1 weeks ago
charlieviettq