AlgoViz

TF-IDF and term rarity

medium 4 min

Term frequency describes a word inside one document.

Video lesson · Chapter 1 of 5

A rare mark in the rail archive

0:00 / 3:14

Why does a rare word outweigh a common one?

1:13Reel

Theory

Read or listen first. About 1 min.

What it is

A word in almost every document offers little help in choosing the right one. Inverse document frequency measures how much a term narrows the field across a corpus.

How much does a term distinguish a document?

Documents containing the term500 of 1,000IDF weightln(1000 / 500) ≈ 0.69
In a corpus of 1,000 documents, a term in 500 has unsmoothed IDF ln(1000 / 500) ≈ 0.69.

Why it exists

Two documents can repeat a query word equally often. Weighting the rarer query term more heavily can bring the more specific match toward the top.

Words to know

Document frequency
The number of documents containing a term, counting each document at most once.

How it works

Step through the idea, or press Play.

Step 1 of 3

Count documents. One word appears in 10 of 1,000 documents.

Understand it

Worked example

TF-IDF and term rarity in practice

In 1,000 documents a word found in ten has unsmoothed IDF ln(100), about 4.61. A word in 500 has ln(2), about 0.69. At equal frequency the rarer word contributes more in this variant.

Related case

Why did this document rank first?

An internal engineering search returns a long glossary above a precise two-paragraph runbook. Another user cannot find a document they just published.

The missing reset guide
Finding the reset guideRunbookjust writtenIndexold viewResultsno guideSearch has an older index view

Check refresh, terms and access filters.

Sources