Search⌘ K
AI Features

Embeddings: The Engine of Semantic Search

Learn how embeddings convert text into numeric vectors that capture meaning, enabling semantic search, clustering, and classification. Explore cosine similarity and pooling techniques with hands-on coding examples using Google Generative AI APIs.

In our last lesson, we explored the art of communication with LLMs through prompt engineering. We can now control a model’s persona, rules, and output format. However, to build more advanced applications, we need to go beyond simply interacting with the model. We need to build systems around it. The first step in that journey is to understand the most important tool for representing the meaning of text: embeddings.

This lesson will be our practical deep dive. We will move from the theory of embeddings we touched on earlier to a hands-on exploration of how they work and why they are the engine behind modern AI applications like semantic search.

A quick recap

Before we dive into the code, let’s build a mental model of the transformation from text to a meaning vector. We’ll do this by breaking the process down into three key questions.

Question 1: What is a token?

  1. A single character in a piece of text.

  2. The smallest unit of meaning the model works with, which can be a word, part of a word, or punctuation.

  3. A special keyword that tells the model what to do.

Choose the correct option below.

The power of comparing meaning

...