liveBook · Manning

Inverted index

As explained in AI Agents and Applications

An inverted index maps terms to the documents or locations in which they occur to support lexical search.

An inverted index supports lexical search by mapping each unique search token to the document chunks where it appears. During indexing, chunks are tokenized; during querying, the question is tokenized the same way and matched against those postings. Search tokenization is optimized for retrieval, not language modeling. section 10.1

A practical sparse-retrieval workflow is:

  • Tokenize each document chunk with a search-oriented tokenizer. section 10.1
  • Create postings that associate every unique token with the chunks containing it. section 10.1
  • Tokenize the query identically and retrieve chunks matching its terms. section 10.1
  • Rank matches with BM25 or TF–IDF, then combine them with semantic results when needed. section 10.1 section 10.8

Keyword-driven retrieval

A question containing a distinctive term retrieves chunks whose postings contain that term. Sparse search can also enforce Boolean conditions such as “must” and “must not,” making matches precise and explainable because results link directly to query terms. section 10.1

The structure favors exact lexical matches and transparent relevance explanations, while dense retrieval captures semantic similarity through embeddings. BM25 may require index support that many vector stores lack; LangChain’s BM25Retriever operates on in-memory document lists and does not scale to millions of documents. section 10.1 section 10.8

How AI Agents and Applications covers it

How deep it goes
Explains tokenization, postings, query matching, ranking, and scalability limits without detailing index internals.
Examples
Uses document-chunk term matching, Boolean must-or-must-not queries, and combined BM25 and vector-search results.
What it assumes
Assumes document chunks and tokenization, while distinguishing search tokenization from LLM tokenization.
What you can do after
Apply it via BM25Retriever for in-memory lexical search and combine its results with vector retrieval using RRF.
How it connects
Connects lexical retrieval with tokenization, BM25, TF–IDF, dense retrieval, vector stores, and reciprocal rank fusion.

Also explained in

Compare how 5 books explain inverted index →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents and Applications. The section links point to the parts of the book it draws on.