No history yet

Advanced Transformers Recap

From Model to Agent

Using a large language model (LLM) is one thing; building a reliable AI agent is another. An agent needs more than just a prompt. It needs to perceive, plan, and act. To build these systems, we need to look under the bonnet at the Transformer architecture that powers them. An agent's ability to reason, remember, and follow complex instructions is directly tied to the inner workings of its core model.

The leap from a simple chatbot to an autonomous agent isn't about better prompts. It's about better architecture and control.

The Engine of Reasoning

At the heart of a Transformer model is the , which is essentially its system for focusing. When an agent processes information—its goals, its available tools, the results of its last action—the attention mechanism allows it to weigh the importance of every piece of data. It learns which words are most relevant to which other words, enabling it to form connections and reason about the task at hand.

Lesson image

This ability to dynamically focus is what allows an agent to parse a complex user request, identify the key entities, and select the correct tool. But this powerful mechanism has a hard limit: the context window.

Memory and Budgets

The is the total amount of text the model can 'see' at once. It's the agent's working memory, and it's measured in tokens. A token is roughly equivalent to a few characters of text. Every part of the interaction—the system prompt, the user's request, the conversation history, and any tool outputs—must fit within this window. If the history gets too long, older information falls out of view, causing the agent to forget what happened earlier.

Effectively managing this token budget is a core challenge in agent design. You have to decide what information is critical to keep in context. Forgetting a user's name is one thing; forgetting the primary goal of the task is a critical failure.

Steering the Agent

Early LLMs were 'completion models'. You gave them text, and they predicted the next most likely words. This is useful, but not for building an agent that needs to follow specific instructions. The breakthrough came with instruction-tuning, which fine-tuned models on datasets of instructions and desired responses. This created chat models that are much better at following commands and staying on topic.

This is where the system prompt comes in. The system prompt is a special instruction, invisible to the end-user, that sets the agent's persona, rules, and objectives. It's the constitution for the agent, defining its boundaries and guiding its behaviour before it ever sees a user's message. A well-crafted system prompt is the primary tool for controlling an agent's behaviour.

Completion Model: "The first person on the moon was Neil..." → "Armstrong." Instruction-Tuned Model: "Who was the first person on the moon?" → "The first person on the moon was Neil Armstrong."

For reliable agentic systems, you also need models with specific features. The ability to handle very long contexts, as mentioned, is paramount for memory. Another critical feature is reliable structured output. When you ask an agent to use a tool, you need its response in a predictable format, like JSON. Models fine-tuned for function calling or JSON mode are far more dependable for these tasks, reducing errors and making the entire system more robust.

Let's test your understanding of these core architectural concepts.

Quiz Questions 1/5

What is the primary function of the attention mechanism within a Transformer-based AI agent?

Quiz Questions 2/5

An AI agent is tasked with summarising a long document. After processing the first half, it seems to have 'forgotten' the key points from the very beginning. What is the most likely technical limitation causing this issue?

Understanding these architectural details—attention, context windows, and instruction-tuning—is what separates basic prompting from true agent engineering. They are the levers we pull to create AI systems that can reason, remember, and reliably execute tasks.