The Maths You Actually NeedLesson 9 of 76

Module 1 · Vectors, and the space they live in

Sparse and dense, and the memory each costs

In this lesson

  • 9 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 9 of 9 in this chapter

This chapter’s goalTurn a real piece of data into a vector and defend the choices made, compute a length, a distance, a projection and a cosine by hand, and explain using the 1/√d rule why a similarity threshold that works in a 3-dimensional picture is meaningless in a 768-dimensional embedding space.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
Storing one million documentsDense, 1,536 numbers at 4bytes6.1Dense, 768 numbers at 4bytes3.1Sparse, 120 terms at 8bytes a term0.96Dense, 768 numbers at 1byte0.77GB for one million documentsSparse storage grows with document length, dense storage with the width of the model. Multiply everyfigure by ten for ten million documents, and the first two lines stop fitting on a laptop.
Sparse storage grows with document length, dense storage with the width of the model. Multiply every figure by ten for ten million documents, and the first two lines stop fitting on a laptop.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 9Free · no account needed
Lesson steps

Two ways to write down a document

Suppose your vocabulary has 50,000 words and you want to represent the sentence “the train was late”.

The sparse way. Make a vector with 50,000 slots, put a count in the slot for each word present, and zeroes everywhere else. Four non-zero entries out of 50,000. Stored naively that is 50,000 numbers; stored sensibly it is four (index, value) pairs, because the zeroes carry no information and need not exist.

The dense way. Run the sentence through an embedding model and get 768 numbers, almost none of them zero, none of them individually interpretable.

Neither is a better idea in general. They record different things. The sparse vector says exactly which words are here. The dense vector says what this is roughly about.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Sparse and dense, and the memory each costs’, in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/sparse-dense-and-one-hot (Accessed: 29 November 2026).