Skip to content
Back to skills

Rank Bm25

ASecurity

"Guides tokenized lexical document retrieval with the rank_bm25

  • 247 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 9, 2026
businesspythongobashapi

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 7 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill rank-bm25 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rank Bm25?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rank Bm25
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-rank-bm25/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-rank-bm25)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rank-bm25
description: "Guides tokenized lexical document retrieval with the rank_bm25
  Python package, including BM25Okapi, BM25L, BM25Plus, full-corpus scoring,
  top-n retrieval, batch scoring, and input troubleshooting."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# rank_bm25

Use this skill when a task asks for the `rank_bm25` package, Okapi BM25,
BM25L, BM25+, sparse lexical ranking, or a small in-memory search index over
pre-tokenized documents. It teaches the package API; it is not a production
search-service design and it does not cover the commented-out BM25Adpt/BM25T
classes.

## Route the task

- **Install or import**: install the public `rank_bm25` distribution, ensure
  NumPy is available, and run the import check below.
- **Build and rank an index**: read [workflows.md](references/workflows.md)
  for a complete tokenization, indexing, scoring, and top-n recipe.
- **Choose an algorithm or use advanced methods**: read
  [api-reference.md](references/api-reference.md) for verified signatures,
  defaults, return types, parameter meaning, and batch-score semantics.
- **Diagnose a failed ranking workflow**: read
  [troubleshooting.md](references/troubleshooting.md), then use the bundled
  [smoke_rank_bm25.py](scripts/smoke_rank_bm25.py) helper for a deterministic
  tiny-fixture check.
- **Check whether this knowledge matches a checkout**: read
  [repo-provenance.md](references/repo-provenance.md) before deciding whether
  the skill needs refreshing.

## Minimal setup and import check

```bash
python -m pip install rank_bm25
python -c "from rank_bm25 import BM25Okapi, BM25L, BM25Plus; print('rank_bm25 ready')"
```

The package has no console CLI and its runtime dependency is NumPy. CPU
execution is the supported baseline for the covered in-memory workflows.

## Core operating contract

1. Represent every document as a sequence of string tokens, for example
   `document.split()`; pass a list of those token sequences as `corpus`.
2. Apply the same lowercasing, normalization, stopword handling, and
   tokenization policy to documents and queries yourself. The package does no
   text preprocessing.
3. Choose `BM25Okapi`, `BM25L`, or `BM25Plus`, construct it once for a corpus,
   and reuse the index for compatible tokenized queries.
4. Use `get_scores(query)` for one score per indexed document,
   `get_top_n(query, documents, n=5)` when you need the original documents,
   or `get_batch_scores(query, doc_ids)` for a selected index subset.
5. Keep the original `documents` list in exactly the same order as the corpus;
   `get_top_n` checks the lengths and maps score indices back into that list.
6. Validate one known query and expected top document before scaling the corpus.
   Run `python scripts/smoke_rank_bm25.py` from this skill directory or any
   current working directory after installing the package.

The package is intentionally lightweight and in-memory. For full API details,
recipes, and predictable failure recovery, follow the linked references rather
than reopening the source repository.

Files in this skill

  • SKILL.md3 KB
  • references/api-reference.md4.6 KB
  • references/repo-provenance.md1.7 KB
  • references/repo-routing-metadata.json333 B
  • references/troubleshooting.md5.3 KB
  • references/workflows.md3.2 KB
  • scripts/smoke_rank_bm25.py2.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.