Part 6 · 5 chapters

Using Language Models in Practice

With the theory in place, we get practical: running inference, prompting effectively, getting structured outputs, and calling tools. These are the everyday skills you will use to build agents.

Chapter 26Using Language Models in Practice

Running Inference: Local and in the Cloud

We have spent five parts understanding how models are built. Now the book pivots to the half you will spend most of your time in: *using* them. This part is about putting a finished model to work, and it begins with the most basic act of all — running the model to get an answer, which is called inference. We will see the two places you can run a model, what actually happens inside when it generates text, the settings that shape its output, and how to think about speed and cost. Everything here is practical and beginner-friendly, and it is the ground floor for building agents.

Chapter 27Using Language Models in Practice

Prompt Engineering Fundamentals

If you learn one practical skill from this book, make it this one. Prompt engineering — the craft of writing the input that gets a model to do what you want — is the cheapest, fastest, and highest-leverage skill in all of applied AI. A better prompt costs nothing, takes effect instantly, and frequently outperforms expensive fine-tuning. This chapter teaches the fundamentals with plenty of before-and-after examples, and it assumes nothing. Master these basics and you will solve the large majority of tasks without ever touching training, exactly as Chapter 20 promised.

Chapter 28Using Language Models in Practice

Advanced Prompting: Chain-of-Thought, Few-Shot, and Self-Consistency

With the fundamentals of clear, specific prompting in hand, we can add a few powerful techniques that push quality higher on the genuinely hard tasks — the ones involving reasoning, multi-step logic, or a precise format. These techniques are not always needed, and using them where they do not belong just wastes tokens, so we will be equally clear about *when* to use each. By the end you will know how to make a model think more carefully, learn from examples, and double-check itself, and how to tell whether any of it actually helped.

Chapter 29Using Language Models in Practice

Structured Outputs and Function/Tool Calling

This is the most important chapter in the book's transition from understanding models to building agents — the hinge on which everything that follows turns. Until now, our models have produced prose for humans to read. But an agent needs two things a chatbot does not: output that *programs* can act on, and the ability to *use tools* to affect the world. Both come from the same underlying capability, and this chapter builds it carefully from the ground up. Take your time here; once tool calling clicks, agents stop being mysterious, because an agent is essentially a loop around the idea you are about to learn.

Chapter 30Using Language Models in Practice

Working with LLM APIs in Code

We close Part VI with the practical engineering that surrounds every real model call. Using a model in a playground is easy; using it reliably inside a program means handling the message format, carrying on a conversation, recovering from failures, and keeping costs under control. None of this is glamorous, but it is exactly the difference between a fragile demo and something you can depend on — and it is the immediate groundwork for the agents you will build next. As always, everything is hands-on and beginner-friendly, building on the first API call you made all the way back in Chapter 3.

← Part 5Part 7