BF50 Black Friday · 50% off all plans
from $5/mo · Auto-applied ---:--:-- Claim 50% off →
Skip to content

Search Seonio

Type a keyword, domain, or paste a URL

Start free with $1 to see full results. Powered by Seonio
Data Science

Vector space model: How documents become vectors

The vector space model treats documents and queries as lists of term weights, usually TF-IDF, and ranks documents by the angle between their vectors.

Monthly searches · vector space model
1.0k
Keyword research data
vector space model
Vector space model: How documents become vectors
Click the image to view it full size

The vector space model is a classic way for a search system to compare text. It represents every document, and every query, as a list of numbers: one number per word in the collection's vocabulary, showing how important that word is in that text. Two texts that use the same important words in similar proportions get similar lists, and the system ranks documents by how similar their list is to the query's.

Gerard Salton's SMART retrieval system at Cornell built search around this idea, and the 1975 paper "A vector space model for automatic indexing" by Salton, Wong and Yang is the usual reference for it.

How the model works

  1. Build the vocabulary. Every distinct term in the collection becomes one dimension. Very common words (stop words) are often dropped, and words may be reduced to their stem (stemming).
  2. Weight each term. The simplest weight is a count of how often the term appears (term frequency). The usual choice is TF-IDF, which also lowers the weight of terms that appear in many documents. That second part, inverse document frequency, comes from Karen Spärck Jones's 1972 paper on term specificity.
  3. Compare with cosine similarity. The system measures the angle between the query vector and each document vector. A cosine of 1 means the same direction (the same mix of terms); 0 means no terms in common.
  4. Rank. Documents are sorted by their cosine score.

Cosine looks at direction, not length. A long article that uses the query terms in the same proportion as a short one scores the same, so longer documents don't win just by having more words.

A small worked example

Take the query "running shoes" and two documents, after dropping the stop word "for":

  • Document A: "running shoes for trail running"
  • Document B: "shoes"

With raw counts over the vocabulary (running, shoes, trail), the vectors are:

running shoes trail
Query 1 1 0
Document A 2 1 1
Document B 0 1 0

Document A's cosine with the query is 3 ÷ (√2 × √6) ≈ 0.87. Document B's is 1 ÷ √2 ≈ 0.71. A ranks first because it covers both query terms, even though it also contains a word the query lacks. B still gets a score for its partial match.

Before the vector space model, retrieval systems mostly used Boolean search: a document either matched the query's AND, OR and NOT conditions or it didn't.

Boolean model Vector space model
Match Yes or no A score between 0 and 1
Partial matches Excluded Ranked lower
Term weights None Counts or TF-IDF
Result An unordered set A ranked list

Where the model falls short

  • It ignores word order. "Dog bites man" and "man bites dog" get the same vector. That's why it's called a bag-of-words model.
  • It doesn't know synonyms. "Car" and "automobile" are separate dimensions, so a document about automobiles scores zero for "car".
  • It doesn't know senses. "Apple" the fruit and "Apple" the company share one dimension.

Later methods tackled these gaps. Latent semantic analysis compresses the term dimensions into fewer "concept" dimensions. Today's embeddings go further: a neural model produces short, dense vectors in which related words and passages sit close together, which is the basis of vector search. The geometry is the same idea, points compared by angle, with learned dimensions instead of one per word.

What it means for SEO today

Modern search engines don't rank pages with a plain vector space model; they combine many systems. The model is still worth knowing for two reasons. It's the clearest explanation of why matching a query's terms, and the terms that usually appear with them, makes a page look relevant to a text-based system. And it's the idea behind TF-IDF content tools, so it tells you their limits: they compare word statistics, and a page can score well on them and still fail to answer the reader's question.

SEO wiki

Related terms

More definitions from the same corner of SEO and digital marketing.

Seonio

Put it to work on your own site

Keyword research, traffic, backlinks and clustering in one place. Start with a free $1 to test, no card required.