Skip to content
ImagineWorld

Evolution of GenAI Workflows

node_idnode-book_ai-agents-in-practice_chapter-01-evolution-of-genai-workflows
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num1
chapter_titleEvolution of GenAI Workflows
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Chapter 1 — Evolution of GenAI Workflows

Section titled “Chapter 1 — Evolution of GenAI Workflows”

Over the past two years, large language models (LLMs) have reshaped the landscape of AI. From simple prompt-based interactions to complex applications across industries, LLMs have evolved rapidly, fueled by breakthroughs in architecture, training techniques, and fine-tuning strategies. As their capabilities evolved, the shift from ChatGPT to today’s agentic systems as of April 2025 marks a natural progression, where the addition of reasoning, planning, and action-taking capabilities represented a major technological leap.

This chapter explores the foundations of LLMs, how they’re built and consumed, and the differences between pre-trained and fine-tuned models. Most importantly, it sets the stage for the next leap forward: the emergence of AI agents.

In this chapter, we will cover the following topics:

  • Understanding foundation models and the rise of LLMs
  • Latest significant breakthroughs
  • Road to AI agents
  • The need for an additional layer of intelligence: introducing AI agents

By the end of this chapter, you’ll have a clear understanding of how LLMs evolved, how they’re trained and deployed, and why the road to truly intelligent systems inevitably leads to the emergence of AI agents.

You can access the complete code for this chapter in the book’s accompanying GitHub repository at https://github.com/PacktPublishing/AI-Agents-in-Practice.

Understanding foundation models and the rise of LLMs

Section titled “Understanding foundation models and the rise of LLMs”

AI has undergone a fundamental transformation thanks to the emergence of foundation models—versatile, general-purpose models that can be adapted across a wide range of tasks. Among them, LLMs have taken center stage, redefining how we interact with machines through natural language.

Before the rise of foundation models, the field of AI was dominated by narrow AI —systems built to perform one specific task and nothing else. Each use case required a custom pipeline: a unique dataset, a dedicated model architecture, and a specialized training routine. If you wanted to classify emails as spam or not spam, you’d build a spam filter. If you needed to extract names and places from documents, you’d create a named entity recognizer. Want to summarize a news article? That would mean yet another bespoke model.

This fragmented approach had several drawbacks. Models were brittle—performing well only within the narrow domain they were trained for—and expensive to maintain. Any shift in the task or data distribution often meant retraining from scratch.

The introduction of foundation models marked a fundamental shift in how we build and think about AI systems. These models are trained on vast and diverse datasets that span multiple domains and tasks. The idea is to teach a single model a general understanding of the world—its language, structure, and patterns—during a large-scale pretraining phase. Once this general knowledge is embedded, the model can be adapted to specific tasks with minimal additional data and compute.

For example, instead of building a separate model for translating French to English, we can now take a pre-trained foundation model and fine-tune it on a smaller translation dataset. The pre-trained model already understands language syntax, grammar, and meaning. Fine-tuning simply aligns this understanding to a specific objective.

The key innovation behind foundation models is transfer learning. Rather than learning from scratch, these models transfer knowledge gained from general training to specific problems. This dramatically improves efficiency, reduces the amount of labeled data required, and leads to more robust and flexible AI systems.

Moreover, foundation models aren’t just about language. They apply across modalities: some models can process and generate not only text but also images, audio, or code.

In essence, foundation models act as a “base brain” for AI—trained once, then repurposed many times over. This scalability and adaptability have unlocked entirely new possibilities in how we build intelligent systems, setting the stage for more autonomous and interactive applications such as AI agents.

Now, we mentioned that foundation models are capable of managing a variety of data formats. Within the cluster of foundation models, we can find data-specific models that focus on only one data type, which is the case of LLMs.

Figure 1.1: Features of LLMs

Figure 1.1: Features of LLMs

LLMs are, in essence, the language-specialized version of foundation models. They’re built on deep neural network architectures—particularly transformers—and are trained to predict the next word in a sequence. But this seemingly simple goal unlocks surprisingly emergent behaviors. LLMs can carry on conversations, answer intricate questions, write code, and even simulate reasoning.

Definition

Emergent behaviors are complex capabilities that arise unexpectedly when a system reaches a certain scale, even though those capabilities weren’t explicitly programmed or anticipated. In the context of LLMs, these behaviors surface when models are scaled up in terms of data, parameters, and training time—unlocking new abilities that were absent in smaller versions.

