Overview

1 Peeking inside the black box

This chapter introduces generative AI as a new kind of application that feels familiar to use but is unusual to build. Unlike traditional software, GenAI systems rely on large language models that accept natural-language instructions and produce outputs probabilistically, which means developers must learn to handle uncertainty rather than fixed, deterministic logic. The chapter also frames the book’s approach: focus on practical building blocks, not deep mathematical detail, and use low-code tools to make experimentation and iteration easier.

The main lesson is that real GenAI applications are more than a direct call to a model. Because LLMs are stateless and pre-trained, developers must add surrounding components that provide conversation history, relevant external knowledge, and other context so each model call has enough information to answer well. Examples like remembering a user’s name or answering with up-to-date office hours show how memory and retrieval make an application feel intelligent, while also motivating later topics such as prompt engineering, tools, agents, and retrieval-augmented generation.

The chapter then opens the black box of LLMs with an intuitive explanation of how models like GPT work. It describes text being broken into tokens, turned into embeddings, processed through large neural networks, and used to predict the next token one step at a time. It also explains the training pipeline: unsupervised learning to learn language patterns, supervised fine-tuning for dialogue, and reinforcement learning from human feedback to improve usefulness. The larger point is that while the underlying model is powerful, it has fixed knowledge and heavy computational requirements, so practical GenAI systems must combine the model with architecture, context, and updating mechanisms to stay useful in the real world.

GenAI applications have an LLM (Magic Black Box) somewhere.
The magic box. Gets text as input and generates text as output.
LLM relationships: every chat is a first date.
Taming the GenAI beast.
The three types of machine learning: Unsupervised, supervised, and reinforcement.
The learning stages of ChatGPT.
Words are numbers in the eyes of an LLM.
Given a prompt, you can calculate the context.
Guess the next best word by combining embeddings with context.
The GPT sentence completion process.
How a GPT architecture generates sentences.
The two stages of GPT-3. First, it gets trained, and then the sentence completion is inferred.
Enhancing a pre-trained model through fine-tuning.

FAQ

What is the main goal of Chapter 1, “Peeking inside the black box”?The chapter aims to help you understand how GenAI applications are built by focusing on their main building blocks, how those pieces fit together, what problems they solve, and what their limitations are. It also introduces hands-on practice with Langflow in a tool-agnostic way.
How is a GenAI application different from a traditional application?A traditional application follows explicit code-driven steps and is mostly deterministic. A GenAI application includes an LLM “black box” that takes natural language as input and produces text output probabilistically, which makes its behavior non-deterministic.
Why is an LLM called a “magic black box”?Because you can see the input and output, but not the exact internal reasoning that produced a specific response. It generates text probabilistically, so its behavior is not fully predictable or directly explainable.
Why do GenAI apps need memory if LLMs are stateless?LLMs do not remember previous calls on their own. To make a chat feel continuous, the application must store prior messages and resend relevant conversation history with each new prompt.
How does ChatGPT appear to remember a conversation?It is not the LLM remembering by itself. The ChatGPT application sends the previous conversation context back to the model each time, which lets the model respond as if it remembered earlier messages.
How can a GenAI application answer questions using fresh or private knowledge?The app must include the relevant knowledge in the prompt or retrieve it from an external source before calling the LLM. This is how the model can respond using up-to-date company data, documents, or other information not present in its training set.
What is Retrieval-Augmented Generation (RAG) in simple terms?RAG is a technique for finding relevant information from a document repository and attaching it to the prompt so the LLM can answer using that context. It helps keep responses grounded in the right knowledge.
What are the three main learning stages described for ChatGPT?The chapter describes unsupervised learning first, where the model learns to predict the next word from large text corpora; then supervised fine-tuning using human conversation examples; and finally reinforcement learning from human feedback (RLHF) to improve response quality.
How does GPT generate text one token at a time?Text is split into tokens, each token is converted into embeddings, the model builds a context from the prompt, and then it computes probabilities for possible next tokens. The most likely token is selected, added to the prompt, and the process repeats.
Why does the chapter emphasize pre-training and knowledge cutoff?Because an LLM’s core knowledge is fixed during training and does not update automatically afterward. That means it has a knowledge cutoff date, so GenAI applications often need retrieval, prompt enrichment, or fine-tuning to stay current and useful.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking AI Applications ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking AI Applications ebook for free