Building with AILesson 36 of 80

Module 4 · Retrieval and the knowledge problem

Vector search: when NumPy is enough, and what an index trades away

In this lesson

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

This chapter’s goalBuild a retrieval pipeline from raw documents to a ranked set of chunks (embed, index, fuse with keyword search, rerank, filter by permission) measure its recall on a gold set of your own questions, and say from cost and quality numbers whether a given corpus should be retrieved or simply placed in the context window.

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

A little at a time

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

Step 1 of 9Free · no account needed
Lesson steps

The baseline nobody sells

A hundred thousand chunks at 768 dimensions in 32-bit floats is 300 MB. A single matrix-vector product over that on an ordinary CPU takes tens of milliseconds. The result is exact: every chunk is compared, nothing is missed.

Python
import numpy as np
M = np.load("vectors.npy")            # shape (100_000, 768), rows normalised
def search(q, k=10):
    scores = M @ q                     # one dot product per chunk
    top = np.argpartition(-scores, k)[:k]
    return top[np.argsort(-scores[top])]

That is a complete vector search engine. No server, no index, no recall loss, no operations. A large share of internal tools (a company handbook, a product’s documentation, a support archive) never grow past this, and a team that starts by deploying a vector database for 20,000 chunks has bought a year of maintenance for a problem that fits in a NumPy array.

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

Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘Vector search: when NumPy is enough, and what an index trades away’, in Building with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-with-ai/vector-search-without-a-vector-database (Accessed: 29 November 2026).