Machine Learning, FoundationsLesson 69 of 92

Module 7 · Learning without labels, and learning a representation

Building a working semantic search with no GPU

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 7 of 10 in this chapter

This chapter’s goalCluster a dataset and defend the number of clusters with more than an elbow plot, reduce dimensionality with PCA and state how much information the reduction discarded, explain what an embedding is as a geometric object, and build a working nearest-neighbour search over pretrained embeddings without a GPU.

This chapter’s media

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

FormatEnglishहिंदी
Chapter filmWatch1:55Not available
Full audiobookNot availableNot available
Why production search runs bothEmbedding search winsParaphrase: ‘refund not received’ finds ‘themoney has not come back’A Hindi query retrieving an English document,in one multilingual spaceQuestions phrased nothing like the passagethat answers themThe long tail of wordings for one meaningKeyword search (BM25) winsExact identifiers: an order number, a partcode, an error stringNegation: ‘restaurants without parking’ embedsbeside ‘with parking’Rare exact terms: a drug name that appearsthree times in the corpusAnything a user expects to match letter forletterHybrid search runs BM25 and embedding search in parallel and fuses the two rankings with reciprocalrank fusion, which needs no score calibration between the systems. It reliably beats either alone andis not much more code.
Hybrid search runs BM25 and embedding search in parallel and fuses the two rankings with reciprocal rank fusion, which needs no score calibration between the systems. It reliably beats either alone and is not much more code.

Figure

A little at a time

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

Step 1 of 8Free · no account needed
Lesson steps

Getting embeddings for free

You do not train these yourself. Pretrained models are free, small enough to run on a CPU, and good enough for most applications.

Python
from sentence_transformers import SentenceTransformer
m = SentenceTransformer("all-MiniLM-L6-v2")
vecs = m.encode(list_of_texts, normalize_embeddings=True)
vecs.shape        # (n, 384)

all-MiniLM-L6-v2 is about 80 MB, produces 384-dimensional vectors, and encodes a few hundred short texts per second on an ordinary laptop CPU. It is the sensible default.

When you need better quality, all-mpnet-base-v2 is larger and slower. For non-English or mixed-language text, the multilingual models (paraphrase-multilingual-MiniLM-L12-v2 and its relatives) cover 50 or more languages in one shared space, which means a Hindi query can retrieve an English document. For Indian languages specifically, MuRIL from Google Research is free on Hugging Face and trained on 17 Indian languages including transliterated text.

All of these run locally. No API key, no per-call cost, no data leaving the machine, which matters when the documents are confidential.

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 How a Language Model Actually Works exam.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Building a working semantic search with no GPU’, in Machine Learning, Foundations. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/machine-learning-foundations/embeddings-in-practice (Accessed: 29 November 2026).