Overview

1 Peeking inside the black box

Generative AI applications may look simple to use, but they become unusual and harder to design once you try to build them. The chapter explains that the central challenge is not just sending a user message to a model, but managing the mix of natural-language instructions and uncertain, probabilistic outputs. Real GenAI systems need supporting pieces around the model so they can preserve conversation context, supply fresh knowledge, trigger actions, and shape responses into something useful and reliable.

The chapter then peeks inside the model itself and shows why large language models feel so different from traditional software. Unlike deterministic programs that follow explicit steps, an LLM is a stateless, pre-trained black box that turns text into text and cannot remember previous calls unless the application supplies that memory. It also cannot know private or newly updated information unless that knowledge is added to the prompt or retrieved from external sources, which is why applications like chatbots and copilots appear smarter than the model alone actually is.

To build intuition for how language models work, the chapter presents GPT as an enormous sentence-completion system. Text is broken into tokens, converted into embeddings, processed through deep neural networks that compute context, and then used to choose the most likely next token repeatedly until a full response is formed. The chapter emphasizes that this is only possible because of massive pre-training, fine-tuning, and specialized hardware, and it closes by stressing that effective GenAI design means combining the model’s capabilities with memory, updated knowledge, and other architectural elements to overcome its built-in limits.

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 this chapter?The main goal is to help you understand how GenAI applications are built by focusing on the key building blocks, how they work together, and their limitations, rather than deep mathematical or architectural details.
Why are GenAI applications different from traditional applications?Traditional applications follow explicit code and deterministic rules, while GenAI applications include an LLM that behaves probabilistically and takes natural language as input, making their behavior non-deterministic.
What does it mean that an LLM is a “black box”?It means the internal reasoning of the model is not transparent. You can see the input and output, but not the exact process that led to a specific response.
Why do GenAI applications need memory management?Because LLMs are stateless and do not remember previous calls, the application must store prior messages and send them back with each new request if it wants the conversation to feel continuous.
How does ChatGPT seem to remember previous conversation details?ChatGPT appears to remember because the application resends relevant parts of the conversation history to the LLM on each call, rather than the LLM remembering on its own.
Why do LLMs need extra knowledge added to prompts?LLMs are pre-trained on fixed data and do not automatically know private, recent, or company-specific information, so the app must include relevant knowledge in the prompt when needed.
What are the main ways GenAI applications extend an LLM?They extend an LLM with components such as memory, external data sources, tools, prompt engineering, and agentic structures to create more useful real-world behavior.
How does GPT generate text in a simplified explanation?It tokenizes text, converts tokens into embeddings, builds a context from the prompt, compares that context with candidate tokens, and selects the most likely next token. This repeats to generate longer text.
How is a real LLM like GPT-3 more complex than the simplified example?Real LLMs use much larger embeddings, deep neural networks with many layers and parameters, transformer-based context processing, and a more complex word-selection process than simple averages and inner products.
Why is it important to understand pre-training and fine-tuning?Pre-training gives the model its general language ability, while fine-tuning adapts it to specific tasks or conversational behavior. Together, they explain both the model’s strengths and its fixed knowledge limits.

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