Agent skill

Algo Ecom Bm25

by asgard-ai-platform in asgard-ai-platform/skills

Implement BM25 ranking function for e-commerce product search relevance scoring.

MITAuto-check passedSales & Support

Install Algo Ecom Bm25

skills CLI
$ npx skills add asgard-ai-platform/skills --skill algo-ecom-bm25 -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install asgard-ai-platform/skills algo-ecom-bm25 --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/asgard-ai-platform/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/algo-ecom-bm25 .claude/skills/algo-ecom-bm25 && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
algo-ecom-bm25
GitHub stars
242
Token cost
~1.4k tokens
SKILL.md length
619 words
Files
5 (incl. scripts, references)
Skills in repo
207
Repo updated
First seen
Licence
MIT

At a glance

Implement BM25 ranking function for e-commerce product search relevance scoring.

  • Works in 4 steps: Input Validation + Tokenization → Core Algorithm → Verification → …
  • The user needs to build a text-based product search engine
  • SKILL.md covers Overview, When to Use, Algorithm and Output Format, plus 4 more sections
  • Runs Python scripts from its folder; calls python

What it does

Algo Ecom Bm25 is an agent skill from asgard-ai-platform/skills. 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'.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including scripts and reference files (for example `examples/sample_input.json`, `references/bm25f.md` and `references/parameter-tuning.md`).

It sits in Sales & Support, covering Search implementation and E-commerce operations. The repository describes itself as: 301 open-source coding agent skills across 22 domains — methodology, judgment & gotchas packaged as Claude Agent Skills for the Asgard AI Platform. The licence is MIT.

When your agent uses it

  • The user needs to build a text-based product search engine
  • Improve search result relevance
  • Replace basic TF-IDF with a more robust ranking function — even if they say product search ranking
  • Search relevance

Example prompts

  • “product search ranking”
  • “search relevance”
  • “BM25 implementation”
  • “/algo-ecom-bm25”

Requirements

  • Python 3

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Input Validation + Tokenization
  2. Core Algorithm
  3. Verification
  4. Output

What it can do on your machine

Read from SKILL.md and the folder at commit 4e7f4f8. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Algo Ecom Bm25 loads about 1.4k tokens when it runs, and up to ~7.2k if it reads all its reference files. Until then it costs about 90 tokens; SKILL.md has 619 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~90
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from asgard-ai-platform/skills at commit 4e7f4f8, republished under its MIT licence (© asgard-ai-platform). 619 words, ~1,432 tokens.

Download SKILL.mdSave it as .claude/skills/algo-ecom-bm25/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
algo-ecom-bm25
description
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'.
metadata.category
WP-43 電商搜尋演算法
metadata.tags
ecommerce, bm25, search, information-retrieval

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 lengths (post stop-word removal), average document length, document frequency per term.

⚠️ Stop-word removal affects |d| and avgdl: because stop words are dropped before length is measured, hand-computing BM25 without removing them will give the wrong length normalization and scores will be off by 3–5%. If you're reproducing BM25 by hand to compare against the script, apply the same stop list first — or just run the script.

Gate: Index built, statistics computed, corpus non-empty.

Phase 2: Core Algorithm

For query Q with terms t₁...tₙ against document d:

  1. For each query term tᵢ: compute IDF(tᵢ) = log((N - DF(tᵢ) + 0.5) / (DF(tᵢ) + 0.5) + 1)
  2. Compute TF component: (TF(tᵢ,d) × (k₁+1)) / (TF(tᵢ,d) + k₁ × (1 - b + b × |d|/avgdl))
  3. Score(d, Q) = Σᵢ IDF(tᵢ) × TF_component(tᵢ, d)
  4. Rank documents by score descending

