Overview at a glance
TF-IDF and BM25 platform specifications | Application type | Browser-based information retrieval and lexical relevance scoring studio |
| Scoring algorithms | Log-augmented TF-IDF and Okapi BM25 (Robertson et al., probabilistic relevance) |
| Background frequencies | Built-in table of about 240 common and information-retrieval words with approximate Zipf frequencies; other words use a length-based estimate |
| Supported inputs | Public webpage URLs, raw pasted HTML markup and plain text copy |
| Term saturation (k₁) | Configurable from 0.1 to 3.0 (default 1.5) |
| Length normalisation (b) | Configurable from 0.0 to 1.0 (default 0.75) |
| Reference document length | Configurable from 50 to 5,000 words (default 500) |
| Morphology engine | Light English stemmer (Porter2 step 1 plus final-e removal): groups plurals, -ed, -ing and -y forms |
| Query relevance mode | Per-term BM25 attribution and query coverage against the BM25 ceiling |
| Prose metrics | Flesch Reading Ease, average sentence length and vocabulary variety (moving-average type-token ratio, 100-word window) |
| Export formats | CSV term weighting tables, JSON metrics, Markdown audit report and print PDF |
| Licence | MIT |
What the studio does
Information retrieval systems must balance two competing challenges: rewarding content that covers relevant terms in depth, whilst preventing manipulative keyword stuffing and penalising verbose pages that mention words solely due to document length.
1. Logarithmic TF-IDF scoring
The engine dampens term frequency logarithmically as 1 + log₁₀(tf) and multiplies it by an IDF estimated from how common the word is in general English.
2. Okapi BM25 probabilistic relevance
Unlike TF-IDF, BM25 puts an upper bound on what term frequency can contribute. Repeating a keyword beyond its natural occurrence yields little extra score, which is how Lucene-based search engines behave.
3. Document length normalisation
By comparing your document length with a reference length (default 500 words) using parameter b, BM25 lets concise, focused pages compete fairly against lengthy articles.
4. Explore the maths
After scoring, the k₁, b and avgdl sliders, the stop-word and stemming options and the query all update the results instantly, without refetching the page. Click any term in the keyword table, or its dot on the saturation curve, to see its TF-IDF and BM25 calculations with this document's numbers plugged in, plus how much one more mention would add.
5. Phrases and competitor comparison
Top Phrases lists repeated two- and three-word phrases. Putting words in quotes in the query checks that exact phrase, and a multi-word query without quotes is also checked as a phrase. Add competitor pages (URLs or pasted text) to rank all the pages for the query using IDF counted across them, and to see the words and phrases most competitors use that your page uses less than half as often. Tick "Score my page with these pages' IDF and average length" to use those statistics everywhere.
6. Query coverage
BM25 scores a document against a query. Each query term can contribute at most IDF × (k₁ + 1), a ceiling it approaches as repetitions grow. Query coverage is the document's BM25 score as a percentage of the sum of those ceilings, so it is comparable across queries of different lengths.
Mathematical formulations
Term Frequency (TF)
TF_log(t) = 1 + log₁₀(count) (if count > 0, else 0)
Inverse Document Frequency (IDF), estimated
IDF_tfidf(t) = max(0.15, 7.8 - Zipf(t))
Zipf(t) is the word's log₁₀ frequency per billion words. There is no real document collection to count against, so IDF is estimated from general word frequency.
BM25 IDF, from an estimated document frequency
n(t) = N × min(0.999, 10^(Zipf(t) - 7.5)), N = 100,000
IDF_bm25(t) = ln(1 + (N - n + 0.5) / (n + 0.5))
Okapi BM25 scoring formula
BM25(t, D) = IDF(t) × [ tf × (k₁ + 1) ] / [ tf + k₁ × (1 - b + b × (|D| / avgdl)) ]
IDF from compared pages
N = your page + competitors, df(t) = pages containing t, avgdl = their mean length
IDF_bm25(t) = ln(1 + (N - df + 0.5) / (df + 0.5)) (Lucene)
IDF_tfidf(t) = ln((1 + N) / (1 + df)) + 1 (smoothed, as in scikit-learn)
Query coverage
Coverage(Q, D) = Σ BM25(t, D) / Σ IDF(t) × (k₁ + 1) for each distinct t in Q
BM25 parameter tuning guide
| Parameter | Typical Range | Impact on Relevance |
| k₁ = 0.5 – 1.0 | Rapid saturation | Keywords hit their maximum score after very few mentions. Ideal for short product descriptions. |
| k₁ = 1.2 – 1.6 (Default) | Standard web search | Balances natural term occurrence against repetition. Matches Elasticsearch and Lucene defaults. |
| k₁ = 1.8 – 2.5 | Slow saturation | Allows repeated keywords to accumulate higher scores. Suitable for lengthy technical or legal literature. |
| b = 0.0 | No length normalisation | Document length is ignored. Longer documents receive an inherent advantage from higher word volume. |
| b = 0.75 (Default) | Standard normalisation | Long documents are scaled down proportionately so concise pages with concentrated relevance can compete. |
| b = 1.0 | Full length normalisation | Aggressive penalisation for verbosity. Every additional word dilutes the relevance of existing keywords. |
Limitations
IDF values are estimates from a built-in frequency table, not counts from a real collection of documents. Words outside the table get an IDF based only on their length, so treat absolute numbers as indicative and focus on comparisons within one document.
BM25 scores query terms as individual words. Exact phrases are counted and reported, but they do not change the BM25 score, and word proximity is not scored. Competitor comparisons with only a few pages give coarse IDF values; five or more pages give steadier results.
Text extraction picks the main content area (MediaWiki article containers, single <article>, <main>, or article content blocks) and removes navigation, sidebars, language menus, footers, forms, hidden elements, cookie banners, comments, Wikipedia maintenance boxes and trailing References / External links sections. Pages that build their content with JavaScript cannot be read because the tool does not run the page's scripts; the Page & Extraction card warns when that seems to have happened. Always check the Extracted Document Text panel, and use Edit and rescore to remove anything that slipped through.
Privacy
All scoring runs in your browser. Pasted text never leaves your device.
Your settings, theme and the last 12 analyses (URLs, queries, pasted texts up to 60,000 characters and comparison pages) are saved in this browser's local storage so you can return to them. They are never sent anywhere. Use Clear history under Recent analyses to remove them.
Browsers block pages from reading other sites directly, so fetching a URL goes through a proxy. The tool tries a same-origin proxy first (if the site provides one), then the public Wikipedia API for Wikipedia pages, then the public proxies allorigins.win and codetabs.com. Those third-party services see the URL you analyse. Untick Allow public proxies under the URL box to stop the tool from using them. The Page & Extraction card and the status in the bottom-left of the input panel show which route was used. Each route gives up after 10 seconds. To avoid proxies entirely, paste the page's text or HTML instead.
Glossary of terms
- Term Frequency (TF)
- A measure of how frequently a term appears within a document. Standard formulations apply logarithmic scaling, such as 1 + log10(count), to dampen the influence of high word counts.
- Inverse Document Frequency (IDF)
- A logarithmic measure of how rare a word is across a reference language corpus or document collection. Common function words receive low IDF values whilst distinctive topical terms receive high values.
- TF-IDF
- Term Frequency–Inverse Document Frequency. A foundational vector space model metric multiplying term frequency by rarity, establishing a baseline keyword weight.
- Okapi BM25
- A non-linear probabilistic ranking function developed by Stephen Robertson and Karen Spärck Jones. BM25 improves on TF-IDF by capping term frequency saturation and normalising for document length.
- k₁ Parameter (Term Saturation)
- A tuning parameter controlling how rapidly term frequency hits an asymptotic ceiling. A value of 1.5 means repeating a term five times yields only modest gains over three occurrences.
- b Parameter (Length Normalisation)
- A tuning parameter scaling document length penalisation. At b = 0.75, longer documents are scaled down to prevent unfair advantages from sheer word volume. At b = 0, length scaling is disabled.
- Zipf Frequency
- A base-10 logarithmic scale measuring occurrences per billion words. Common words score above 7.0, whereas specialised vocabulary scores between 1.5 and 4.0.
- Query Coverage
- The document BM25 score for the query expressed as a percentage of the theoretical maximum ceiling the query terms could achieve in this document.
- Stemming
- Algorithmic stripping of morphological suffixes (using Porter2 step 1 plus step 5a) to consolidate singulars, plurals and verb conjugations into a canonical root form.
- Term Gaps
- Words and two-word phrases used by the majority of compared competitor pages that your document uses less than half as frequently per 1,000 words.
Frequently asked questions
What is the fundamental difference between TF-IDF and Okapi BM25? +
TF-IDF scores grow monotonically as a word is repeated, which rewards long, repetitive pages. Okapi BM25 introduces an asymptotic saturation curve (controlled by parameter k₁) where term gains diminish, alongside a document length normalisation penalty (controlled by parameter b) that prevents long documents from dominating results simply due to verbosity.
Why do modern search engines prefer BM25 over TF-IDF? +
Search retrieval engines such as Elasticsearch, OpenSearch, Lucene and modern hybrid neural rankers use BM25 as their primary sparse lexical scoring model because it resists keyword stuffing and fairly balances concise answers against long articles.
How should I tune the k₁ parameter? +
The k₁ parameter dictates the steepness of term frequency saturation. A default value between 1.2 and 1.6 works well for general web search. Lower values (e.g. 0.8) reach saturation quickly, suitable for short query matching. Higher values (e.g. 2.0) reward repeated terms more generously, suitable for technical manuals or legal contracts where repeated terminology is essential.
What effect does the b parameter have on long articles? +
Parameter b scales document length normalisation from 0.0 (no length adjustment) to 1.0 (strict length penalisation). At the default of 0.75, pages longer than the reference document length are penalised proportionately, requiring terms to appear consistently throughout the copy to score highly.
How does competitor comparison and corpus IDF work? +
You can paste or fetch up to 10 competitor URLs. The studio calculates true document frequency across the collection, ranks each page by BM25 for the target query, identifies keyword gaps and lets you score your primary page using the empirical collection statistics.
Is my analysed content sent to any external server? +
No. All tokenisation, stemming, frequency counts and relevance calculations execute strictly client-side inside your web browser. Pasted text never leaves your device.
Can I export the calculated term weights? +
Yes. You can export complete term weighting tables as CSV or JSON files, copy a formatted Markdown report to your clipboard or print a PDF summary.
About the author
The TF-IDF & BM25 Calculator was engineered by Mike Higgins, a technical SEO and web operations manager with over a decade of experience accelerating digital growth, auditing search architectures and building performance-driven web tools.
Explore more developer and SEO tools on the Tools index or visit the About page to learn more.