liveBook · Manning

Lexical search

As explained in Generative AI in Action

A sparse retriever is an information-retrieval system that matches queries and documents through sparse lexical representations and keyword-based statistics.

Lexical search matches queries to documents through keyword overlap. In retrieval-augmented generation (RAG), a retriever searches knowledge sources and supplies relevant information to a generator. section 7.4

Sparse retrieval commonly uses TF-IDF and inverted indexes:

  • It is fast and efficient for large-scale, keyword-dependent search when computational resources are limited. section 7.4
  • It can struggle with synonyms and nuanced phrasing. Dense retrieval can capture semantic relationships, but is more computationally intensive and requires substantial training data. section 7.4

Choose between sparse and dense retrieval based on query characteristics, domain specificity, available resources, and the need to understand nuanced language. section 7.4

How Generative AI in Action covers it

How deep it goes
Explains TF-IDF keyword matching with inverted indexes and contrasts sparse and dense retrieval by capability and cost.
Examples
Uses TF-IDF and keyword overlap to illustrate sparse retrieval.
What you can do after
Evaluate sparse versus dense retrieval against query needs, domain specificity, and available resources.
How it connects
Connects RAG retrieval with TF-IDF, inverted indexes, and dense retrieval.

Also explained in

Compare how 8 books explain lexical search →

Related concepts

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