As models scale, they begin to exhibit emergent properties, including the following:

  • In-context learning: LLMs can learn to perform a task simply by being shown a few examples in the prompt—without any fine-tuning. This was not seen in smaller models.
  • Chain-of-thought reasoning: By generating intermediate reasoning steps, LLMs can solve multi-step problems such as math word problems or logical puzzles—something they previously struggled with.
  • Analogical reasoning: They can solve analogy problems (e.g., “cat is to kitten as dog is to…”) in a way that resembles human cognitive processing.
  • Arithmetic and logic: At scale, LLMs develop the ability to handle tasks such as multi-digit arithmetic or logic puzzles, even if these tasks weren’t part of their training objective.
  • Understanding metaphors and humor: Advanced LLMs can interpret new metaphors or even attempt jokes—demonstrating an abstract grasp of language and nuance.
  • Multi-task generalization: Rather than being trained for one specific task, they can simultaneously handle translation, summarization, question answering, and more—without task-specific training.

These capabilities represent more than just better performance—they are qualitatively new behaviors that “emerge” only at scale, giving LLMs a surprisingly broad range of skills with real-world implications across domains.

At the core of every LLM is a powerful neural network architecture—most commonly, a transformer. These networks are built to process and understand patterns in data, particularly human language, by learning statistical relationships across billions of text examples. Though loosely inspired by the structure of the human brain, LLMs function purely through mathematics, passing information through interconnected layers that adapt as the model trains.

To make language computable, the first step is to convert it into numbers because neural networks can’t process raw text. This happens through two key steps— tokenization and embedding:

  • Tokenization breaks down sentences into smaller chunks called tokens. These could be full words or parts of words, depending on the model. For example, “The cat sat on the mat” might be split into individual words or smaller subword units, depending on the tokenizer used.
  • Embedding takes these tokens and maps each one to a high-dimensional vector—a string of numbers that encodes its meaning and relationship to other words. These embeddings are learned during training so that similar words end up in similar regions of the model’s “semantic space.” This helps the model understand context and word usage, such as how “Paris” and “London” relate as cities.

Figure 1.2: An example of embedding

Figure 1.2: An example of embedding

Once the input is tokenized and embedded, it moves through the transformer network itself. Unlike traditional neural networks with just a few hidden layers, LLMs use dozens—or even hundreds—of stacked layers, each containing mechanisms called attention heads. These attention layers help the model decide which parts of the input are most relevant to a given prediction. For instance, when completing a sentence, the model learns to focus more on specific previous words that influence what should come next.

Training an LLM means teaching it to make better predictions over time. This is done through a method called backpropagation, where the model compares its predicted word to the correct one, calculates how far off it was, and then updates its internal parameters to reduce future errors.

Definition

Backpropagation is the core learning algorithm used to train neural networks. It works by comparing the model’s prediction to the correct answer, calculating the error (called the loss), and then adjusting the network’s internal parameters (weights) to reduce that error. This adjustment happens by “propagating” the error backward through the layers of the network—hence the name. Over time, this process helps the model make increasingly accurate predictions.

Let’s say you type The cat is on the.... The model predicts the next word by assigning probabilities to possible continuations such as mat, roof, or sofa. It doesn’t guess randomly—it relies on patterns it has seen during training.

This process is repeated across vast amounts of data—millions or billions of sentences—enabling the model to gradually capture the structure and rhythm of language. The result is a system capable of not just completing sentences but also holding conversations, solving problems, and responding with context-aware, often remarkably fluent language.

Once the training stage of an LLM is concluded, we need to understand how to predict the next token with this model, and that process is called inference.

In the context of machine learning and AI, inference refers to the process of running a trained model on new input data to generate predictions or responses. In LLMs, inference involves processing a prompt and producing text-based output, typically requiring significant computational resources, especially for large models.

LLMs can be typically accessed through APIs, allowing developers to use them without managing complex infrastructure. This approach simplifies integration, making AI-powered applications more scalable and cost-effective.

