AI for Youth Academy Future Scholars Research Initiative

Year 1 · Week 04

Chapter 4: Vectors in AI, 3D Space, and Python Basics

This week we connect the math we've learned to real AI applications. You'll discover how computers turn words into vectors, extend our coordinate systems into 3D, and start coding in Python using Google Colab.

Part 1: Why AI Needs Vectors

Here's a question: how does a computer understand words? Computers work with numbers, not language. So AI researchers came up with a brilliant idea—turn words into vectors!

This process is called word embedding. Each word becomes a list of numbers (a vector) that captures its meaning. Words with similar meanings end up close together in this "vector space."

Word Analogies as Vector Math

The most famous example of word vectors is the king-queen analogy:

king - man + woman = queen

What does this mean? When AI researchers trained a model on millions of sentences, they found that:

  • The vector for "king" minus the vector for "man" captures "royalty without gender"
  • Adding the vector for "woman" gives us... the vector closest to "queen"!

This shows that the model learned the relationship between gender and royal titles just from reading text—nobody explicitly taught it that kings and queens are related!

Another Example: Verb Tenses

Word vectors also capture grammar patterns. Consider:

playing - play = studying - study

The difference between "play" and "playing" (the "-ing" transformation) is almost identical to the difference between "study" and "studying." The model learned verb conjugation patterns as directions in vector space!

Part 2: Stepping Into 3D Space

So far, we've worked with 2D coordinate systems using x and y. But the real world is three-dimensional! To describe a point in 3D space, we need a third axis: z.

In a 3D coordinate system:

  • x-axis: Points left (-) and right (+)
  • y-axis: Points down (-) and up (+)
  • z-axis: Points at a 45-degree angle toward the lower left (-) and upper right (+)

Part 3: Python Basics

This week we also start coding in Python using Google Colab. Python is a powerful yet easy-to-learn programming language widely used in AI and machine learning.

Variables and Data Types

In Python, we can create variables to store data:

temperature = 72        # Integer (int)
price = 19.99           # Floating-point (float)
name = "LEGO Robot"     # String (str)
is_active = True        # Boolean (bool)

Lists

Lists let us store multiple values:

coordinates = [3, 5, 2]  # A list of three numbers
print(coordinates[0])    # Prints 3 (the first element)