⚠️ IDF variant lock-in: BM25 has several IDF formulations in the wild (Robertson-Sparck Jones, classic Okapi, Lucene's smoothed +1, BM25+, BM25L). This skill — and the bundled script — uses the Lucene-style smoothed variant shown above (log((N - df + 0.5) / (df + 0.5) + 1)), which never returns negative IDF for very common terms. If you compare scores against another engine (Elasticsearch, Solr, Whoosh), they may differ by ~3–5% even on identical inputs. Do not "correct" the script unless you intend to change the variant globally.

Show full SKILL.md (258 more words)Show less
Phase 3: Verification

Spot-check: query "red shoes" should rank documents containing both "red" and "shoes" higher than documents with only one term. Shorter product titles with both terms should rank above long descriptions with sparse mentions. Gate: Relevance spot-check passes on 10+ test queries.

Phase 4: Output

Return ranked results with scores.

Output Format

json
{
  "results": [{"doc_id": "SKU-123", "score": 12.5, "title": "Red Running Shoes"}],
  "metadata": {"query": "red shoes", "hits": 85, "k1": 1.2, "b": 0.75, "avg_doc_length": 45}
}

Examples

Sample I/O

Input: Query "wireless earbuds", corpus of 1000 product listings Expected: Products with "wireless earbuds" in title rank highest; "wireless headphones" ranks lower (no "earbuds" term).

Edge Cases
InputExpectedWhy
Single-word queryIDF-dominated rankingOnly one term's IDF differentiates
Very common term ("the")Near-zero IDF, low impactIDF suppresses common terms
Document with 100 repetitionsSaturated TF, not 100x scorek₁ caps the benefit of repetition

Gotchas

  • Multi-field scoring: E-commerce products have title, description, brand, category. Weight fields differently: title match > description match. Use field-boosted BM25.
  • Synonyms and stemming: BM25 is keyword-exact. "earphones" won't match "earbuds." Add synonym expansion and stemming in the query pipeline.
  • Parameter tuning: Default k₁=1.2, b=0.75 is reasonable but not optimal. Tune on relevance judgments specific to your catalog.
  • Numeric attributes: BM25 doesn't handle numeric filtering (price range, ratings). Use it for text relevance, then combine with numeric filters.
  • Zero-result queries: When BM25 returns nothing, fall back to fuzzy matching or semantic search rather than showing empty results.

Scripts

ScriptDescriptionUsage
scripts/bm25.pyScore documents against a query using BM25 ranking functionpython scripts/bm25.py --help

Run python scripts/bm25.py --verify to execute built-in sanity tests.

References

  • For BM25F multi-field extension, see references/bm25f.md
  • For parameter tuning methodology, see references/parameter-tuning.md

© asgard-ai-platform, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in algo-ecom-bm25 of asgard-ai-platform/skills.

  • SKILL.md
  • examples/sample_input.json
  • references/bm25f.md
  • references/parameter-tuning.md
  • scripts/bm25.py

Open the folder on GitHubat commit 4e7f4f8

Compare with similar skills

Algo Ecom Bm25 next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Algo Ecom Bm25 compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Algo Ecom Bm25 this skillasgard-ai-platform/skills242—~1.4kAutomated safety check: PassMIT
Paypal Integrationwshobson/agents40k11 repos~1kAutomated safety check: PassMIT
EtsyAnil-matcha/awesome-muse-connectors1.3k—~660Automated safety check: PassMIT
Agentkeychainbase-labs/Agentkey656—~2.3kAutomated safety check: PassMIT
Amazon Buy Box Monitorbrowser-act/skills6.1k1 repos~1.6kAutomated safety check: PassMIT
Tourmind Bookingtourmind-com/Tourmind-Booking-Skills1.8k—~13kAutomated safety check: PassMIT

Similar skills

  • Paypal Integration

    wshobson/agents

    Integrate PayPal payment processing with support for express checkout, subscriptions, and refund management.

    40k GitHub starsUsed in 11 repos~1k tokens
    Sales & SupportAuto-check passed
  • Etsy

    Anil-matcha/awesome-muse-connectors

    Read Etsy shop data: receipts, listings, transactions, payment ledger; create listings.

    1.3k GitHub stars~660 tokensUpdated 5 days ago
    Sales & SupportAuto-check passed
  • Agentkey

    chainbase-labs/Agentkey

    PROACTIVELY use whenever the user needs data outside your training set or requires a live network call — web search, URL scraping, news, social media (any platform), market prices…

    656 GitHub stars~2.3k tokensUpdated 1 mo ago
    Sales & SupportAuto-check passed
  • Amazon Buy Box Monitor

    browser-act/skills

    Pulls Amazon product details, competing seller prices and seller ratings for a given ASIN through the BrowserAct API, without browser automation.

    6.1k GitHub starsUsed in 1 repo~1.6k tokens
    Sales & SupportAuto-check passed
  • Tourmind Booking

    tourmind-com/Tourmind-Booking-Skills

    MUST USE for any hotel or accommodation intent in any language, including hotel search, hotel recommendations, nearby accommodation, hostels, guesthouses, resorts, where-to-stay questions, room…

    1.8k GitHub stars~13k tokensUpdated yesterday
    Sales & SupportAuto-check passed
  • Ecommerce Image Suite

    wzj177/ecommerce-image-suite

    电商套图生成助手。用户明确提出需要生成电商套图、商品主图、卖点图、场景图、模特图等图片内容时触发. An agent skill from wzj177/ecommerce-image-suite.

    449 GitHub stars~10k tokensUpdated 1 mo ago
    Sales & SupportAuto-check passed

More from asgard-ai-platform/skills

All 207 skills in this repo
  • Algo Mfg Cpk

    asgard-ai-platform/skills

    Calculate Cpk process capability index to assess whether a process meets specification requirements.

    242 GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Algo Price Elasticity

    asgard-ai-platform/skills

    Calculate price elasticity of demand to quantify how price changes affect sales volume.

    242 GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Algo Rank Bayesian

    asgard-ai-platform/skills

    Apply Bayesian averaging to rank items by combining observed ratings with prior expectations.

    242 GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Algo Rank Elo

    asgard-ai-platform/skills

    Implement Elo rating system to rank items or players from pairwise comparison outcomes.

    242 GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Algo Rank Wilson

    asgard-ai-platform/skills

    Calculate Wilson Score confidence intervals for ranking items by positive proportion with sample size correction.

    242 GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Algo Risk Altman Z

    asgard-ai-platform/skills

    Calculate Altman Z-Score to predict corporate bankruptcy probability from financial ratios.

    242 GitHub stars~1.5k tokensUpdated 4 mo ago
    Auto-check passed

Questions about Algo Ecom Bm25

What does Algo Ecom Bm25 do?

Implement BM25 ranking function for e-commerce product search relevance scoring. Algo Ecom Bm25 is an agent skill from asgard-ai-platform/skills. Implement BM25 ranking function for e-commerce product search relevance scoring.

When should I use Algo Ecom Bm25?

Algo Ecom Bm25 fits situations like: the user needs to build a text-based product search engine; improve search result relevance; replace basic TF-IDF with a more robust ranking function — even if they say product search ranking; search relevance.

How do I install Algo Ecom Bm25 in Claude Code?

Run `npx skills add asgard-ai-platform/skills --skill algo-ecom-bm25 -a claude-code`. Or copy the skill folder (algo-ecom-bm25 in asgard-ai-platform/skills) into .claude/skills/algo-ecom-bm25 in your project. Claude Code loads it when a task matches its description.

How do I install Algo Ecom Bm25 in Codex?

Run `npx skills add asgard-ai-platform/skills --skill algo-ecom-bm25 -a codex`. Or copy the skill folder (algo-ecom-bm25 in asgard-ai-platform/skills) into .agents/skills/algo-ecom-bm25 in your project. Codex loads it when a task matches its description.

Can I use Algo Ecom Bm25 in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add asgard-ai-platform/skills --skill algo-ecom-bm25 -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/algo-ecom-bm25, .gemini/skills/algo-ecom-bm25, .github/skills/algo-ecom-bm25 and .opencode/skills/algo-ecom-bm25 in your project.

What does Algo Ecom Bm25 need to run?

Going by SKILL.md and its folder, Algo Ecom Bm25 needs Python for the scripts in its folder and the command-line tools its instructions call (python). Our summary lists: Python 3.

Does Algo Ecom Bm25 access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Algo Ecom Bm25 safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Algo Ecom Bm25 use?

Algo Ecom Bm25 is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Algo Ecom Bm25 use?

About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 5.8k tokens, read only when the agent opens those files.

What are the alternatives to Algo Ecom Bm25?

Skills that share tags, products or a category with Algo Ecom Bm25: Paypal Integration (wshobson/agents, 40k stars), Etsy (Anil-matcha/awesome-muse-connectors, 1.3k stars), Agentkey (chainbase-labs/Agentkey, 656 stars) and Amazon Buy Box Monitor (browser-act/skills, 6.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Algo Ecom Bm25?

asgard-ai-platform (a GitHub organization) maintains it in asgard-ai-platform/skills, which has 242 GitHub stars. The repository holds 207 skills in this directory. The repository was last updated on June 6, 2026.

Source: asgard-ai-platform/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.