LLM providers such as OpenAI, Azure AI,and Hugging Face offer APIs that handle requests and return responses in real time. The process usually involves the following:

  1. Authentication: Developers use API keys or OAuth tokens for secure access. Definition Authentication is how developers prove that their application has permission to access an external service. This is usually done using either API keys or OAuth tokens. An API key is a unique string provided by the service—such as a password—that identifies the app. OAuth, on the other hand, is a more flexible system that allows users to grant specific permissions to apps, issuing temporary access tokens in return. Both methods ensure that only authorized users or systems can make requests, helping protect sensitive data and resources.
  2. Sending a request: A structured JSON request includes the model name, prompt, and parameters such as temperature (for randomness).
  3. Receiving a response: The API returns a generated text output along with metadata such as token usage.

Figure 1.3: An example of an HTTP request to the LLM API

Figure 1.3: An example of an HTTP request to the LLM API

Note

Some LLM APIs support streaming responses, where the model outputs tokens incrementally rather than waiting to generate the full response before sending it. This approach helps mitigate the high latency often associated with large models. By delivering the first chunk of text quickly, streaming reduces perceived latency—the time the user waits before seeing any output—leading to a smoother, more responsive experience.

Now, a legitimate question might be: what if I want to run my model on my local computer? To answer this question, we first need to distinguish between the following:

  • Private LLMs: These are proprietary models developed by companies such as OpenAI, Anthropic, or Google. They’re closed source, meaning you can’t see or modify their underlying code. Those models are typically only accessible via APIs, and they come with a pay-per-use, token-based cost.
  • Open source LLMs: Open source models, such as Meta’s LlaMA, Mistral, and Falcon, are freely available for anyone to download, modify, and deploy. This means developers can access the underlying trained parameters, run them on private infrastructure, and even use the underlying architecture to retrain the model from scratch.

Even for open source LLMs, however, many developers opt to access these models via APIs provided by platforms such as Azure AI Foundry and Hugging Face Hub.

This approach offers several advantages:

  • Reduced infrastructure costs: Running LLMs independently demands significant computational resources, which can be cost-prohibitive. Utilizing APIs shifts this burden to the service provider, allowing developers to leverage powerful models without investing in expensive hardware.
  • Scalability: API services can dynamically scale to handle varying workloads, ensuring consistent performance without manual intervention.
  • Security and compliance: Platforms such as Azure AI Foundry offer enterprise-grade security features, helping organizations meet compliance requirements and protect sensitive data.

In the context of AI agents and, more broadly, AI-powered apps, the most adopted path is that of consuming LLMs via APIs. Exceptions might be related to disconnected scenarios (e.g., running LLMs at offshore sites or remote locations) or regulatory constraints in terms of data residency (the LLM must reside in a specific country where there is no public cloud available).

The field of GenAI has experienced rapid advancements over the past few years, with breakthroughs that pushed the boundaries of efficiency, adaptability, and reasoning capabilities. In the following sections, we are going to explore some of the latest techniques that significantly enhance GenAI models’ performance while reducing computational demands.

Small language models (SLMs) are becoming increasingly relevant as organizations seek efficient, cost-effective alternatives to large-scale AI systems.

SLMs are a streamlined category of GenAI models designed to efficiently process and generate natural language while using fewer computational resources than their larger counterparts. Unlike LLMs, which can have hundreds of billions of parameters, SLMs typically contain only a few million to a few billion parameters.

The reduced size of SLMs allows them to be deployed in environments with limited hardware capabilities, such as mobile devices, edge computing systems, and offline applications. By focusing on domain-specific tasks, SLMs can deliver performance comparable to LLMs within their specialized areas while being more cost-effective and energy-efficient.

SLMs can be designed as domain-specific models since their pre-training stage, or they can be adjusted and tailored after their first training (which will still be general-purpose, as LLMs). The process of further specializing a model on a specific domain is called fine-tuning.

The fine-tuning process involves using smaller, task-specific datasets to customize the foundation models for particular applications.

This approach differs from the first one because, with fine-tuning, the parameters of the pre-trained model are altered and optimized toward the specific task. This is done by training the model on a smaller labeled dataset that is specific to the new task. The key idea behind fine-tuning is to leverage the knowledge learned from the pre-trained model and fine-tune it to the new task, rather than training a model from scratch.

Figure 1.4: An illustration of the process of fine-tuning

Figure 1.4: An illustration of the process of fine-tuning

In the preceding figure, you can see a schema on how fine-tuning works on OpenAI pre-built models. The idea is that you have a pre-trained model available with general-purpose weights or parameters. Then, you feed your model with custom data, typically in the form of “key-value” prompts and completions. In practice, you are providing your model with a set of examples of how it should answer (completions) to specific questions (prompts).

