liveBook · Manning

Sparse vector

As explained in AI-Powered Search

A sparse vector is a vector representation in which most component values are zero or absent and only nonzero features are stored or processed.

A sparse vector representation stores only the meaningful, nonzero features instead of every possible dimension. In search, those features are often terms or attributes shared by a query and its candidate documents. section 3.1.3 section 7.4.3

Sparse representations make scoring efficient when a query touches only a small portion of the feature space. An inverted index stores term postings, allowing tokenized and normalized query terms to retrieve matching documents before BM25 scores and ranks them. section 3.1.3 section 13.2.1

A two-term query

For the query “apple juice,” retain only the dimensions for those two terms: query_vector = [1, 1]. If doc1_vector and doc2_vector are both [1, 1], cosine similarity gives each document a score of 1.0. The sparse calculation preserves their equal relative ranking even though its absolute score differs from a dense calculation. section 3.1.3

Sparse vectors support several search designs:

  • Use lexical keyword search with an inverted index whose dimensions represent indexed terms. section 7.4.3
  • Use weighted query expansion to add terms beyond the literal query, including semantic search built from sparse term vectors. section 7.4.3
  • Treat scores primarily as relative rankings: term matching can be fast and explainable but does not establish that a result is an objectively good semantic match. section 13.2.1

How AI-Powered Search covers it

How deep it goes
Defines representation, demonstrates cosine scoring, and explains inverted-index retrieval while deferring dense-vector techniques to separate treatment.
Examples
Uses an apple-juice cosine example, inverted-index retrieval, and SPLADE++ expansions for queries such as kimchi and Korean barbecue.
What it assumes
Assumes basic query and document matching, while introducing sparse-versus-dense representations and inverted-index mechanics.
What you can do after
Apply sparse vectors through an inverted index and BM25, or inspect weighted sparse query expansions for ranking.
How it connects
Connects sparse vectors with lexical search, inverted indexes, cosine similarity, BM25, query expansion, and dense vectors.

Also explained in

Compare how 3 books explain sparse vector →

Related concepts

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