Chapter 1 · Part 1

Install the model

This is a hands-on course. By the end you'll have a working search engine that finds text by meaning — type "I forgot my login" and it finds the document about resetting your password, even though they share no words. And it runs entirely on your laptop: no API key, no cloud, no GPU. This first chapter gets set up. Budget five minutes here; the search engine itself is the next five chapters.

You need three things: a recent Python, an isolated environment, and one library — sentence-transformers — that gives us a ready-made embedding model.

1 · Check your Python

You need Python 3.9 or newer:

terminal
python3 --version

If that prints Python 3.9 or higher, you're set. Otherwise grab a current version from python.org/downloads first.

2 · Make a virtual environment

A virtual environment is a private, throw-away copy of Python just for this project, so its libraries never collide with anything else on your machine. Create one and activate it:

macOS / Linux
python3 -m venv .venv
source .venv/bin/activate
Windows (PowerShell)
python -m venv .venv
.venv\Scripts\Activate.ps1

Your prompt should now start with (.venv). (To leave it later, run deactivate.)

3 · Install sentence-transformers

One install gives us everything — the library, and PyTorch underneath it to run the model:

terminal
pip install sentence-transformers

This pulls in a few packages (PyTorch among them), so it's a slightly bigger download than usual — give it a minute or two. Everything runs on the CPU; you don't need a GPU for this project.

4 · Load the model and verify

Create a file called check.py. The first time you load a model, sentence-transformers downloads it (~90 MB) and caches it; every run after that is instant.

check.py
from sentence_transformers import SentenceTransformer

# A small, fast, high-quality model — perfect for a first search engine.
model = SentenceTransformer("all-MiniLM-L6-v2")

print("Model loaded.")
print("Embedding size:", model.get_sentence_embedding_dimension())
terminal
python check.py

After the one-time download you should see:

Model loaded.
Embedding size: 384

That 384 is the length of the vector this model turns any sentence into — the number we'll build the whole search engine around. Your machine is ready. Next, let's see what one of those vectors actually looks like.