

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Semantic Search
incomplete
2: Embeddings
incomplete
3: Embedding Models
incomplete
4: Model Selection
incomplete
5: Vector Operations
incomplete
6: Dimensions
incomplete
7: Dot Product Similarity
incomplete
8: Cosine Similarity
incomplete
9: Why Cosine Similarity?
incomplete
10: Generating Text Embeddings
incomplete
11: Document Embeddings
incomplete
12: Query Embeddings
incomplete
13: Same Model
incomplete
14: Implementing Semantic Search
incomplete
15: Locality-Sensitive Hashing
incomplete
16: Vector Databases
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Training a model to convert text into vectors takes a lot of data and computation. The model slurps up a massive amount of text and learns patterns about how words and phrases relate to each other.
For our purposes, there isn't much to gain by training our own model from scratch. We'll use a pre-trained embedding model called all-MiniLM-L6-v2 because it:
This is all it takes to load the model and convert some text into vectors:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")
print(f"Model loaded: {model}")
print(f"Max sequence length: {model.max_seq_length}")
model.encode(text)
The first time you run this, it downloads the model files. Subsequent runs will load from your local cache.
If you get an error about your GPU or hardware acceleration, load the model on your CPU instead by passing device="cpu".
Set up and test a pre-trained embedding model for our movie search system.
uv add sentence-transformers
verify_model that creates an instance of the SemanticSearch class and prints the model information:
Run and submit the CLI tests.