Here, you can see an example of how these key-value pairs might look:

{"prompt": "<prompt text>", "completion": "<ideal generated text>"}
{"prompt": "<prompt text>", "completion": "<ideal generated text>"}
{"prompt": "<prompt text>", "completion": "<ideal generated text>"}
...

Once the training is done, you will have a customized model that is particularly suited for a given task, for example, the classification of your company’s documentation.

The major benefit of fine-tuning is that you can make pre-built models tailored to your use cases, without the need to retrain them from scratch, yet leveraging smaller training datasets and hence less training time and compute. At the same time, the model keeps its generative power and accuracy learned via the original training, the one that occurred on the massive dataset.

Fine-tuning is particularly valuable for SLMs, as it enables them to achieve high performance while maintaining their efficiency.

Several advanced fine-tuning techniques have been developed to optimize the process, especially for SLMs:

  • Low-rank adaptation (LoRA): This method inserts trainable low-rank matrices into the model’s layers, allowing adaptation to new tasks with minimal computational overhead. LoRA is highly efficient in terms of memory usage and is widely used to fine-tune large models on limited hardware.
  • Adapter tuning: Instead of modifying the entire model, small neural network modules called adapters are added to each layer. During fine-tuning, only these adapters are updated, significantly reducing the number of trainable parameters while preserving the model’s pre-trained knowledge.
  • Prefix tuning and prompt tuning: These techniques guide the model’s output by attaching learnable task-specific vectors or tokens to the input. Prefix tuning introduces trainable vectors at the beginning of the input sequence, whereas prompt tuning optimizes a set of prompt tokens to steer the model’s behavior. Both approaches allow for efficient adaptation without altering the model’s internal parameters.

By leveraging SLMs in combination with efficient fine-tuning methods, AI applications can achieve high levels of performance without the computational and financial burdens of massive models. This makes AI more accessible, sustainable, and scalable for a wide range of industries and use cases.

Model distillation, also known as knowledge distillation (KD), is a process where heavy LLMs (by heavy, we refer to their high number of parameters) transfer their knowledge to lighter LLMs or SLMs without a significant loss in performance.

This is a crucial technique if we consider that the most powerful LLMs are typically made of billions—if not trillions—of parameters, making them computationally expensive for both training and inference. In fact, among the main benefits of distillation, we can mention the following:

  • Reduced model size while preserving accuracy
  • Improved inference speed and reduced latency
  • Lower computational and energy costs
  • Enables deployment on edge devices and mobile platforms

Distillation typically follows a structured training pipeline:

  1. Teacher model training: A large, powerful LLM is pre-trained on vast datasets and fine-tuned for specific tasks.
  2. Soft label extraction: When the LLM returns its output (known as hard labels), we know that each token is the result of a probabilistic computation—the one with the highest probability associated. However, for each prediction, we have an associated vector of probability which, in fact, provides a nuanced view of the teacher’s predictions and thought process. These probabilities, referred to as soft labels, are extracted as they will be extremely useful to train the student model.
  3. Student model training: A smaller model is trained using soft labels along with the ground truth, which serve as a rich source of information and nuanced predictions.
  4. Optimization and fine-tuning: The student model undergoes additional refinements to further enhance its accuracy and efficiency.

