What brute force costs, counted
The 1 billion multiply-adds per second is an assumption to make the table readable. Your CPU, the library (NumPy, SIMD) and the vector size change it a lot. The count itself is exact.
A list of vectors in a program searches fine until the program restarts, two people write at once, a question needs a filter, or there are millions of vectors. A vector database is the set of features that fix those, and you may not need one yet.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write work(n, dims) that returns the multiply-adds of one exact search, and print it for 50,000 vectors of 768 numbers and for 2,000,000 vectors of 384 numbers.
Write fits_in_ms(n, dims, budget_ms, ops_per_second) that says whether one exact search fits in the time budget. Test it with 1,000,000 vectors of 384 numbers, a budget of 50 ms and 2 billion operations per second.
Explain it without notes
List four problems that appear when you keep vectors only in a program's memory.
What does exact search cost, and how do you compute it?
What does a vector database add compared with a list?
When would you not add a vector database?
Expected output
searched 1000 vectors of 8 numbers
multiply-adds counted: 8000
best id: 464
same work at 384 numbers per vector (a common size for small models):
12 vectors -> 4608 multiply-adds, about 0.0 ms at 1 billion per second
10000 vectors -> 3840000 multiply-adds, about 3.8 ms at 1 billion per second
1000000 vectors -> 384000000 multiply-adds, about 384.0 ms at 1 billion per second