No history yet

Introduction to LLMs

The Engine of Modern AI

At their core, Large Language Models (LLMs) are powered by a specific design called the Transformer architecture. Introduced in 2017, this architecture revolutionized how machines process language. Before Transformers, models struggled to keep track of relationships between words in long sentences. The Transformer changed that.

It consists of two main parts: an encoder and a decoder. The encoder's job is to read and understand the input text, building a rich numerical representation of its meaning. The decoder then takes that representation and generates the output, one word at a time.

Lesson image

Think of it like a human translator. The encoder reads a sentence in French, grasping its full meaning and nuance. The decoder then uses that understanding to construct a new sentence in English. This two-part structure allows the model to handle complex language tasks with remarkable fluency.

How LLMs Pay Attention

The secret ingredient of the Transformer architecture is the attention mechanism. This is what allows the model to weigh the importance of different words when processing a sentence. It helps the model understand that in the sentence "The robot picked up the red ball because it was heavy," the word "it" refers to the "ball," not the "robot."

When you read, you naturally focus on certain words to understand the overall meaning. Attention works similarly for an LLM. As it processes text, it assigns an

attention

noun

A mechanism in neural networks that allows a model to weigh the importance of different parts of the input data when making predictions.

attention score" to each word in relation to every other word. This lets it build connections and grasp context, no matter how far apart the words are.

Lesson image

This ability to dynamically focus on relevant parts of the input is what gives Transformers their power. Instead of processing a sentence word-by-word in a fixed order, the attention mechanism allows the model to look at the entire sentence at once and decide which parts are most important for understanding the context.

The LLM's Working Memory

Every LLM has a limit to how much information it can process at one time. This limit is called the context window. It's like the model's short-term memory. The context window includes both the input you provide (your prompt) and the output the model generates.

Imagine you're having a long conversation. You can probably remember what was said a few minutes ago, but you might forget the exact details from an hour ago. An LLM's context window works in a similar way. If a conversation or a document exceeds its context window, the model starts to "forget" the earliest parts.

The context window determines the amount of recent information the model can access to inform its next response.

The size of the context window is measured in tokens, which are pieces of words. For example, the word "transformer" might be broken into three tokens: "trans", "form", and "er". A model with a larger context window can handle longer documents, maintain more coherent conversations, and follow more complex, multi-step instructions.

This is why a model might lose track of the plot when asked to summarize a very long book, or forget an instruction you gave it at the beginning of a lengthy chat. Its working memory simply isn't big enough to hold all the information at once.

Now, let's test your knowledge of these core concepts.

Quiz Questions 1/5

What is the primary function of the Transformer architecture in a Large Language Model?

Quiz Questions 2/5

In the human translator analogy, the encoder's job is to read a sentence and grasp its meaning. What is the decoder's job?

Understanding the Transformer architecture, attention, and context windows provides a solid foundation for working with LLMs.