Figure 1.5: Generic framework for model distillation (source: https://arxiv.org/pdf/2006.05525)

Figure 1.5: Generic framework for model distillation (source: https://arxiv.org/pdf/2006.05525)

As LLMs continue to grow in size and computational demands, distillation techniques enable more practical deployment while retaining high-quality outputs.

In late 2024, a new class of AI models known as reasoning language models (RLMs) emerged, designed to enhance complex problem-solving capabilities beyond traditional LLMs. These models represent a significant shift in GenAI development, focusing on internal deliberation and step-by-step reasoning to tackle intricate tasks.

Examples of RLMs are the following:

  • OpenAI’s o1 model: Released in September 2024, the o1 model introduced a “private chain-of-thought” mechanism, allowing the model to internally process and reason through problems before responding. This approach led to substantial improvements in fields such as mathematics and science, with o1 solving 83% of problems on the American Invitational Mathematics Examination (https://en.wikipedia.org/wiki/OpenAI_o1?utm_source=chatgpt.com), marking a notable increase in performance compared to previous models.
  • OpenAI’s o3 model: Building upon the advancements of o1, the o3 model, unveiled in December 2024, further enhanced reasoning capabilities by allocating more time for internal deliberation. This resulted in higher accuracy on complex tasks, including coding and advanced scientific queries. Notably, o3 achieved a 75.7% score on the ARC-AGI benchmark (https://arcprize.org/blog/oai-o3-pub-breakthrough), reflecting its superior problem-solving skills. Definition Abstraction and Reasoning Corpus for Artificial General Intelligence (ARC-AGI) is a benchmark designed to evaluate an AI system’s ability to generalize and adapt to novel tasks, closely mirroring human-like intelligence. Introduced by François Chollet in 2019, ARC-AGI emphasizes problem-solving skills that require abstract reasoning without relying on extensive prior data or domain-specific training.
  • DeepSeek’s R1 model: In January 2025, Chinese start-up DeepSeek introduced R1, an open source reasoning model that matched the performance of leading models such as o1 while being developed at a fraction of the cost. The open source nature of R1 has facilitated widespread research and adaptation, contributing to its rapid adoption and impact.

The great differentiator of reasoning models is that they “take their time” before answering; unlike traditional LLMs, which generate responses in a single pass, RLMs engage in internal deliberation, processing multiple reasoning steps before arriving at a conclusion. This method enhances their ability to handle complex, multi-step problems, which is key the moment we start talking about AI agents, as we will see throughout the book.

Also, RLMs are specifically trained to excel in tasks requiring advanced reasoning, such as complex mathematics, scientific research, and intricate coding challenges. This specialization enables them to outperform traditional LLMs in these domains.

The natural consequence of the preceding feature is that the internal processing and extended reasoning pathways of RLMs necessitate more computational power and time per query compared to traditional LLMs. This trade-off results in superior performance on tasks demanding deep reasoning at the cost of increased resource consumption.

In January 2025, everyone’s attention turned toward a new, breakthrough model called DeepSeek R1.

DeepSeek, a Chinese AI company founded in 2023, has developed a series of advanced LLMs—culminating in its R1 series—that have disrupted the AI industry by demonstrating that high-performance models can be developed efficiently and cost-effectively. As the icing on the cake, DeepSeek open-sourced this training approach as well as the models themselves, so that everyone can download them and use them locally.

These are the main features that make DeepSeek LLMs a leap forward in the field of GenAI:

  • Training approach: What sets DeepSeek apart is its unique approach to training. Instead of relying heavily on manually labeled datasets, DeepSeek’s R1-Zero model was trained using reinforcement learning (RL) alone. In RL, models learn by trial and error—receiving rewards for producing desirable outputs. In this case, the LLM was rewarded for generating coherent and accurate responses, encouraging it to develop reasoning capabilities independently.

This pure-RL approach allowed DeepSeek to push boundaries, but it initially came with trade-offs: the model sometimes produced less readable or inconsistent language. To address this, the team adopted a multi-stage training process for the follow-up R1 model, combining different techniques to gradually improve the model’s performance.

The process began with supervised fine-tuning on a small, high-quality dataset—often referred to as cold start data—to establish a strong linguistic foundation. Then, RL was reintroduced to sharpen reasoning and decision-making abilities. The model also generated synthetic data, which was filtered through rejection sampling to remove poor outputs. This filtered data was used for further supervised training. A final RL phase helped improve the model’s consistency and adaptability across diverse tasks.

The result? A model that rivals top-tier alternatives such as OpenAI’s o1 in quality—despite being trained with fewer resources and no large-scale human-annotated datasets.

  • Hardware utilization: In an industry where access to cutting-edge hardware is often a limiting factor, DeepSeek has demonstrated that innovation can offset hardware constraints. The company successfully trained its flagship model, DeepSeek-R1, using approximately 2,000 NVIDIA H800 GPUs over a span of 55 days, incurring a cost of around $5.6 million, thanks to the training strategy explained previously. This achievement is particularly noteworthy given the U.S. export restrictions on advanced AI chips to China, underscoring DeepSeek’s ability to optimize available resources effectively.
  • Open source: DeepSeek’s commitment to open source principles has fostered a collaborative environment that accelerates innovation. By making its models and training methodologies publicly available, DeepSeek invites researchers and developers worldwide to contribute to and build upon its work.

DeepSeek’s advancements have sent ripples across the global AI community, challenging established players and prompting a reevaluation of existing practices.

The rapid evolution of GenAI has taken us from simple automation to increasingly intelligent systems capable of reasoning, learning, and decision-making. In recent years, LLMs have revolutionized how we interact with the surrounding ecosystem, enabling more natural conversations and sophisticated problem-solving.

Let’s explore the greatest milestones that have eventually fueled the rise of AI agents.

Since the launch of ChatGPT in November 2022, the very first use case that users embraced was that of conversational text generation, such as the following:

  • “Generate a beginner-level description of the nuclear fission”
  • “Draft an email to send to the C-level board of my customer to invite them to our event”
  • “List 10 ideas for an article about AI”
  • “Generate an essay about the French Revolution I have to hand over by tomorrow”

Do any of the preceding scenarios look familiar to you?

The text generation capability of LLMs was disruptive because it fundamentally changed how humans interact with technology, enabling AI to produce human-like text with unprecedented fluency and contextual understanding.

Note

In this context, text also includes code, as LLMs have demonstrated significant capabilities in generating and assisting with programming tasks since the very beginning. Back then, common code-related tasks included code generation, debugging, optimization, translation, and explanation.

LLMs marked an unprecedented shift in the field of traditional AI and natural language processing, as they could generate coherent, creative, and contextually relevant text on demand. All of a sudden, such an incredible technology was available to every user with an internet connection, democratizing access to high-quality writing, accelerating automation in industries such as marketing and customer service, and even reshaping creative fields by assisting in storytelling, poetry, and scriptwriting.

However, after the initial hype of having this free, conversational assistant that seemed to know anything about the world we live in, we soon started realizing that there was a huge limitation. ChatGPT and, more generally, LLMs carry knowledge that is limited to the data they have been trained on (this is parametric knowledge). Now, even if this data represents the whole web, users still need to deal with dynamic, proprietary,or niche datasets that were not part of the model’s training data.

Chatting with your data is, in fact, the next milestone in our GenAI roadmap.

“I want to chat with my data.” This statement leads to a specific technique called retrieval-augmented generation (RAG). This method allows the LLM to not only generate text but also retrieve relevant information from external sources before generating a response, ensuring accuracy, context relevance, and a lower risk of hallucination.

Definition

In the context of language models, hallucination refers to the generation of information that is plausible-sounding but false or unsupported by factual data. This can undermine trust, especially in scenarios that demand accuracy.

The process of “scoping” the LLM to a predefined knowledge base is called grounding. A critical part of RAG is the vector database (vector DB), which efficiently stores and retrieves information using a vector representation called embeddings. This allows the LLM to search for semantically relevant information rather than just exact keyword matches.

Let’s break down each step of this technique:

  1. Retrieval or finding relevant information: Instead of relying only on pre-trained knowledge, RAG first retrieves relevant data from an external knowledge base that has been properly vectorized. This could be PDFs, Word files, reports, research papers, structured records, tables, internal archives, and so on.

When you ask a question, the RAG pipeline converts it into a vector itself and searches for the most relevant pieces of information in the dataset by computing the distance function between the user’s vectorized query and the knowledge base’s vectorized chunks. Because of the way embeddings are computed, the lower the mathematical distance, the higher the semantic similarity. This step ensures that AI is not just generating responses from memory but actively retrieving the most relevant and up-to-date information from your data.

  1. Augmentation—enhancing AI understanding: Once the system retrieves relevant documents, they are fed into the model along with the original query. This step augments the AI’s understanding by providing contextually rich input.

Instead of guessing or relying on general knowledge, the AI now has grounded, context-specific information to base its response on. This augmentation process ensures that the model’s output is the following:

  • More precise because it directly references relevant data
  • More explainable since responses are backed by retrievable sources
  • Less prone to hallucinations as AI generates text in a curated and grounded context
  1. Generation—creating a context-aware response: With the augmented context, the AI then generates a response that is more informative, accurate, and aligned with the retrieved data. The final output is the following:
    • Factually grounded, as it incorporates retrieved knowledge
      • Context-aware, tailored to your specific dataset
      • Referenceable, meaning it can provide citations or source links when needed

This step ensures that the response is not just an AI-generated answer but one that is specifically crafted based on the retrieved and augmented knowledge from your data.

In the next chapters, we will cover more about RAG and its role in agentic systems.

Until now, we’ve only been talking about text data, but what if we want to interact with our models with images, video, or audio?

Multimodality in GenAI refers to the ability of models to process and generate content across multiple types of data, such as text, images, audio, and video. Multimodal LLMs (MLLMs) extend the capabilities of traditional LLMs by incorporating multiple modalities, allowing for more comprehensive understanding and richer interactions.

Recent advances, such as OpenAI’s GPT-4V and Google’s Gemini, demonstrate how MLLMs can analyze images, generate captions, process voice inputs, and even reason across different formats in a single workflow.

The key feature of LMMs is that they share the capability of generalization and adaptation with text-only LLMs. However, LMMs are capable of processing heterogeneous data with the idea of mirroring the way humans interact with the surrounding ecosystem—that is, with all our senses.

A great example of a multimodal model is OpenAI’s GPT-4o, which is able to interact with users via text, images, and audio. Let’s see a couple of examples with images:

Figure 1.6: Example of ChatGPT reasoning over an image

Figure 1.6: Example of ChatGPT reasoning over an image

As you can see, the model was able to analyze the image and reason over it. Let’s now go ahead and ask the model to generate an illustration:

Figure 1.7: Example of ChatGPT changing the style of an image

Figure 1.7: Example of ChatGPT changing the style of an image

The most interesting fact about LMMs is that they preserve their reasoning capabilities, making them suitable for complex reasoning in heterogeneous data contexts. Let’s consider this last example (showing only the first lines of the response):

Figure 1.8: Example of ChatGPT reasoning over a puzzle and solving it

Figure 1.8: Example of ChatGPT reasoning over a puzzle and solving it

As you may imagine, this opens a landscape of applications in various industries, and we are going to see some concrete examples in the upcoming chapters.

The need for an additional layer of intelligence: introducing AI agents

Section titled “The need for an additional layer of intelligence: introducing AI agents”

LLMs have demonstrated impressive capabilities in generating coherent text, answering questions, and even performing limited problem-solving. However, their fundamental design presents several limitations when it comes to real-world applications:

  • Lack of long-term memory: Most LLMs operate within a fixed context window, meaning they forget previous interactions once the context limit is exceeded. This makes them incapable of learning from past experiences or maintaining continuity over time.
  • No persistent goals or autonomy: LLMs respond to individual prompts but do not operate with a persistent goal-oriented mindset. They cannot proactively make decisions, self-correct, or refine their approach over time.
  • Limited reasoning and multi-step execution: While LLMs can follow instructions within a single prompt, they struggle with executing multi-step workflows, handling complex decision-making, and maintaining logical coherence across long interactions.
  • Inability to interact with external systems: Without additional integrations, LLMs cannot retrieve real-time information, call APIs, manipulate databases, or execute actions beyond text-based output.

To address these challenges, AI agents introduce an additional layer of intelligence that enables models to act autonomously, reason through tasks, interact with external environments, and learn from past interactions.

We will define the anatomy of an AI agent in the next chapter. However, you can start thinking about it as a system that combines an LLM with additional capabilities such as memory, planning, and multi-step reasoning to perform tasks with minimal human intervention, leading to a great degree of autonomy. Unlike standard LLMs that generate static responses, AI agents can do the following:

  • Persist across interactions by maintaining memory and adapting their behavior over time
  • Break down complex tasks into smaller steps and execute them sequentially
  • Interact with tools and APIs to retrieve real-time data, automate workflows, and take meaningful actions
  • Make decisions autonomously based on learned knowledge, goals, and constraints

At their core, AI agents act as intelligent assistants capable of handling sophisticated tasks beyond simple question-answering. We will explore them in detail in the upcoming chapters.

Over the past two years, AI has undergone a profound transformation, shifting from simple LLM API calls to more sophisticated, interactive, and autonomous systems. The rapid evolution of LLMs has been marked by innovations such as RAG, fine-tuning advancements, and reasoning-focused architectures, all aimed at improving efficiency, adaptability, and cost-effectiveness.

Despite these advances, LLMs alone are not enough to meet the growing demand for AI systems that can operate autonomously, make decisions, and interact meaningfully with their environments.

This shift marks a pivotal moment in AI development, where the focus is no longer just on making models bigger but on making them smarter. Instead of treating AI as a passive tool that responds to isolated prompts, we are now designing agentic systems that can act, learn, and adapt to complex real-world tasks.

In the next chapter, we will examine the emergence of AI agents, their primary components, and the various forms they may take.