Skip to main content
For scenarios where ML model downloads aren’t acceptable, use the TF-IDF variant. It provides keyword-based search with zero external dependencies.

When to Use TF-IDF

Basic Usage

Key Differences from VectoriaDB

Important: Reindexing

TF-IDF requires reindexing after document changes to update IDF (Inverse Document Frequency) values:
Forgetting to call reindex() after changes will result in incorrect search results.

Configuration Options

Search Options

TF-IDF Algorithm

TF-IDF (Term Frequency-Inverse Document Frequency) works by:
  1. Term Frequency (TF): How often a term appears in a document
  2. Inverse Document Frequency (IDF): How rare a term is across all documents
  3. TF-IDF Score: TF x IDF - terms that are frequent in a document but rare overall get high scores
This means:
  • Common words like “the”, “is”, “a” get low scores (low IDF)
  • Unique terms specific to a document get high scores
  • The query is matched against TF-IDF vectors using cosine similarity

Example: Tool Discovery

Limitations

  1. No semantic understanding - “car” won’t match “automobile”
  2. Reindex requirement - Must call reindex() after changes
  3. Limited to keywords - Misspellings and synonyms aren’t handled
  4. Memory for large vocabularies - IDF tables grow with vocabulary size

Hybrid Approach

For best of both worlds, you can use TF-IDF as a pre-filter before semantic search:

Overview

Getting started

Search

Semantic search options

Persistence

Storage adapters