Hugging Face, End to EndLesson 55 of 75

Module 6 · Embeddings, and search that understands

One space for pictures and words

In this lesson

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

This chapter’s goalBuild and measure a semantic search over your own documents: choosing an embedding model against your language and text length, chunking deliberately, normalising vectors for the similarity you use, adding a cross-encoder reranker, and reporting recall@k on questions you wrote yourself.

This chapter’s media

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

FormatEnglishहिंदी
Chapter filmWatch2:08Not available
Full audiobookNot availableNot available

A little at a time

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

Step 1 of 7Free · no account needed
Lesson steps

CLIP, and why it is interesting

CLIP was trained on hundreds of millions of image–caption pairs with one objective: put an image and its caption close together, and push mismatched pairs apart. The result is a shared space where a photograph and the sentence describing it are neighbours.

Python
from sentence_transformers import SentenceTransformer
from PIL import Image

m = SentenceTransformer("clip-ViT-B-32")
img = m.encode([Image.open("kitchen.jpg")], normalize_embeddings=True)
txt = m.encode(["a photo of a kitchen", "a photo of a motorbike"],
               normalize_embeddings=True)
print(img @ txt.T)     # [[0.31 0.09]]

Text and image vectors are directly comparable, which gives you two capabilities that used to require training:

Search photos with words. Embed 50,000 images once, then search them with a typed sentence. No tags, no labels, no training. This runs on a laptop and it is the single most immediately useful thing in this lesson.

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 Image Generation, in Practice exam.

Stuck on something?Ask Arjun, your AI tutor

How to cite: Addaly (2026) ‘One space for pictures and words’, in Hugging Face, End to End. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/hugging-face/embedding-images-and-audio (Accessed: 29 November 2026).