TAKE THE LONGER ROUTE

Open the complete high-school lesson →

Worked explanations, full local narration, and connected Signal Room, Workbench and Field Notes.

← Connected lesson

EmbeddingsA gentler route.

Plot two arrows on squared paper before using vector notation.

More time for: Cosine geometry, embedding lookup gradients, position encoding and contextual meaning.

Open high-school classroom and assessment ↗

What is an Embedding?

Let's dive into today's topic: What is an embedding? This is a key concept that helps us understand how AI processes language.

In simple terms, an embedding is how AI turns words into numbers. This lets the computer understand and work with language, since machines think in numbers.

These number representations give AI the power to find patterns, make connections, and figure out what words really mean together.

Think of embeddings like a map or coordinates in a video game. Each word has a spot on this map, showing its meaning and how it relates to other words.

By placing words on this 'meaning map', AI can navigate language and understand which words are close in meaning, or very different.

So, embeddings are the foundation for AI to really get language—not just as words, but as meaningful ideas connected by numbers.

What is an Embedding?

• Embedding: how AI turns words into numbers

• Powers AI language models to understand meaning

• Like a map or coordinates guiding word meanings

Imagine embedding as a map or video game coordinates that help AI "locate" word meanings in a space!

Tokens and Byte-Pair Encoding (BPE)

Today, we'll explore how words get broken down into smaller pieces called tokens using a method called Byte-Pair Encoding, or BPE for short. This is key to how AI models read and understand text.

First, words are split into tokens. Common words might be just one token because they appear so often. Less common words break into several tokens.

For example, the word 'neurotransmitter' is split into smaller parts like 'neuro', 'trans', 'mit', and 'ter'. Each part is a token that the AI can recognize separately.

Numbers are a bit different. Instead of whole numbers, digits are split one by one. So '1234' becomes four separate tokens: '1', '2', '3', and '4'.

Byte-Pair Encoding helps by merging the most common pairs of bytes to make efficient tokens, reducing overall token count.

This token count matters because it affects how much computation the AI needs, impacting both speed and cost. So, understanding tokenization helps us see how AI processes language behind the scenes.

Tokens and Byte-Pair Encoding (BPE)

• Words split into tokens; common words often one token

• BPE merges frequent byte pairs to form tokens

• Token count impacts AI model cost and complexity

• Example: 'neurotransmitter' tokenized, digits split one-by-one

Tokens for "neurotransmitter"

neuro + trans + mit + ter

Digits split digit-by-digit

"1234" → 1 + 2 + 3 + 4

Explore Tokens and Bytes

Let's start by clicking the word 'Hello' to see how it breaks down in smaller parts called tokens.

Now observe how 'Hello' splits into tokens, smaller chunks that the model understands separately.

Next, let's see how these tokens translate into bytes, the actual data your computer processes.

Finally, explore how the number of tokens and bytes impacts the energy and cost of processing your message.

Positional Encoding in Transformers

Let's dive into positional encoding in Transformers, a key idea that helps AI understand the order of words.

Transformers treat all words, or tokens, the same without any sense of order. That means they don’t know if a word comes first or last.

For example, the sentences “I love AI” and “AI love I” have the same words, but very different meanings because of their order.

To fix this, positional encoding adds information about the position of each word. There are different types, like sinusoidal, learned embedding, RoPE, and ALiBi.

This way, Transformers can understand not just the words but where they appear in the sentence, capturing meaning more accurately.

Positional Encoding in Transformers

• Transformers treat all words (tokens) the same

• They ignore the order words appear in

• Positional encoding adds order info to tokens

• Helps the model understand word sequence and meaning

Example: "I love AI" vs "AI love I"

• Same words but different order

• Meaning changes a lot

• Positional encoding tells model the order

Types of Positional Encoding

• Sinusoidal (mathematical waves)

• Learned (trainable embeddings)

• RoPE (rotary positions)

• ALiBi (attention bias)

Semantic Word Maps

Today, we're diving into semantic word maps, which help us understand how words relate to each other in a very visual and meaningful way.

First, imagine words as points in a multi-dimensional space, where words that are close together share similar meanings or contexts.

For example, social media slang words often group together in this space because they are used in similar conversations and carry related meanings.

This grouping helps artificial intelligence systems understand not just words, but also the context and subtle meanings behind them.

Visualizing word meanings as a map makes it easier for both humans and AI to see the relationships between different words and concepts.

You can think of it like a map of emotions or everyday words, where nearby points share feelings or similar uses.

So, by creating these semantic word maps, AI becomes better at understanding language context, which improves things like translation and chatbots.

Semantic Word Maps

• Words as points in multi-dimensional space

• Close points mean similar meanings

• Example: social media slang groups

• Helps AI understand context & meaning

Visualizing Word Meanings as a Map

Gaming

Social Media Slang

Tech Terms

Emotions

Everyday Words

How Scale Changes Embeddings' Meaning

Today, we'll explore how the scale or size of vocabulary changes what embeddings actually mean in a model. This is a key idea for understanding how language models work behind the scenes.

First, a bigger vocabulary lets us have more precise single tokens. Imagine it like having more words in your vocabulary to express exactly what you mean instead of using rough approximations.

To make this clearer, think of vocabulary size like a video game’s arsenal. A bigger weapon set means you can choose the perfect tool for the challenge, but it also means managing more gear, just like larger embedding tables cost more model resources.

Now, let's consider why some languages or rare words get split up more. This happens because the model can only afford so much vocabulary size, so it breaks down rare or complex words into smaller parts.

This leads to trade-offs between cost and accuracy. Bigger vocabularies improve precision but increase model size and computational cost. Smaller vocabularies save resources but may lose some detail.

So, understanding how scale changes embeddings helps us appreciate the balance engineers make between making models powerful and keeping them efficient.

How Scale Changes Embeddings' Meaning

• Bigger vocabulary = more precise single tokens

• Large embedding tables increase model cost

• Some languages & rare words get split more

• Trade-offs between cost and accuracy

Imagine vocabulary size like a video game’s weapon list:

More weapons mean more precise choices but require more storage!

Splitting rare words is like breaking big combos into smaller moves for better control.

Visualize Semantic Embedding Space

Let's explore how words relate to each other using this interactive 3D visualization of semantic embeddings.

Try rotating and zooming to see how words group into clusters of similar meanings.

Notice how the distance between words reflects their similarity — closer words mean more related meanings.

Feel free to pause the animation using the pause button and reset the view if you want to start fresh.

Embedding Concepts Quiz

Now let's check how well you’ve grasped the key ideas we just covered. Take your time to answer each question on your own.

Once you’re done, I’ll be here to review your results and help with anything that wasn’t clear.

Summary and Key Takeaways

Let's wrap up today's lesson by looking at a summary of the key takeaways about embeddings and their role in AI.

First, embeddings turn words into numbers that AI can understand. Think of it as translating human language into a code computers can work with.

Tokens and positional encoding help the AI process language by breaking sentences into parts and understanding the order they come in.

Semantic maps are like mental maps for computers—showing how words relate in meaning, which helps AI grasp context better.

Finally, the scale of embeddings matters because bigger models capture more detail but require more processing power.

Understanding these concepts gives you a solid foundation to appreciate how AI reads and understands language, just like we do.

Summary and Key Takeaways

• Embeddings turn words into numbers AI understands

• Tokens and positional encoding enable language processing

• Semantic maps show relationships between word meanings

• Scale influences detail level and processing cost