How GenAI generates

Do you ever wonder how GenAI works or why some call it a probability engine? Here is a simple analogy that covers the basic terminology without getting too technical:

The Librarian

Think of GenAI as a librarian in a vast library filled with countless books.

This librarian is extremely well-read—she’s read every single book in the building. In fact, she was born in this library, and books are all she knows. That might sound a little sad, but don’t worry: this particular librarian doesn’t have emotions. She doesn’t truly feel sadness—or anything else, for that matter.

The librarian learns from these books by identifying PATTERNS that help her remember and connect the information within them. It’s similar to how we use mnemonics—like “My Very Educated Mother Just Served Us Noodles” to remember the order of the planets.

In her case, she might have read that “dogs” often have “tails,” “fur,” and “ears,” and that they “bark.” Of course, there are many more such PATTERNS, and she knows most—if not all—of them.

The LEGO Firetruck

Now, let’s give this librarian a task: build a fire truck out of LEGO bricks.
From the patterns she’s learned, she knows a fire truck typically has wheels, a ladder, windows, doors—and is most often red.

The LEGO bricks she uses are called TOKENS in AI terminology.

Each brick has properties like shape, color, and the number of knobs. In AI, these properties are known as EMBEDDINGS—numerical values that help the model understand the relationships between different tokens.

Before building, the librarian needs to decide where to start—what parts are most important to define the fire truck. She might start with the wheels or the ladder. This process is known as the ATTENTION MECHANISM.

She also needs to clear off her desk. The available desk space determines how many TOKENS she can work with at once. This is called the CONTEXT WINDOW.

Next, she looks at the bricks and chooses which TOKEN best represents each part of the fire truck—the wheels, the windows, the body, and so on. In AI terms, this selection process is guided by PROBABILITY.

And here’s a fun twist: this librarian gets more creative when it’s warm.

For an AI model, TEMPERATURE controls how creative or unpredictable the output is. It’s a setting between 0 and 1—where 0 produces a basic, standard fire truck, and 1 might give you a fire truck with wings that can fly.

How AI Works - LEGO Building Analogy
Let's look at it again step-by-step:
The librarian remembers the PATTERNS

Like a LEGO expert who has seen thousands of vehicles, she knows what makes trucks look like trucks and not cars or planes.

She takes the TOKENS she needs based on their EMBEDDINGS

She sorts through her LEGO collection, grouping similar pieces together - all the wheels in one pile, all the cab pieces in another.

She highlights the most important features with her ATTENTION MECHANISM

She focuses on the key truck elements - the cab, the bed, the wheels - paying more attention to these critical components.

She decides how the truck should look based on TEMPERATURE

High temperature = wild, creative truck design. Low temperature = safe, conventional truck that looks like every other truck.

Her desk space, the CONTEXT WINDOW, defines the number of bricks she can use

A small desk means a simple truck. A huge desk allows for an elaborate truck with trailers, cranes, and detailed features.

She starts building using PROBABILITY to find bricks that belong together

Each piece she picks has the highest chance of creating an actual firetruck - just like AI picks the most probable next word.

All images in this article were generated with DALL-E.

Next
Next

AI - not just generative