Information Retrieval
Finds and ranks the documents that best match a query.
The idea
A search engine builds an inverted index from word to documents, then ranks matches. TF-IDF scores a word higher if it is frequent in the document but rare across the collection; BM25 refines this. Modern systems add vector search and learned re-rankers.
tf-idf(t, d) = tf(t, d) · log(N / df(t))
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- TF
- IDF
- TF-IDF
Document 1: "the cat sat on the mat". Which of its words best describe it? Common words like "the" appear everywhere, so they say little.
Try the slider to score a different document.
Step by step
- 1Build an inverted index of the documents.
- 2Turn the query into terms.
- 3Find the documents containing them.
- 4Score each by TF-IDF or BM25 and sort.
- 5Optionally re-rank the top results with a neural model.
Where it is used
Web and enterprise search, retrieval for chatbots (RAG).
Watch out for
Keyword matching misses synonyms; pure semantic matching can miss exact terms such as part numbers.