Chapter 3: Installing and setting up Ollama
Introduces Ollama as the tool for downloading and running large language models directly on a Mac, while previewing the chapter’s setup steps.
After this chapter you will be able to
- Ollama’s local model role. Explain that Ollama is a program for downloading and running large language models directly on a Mac.
- Ollama and model roles. Explain that Ollama is a runtime for downloading, managing, and running large language models, not the AI model itself. Describe how it makes a model file usable for tasks such as answering questions or generating text.
- Simple model operation and management. Describe how Ollama makes it straightforward to start using a model and manage several models.
- Ollama server and response flow. Trace what happens after Ollama starts and receives a question from the terminal or an API request from a Python script.
- Local Ollama processing boundary. Explain where the Ollama components shown within “Your Mac” operate and whether their processing sends data over the internet.
- Cloud and local data flow. Explain that cloud AI sends a prompt over the internet to a provider’s server, whereas local AI keeps the prompt, model, and response on your own machine. Describe why the book favors local AI for learning and building close to the system.
- Ollama installation outcome. Describe what the installation accomplishes: one command puts an AI runtime on your computer, and the installation takes about 30 seconds.
- Ollama installation checks. Describe the two checks presented for an Ollama installation: a verification command and a Homebrew details check. Do not require the exact commands or output, which are not included in the supplied text.
- Ollama service availability. Explain that Ollama runs as a foreground server in a terminal, waiting for requests, and must be started before you can interact with an AI model. State that it runs until you stop it or close the terminal.
- Starting the Ollama service. Describe how to start Ollama with `ollama serve` and why other commands need a second terminal window while it runs.
- Ollama service verification methods. Describe the terminal and browser checks, and explain what a successful result from each establishes.
- Ollama startup sequence. Trace what Ollama does when `ollama serve` starts: it checks the available hardware and acceleration options, then opens a port to listen for requests.
- Stopping and verifying Ollama. Describe how to stop the Ollama service with Ctrl-C in the terminal where it is running, then verify the stop by refreshing http://localhost:11434 and seeing that the browser cannot connect.
- Address already in use. Explain that an “address already in use” error means Ollama is already running, and describe how to stop the existing process before starting it again.
- Missing Ollama command. Describe what “command not found: ollama” means and the two fixes this section recommends.
- Browser connection failure. Explain how to check an “unable to connect” browser message, including when the desktop app may make a manual service start unnecessary.
What it builds on
- What is a large language model? (chapter 1) · The basic idea of a large language model.
- Cloud AI vs. local AI (chapter 1) · The distinction between cloud AI and local AI.
- When to use cloud AI vs. local AI (chapter 1) · The earlier discussion of when to use cloud AI versus local AI.
- Installing a package (chapter 2) · Prior experience installing a package with Homebrew.
- Upgrading installed packages (chapter 2) · The earlier introduction to upgrading installed packages with Homebrew.
Section by section
Introduction
Introduces Ollama as the tool for downloading and running large language models directly on a Mac, while previewing the chapter’s setup steps.
- Ollama’s local model role: Explain that Ollama is a program for downloading and running large language models directly on a Mac.
Why it matters: This identifies the tool you will use to run local AI models.
Key terms: Ollama, large language models (LLMs)
3.1 What is Ollama?
This section explains that Ollama runs AI models stored on your computer and gives you offline access to them.
- Ollama and model roles: Explain that Ollama is a runtime for downloading, managing, and running large language models, not the AI model itself. Describe how it makes a model file usable for tasks such as answering questions or generating text.
Why it matters: Separating the runtime from the model makes it clearer what you are installing and what you will later download. - Local offline model access: Distinguish Ollama’s access to models on your own computer from AI applications that connect to cloud-based models.
Why it matters: This distinction explains what makes using Ollama different from using a cloud AI app.
Key terms: Ollama, runtime, large language models, model file, offline access, open source models, cloud server, own hard drive
3.1.1 Why Ollama?
This section explains why Ollama is a practical choice for running local LLMs: simple commands, model management, Apple Silicon performance, code access, and privacy.
- Simple model operation and management: Describe how Ollama makes it straightforward to start using a model and manage several models.
Why it matters: These simple operations let you try local models without a complicated setup. - Apple Silicon response speed: Explain why the section presents Ollama as a good fit for modern Apple Silicon Macs.
Why it matters: It explains the performance benefit of choosing Ollama on a supported Mac. - Code access through Ollama: Explain what Ollama's API access makes possible for someone building an application.
Why it matters: Ollama is useful not just for running a model directly, but also for building software that uses it. - Local conversation privacy: Explain the privacy reason this section gives for choosing Ollama.
Why it matters: Keeping conversations on the laptop is a reason to choose local AI.
Key terms: ollama pull, ollama run, model management, Apple Silicon, M-series chips, API access, programming interface, Privacy
3.1.2 How Ollama works
Explains how Ollama waits for requests, generates responses on the Mac, and keeps that processing local.
- Ollama server and response flow: Trace what happens after Ollama starts and receives a question from the terminal or an API request from a Python script.
Why it matters: This explains why Ollama must be running to answer a terminal or Python request. - Local Ollama processing boundary: Explain where the Ollama components shown within “Your Mac” operate and whether their processing sends data over the internet.
Why it matters: This is the section’s basis for calling the depicted Ollama interaction local.
Key terms: server process, requests, model, CPU, GPU, Neural Engine, Your Mac, internet
3.2 Cloud AI vs. local AI with Ollama
The section contrasts cloud AI’s server-based data flow with local AI on your machine and explains why Ollama suits the book’s hands-on work.
- Cloud and local data flow: Explain that cloud AI sends a prompt over the internet to a provider’s server, whereas local AI keeps the prompt, model, and response on your own machine. Describe why the book favors local AI for learning and building close to the system.
Why it matters: This distinction explains why the book has you run AI locally with Ollama. - Complementary cloud and local uses: Distinguish the uses the section suggests for each option: cloud AI for tasks needing the most powerful models, and local AI for private work, experimentation, and application building.
Why it matters: Choosing local AI for this book does not mean cloud AI is never useful.
Key terms: cloud AI, local AI, prompt, model, response, private work, experimentation, application building
3.3 Installing Ollama
3.3.1 Step 1: Update Homebrew
3.3.2 Step 2: Install Ollama
This subsection describes installing Ollama with one command and explains why the book recommends Homebrew over the macOS desktop download.
- Ollama installation outcome: Describe what the installation accomplishes: one command puts an AI runtime on your computer, and the installation takes about 30 seconds.
Why it matters: This establishes what you have installed before you verify it or start the Ollama service. - Homebrew installation preference: Explain why the book recommends installing Ollama through Homebrew even though a macOS desktop application is available from ollama.com.
Why it matters: The recommendation helps you choose between two available installation methods.
Key terms: Ollama, AI runtime, installation command, Homebrew, macOS desktop application, brew upgrade ollama
3.3.3 Step 3: Verify the installation
This section presents a command-based check of the Ollama installation and an alternative way to view its details through Homebrew.
- Ollama installation checks: Describe the two checks presented for an Ollama installation: a verification command and a Homebrew details check. Do not require the exact commands or output, which are not included in the supplied text.
Why it matters: Checking the installation helps you confirm Ollama is in place before starting its service.
Key terms: Ollama installation, Homebrew
3.4 Starting the Ollama service
This section explains why the Ollama service must be running before a model can receive requests.
- Ollama service availability: Explain that Ollama runs as a foreground server in a terminal, waiting for requests, and must be started before you can interact with an AI model. State that it runs until you stop it or close the terminal.
Why it matters: This explains why a model cannot respond if the Ollama service is not running.
Key terms: Ollama service, foreground server process, requests
3.4.1 Starting the service
This subsection shows how to start the Ollama service, recognize that it is listening for requests, and keep it running while using another terminal window.
- Starting the Ollama service: Describe how to start Ollama with `ollama serve` and why other commands need a second terminal window while it runs.
Why it matters: Keeping the service running lets Ollama continue waiting for requests while you work elsewhere. - Local listening address: Explain what `listening on 127.0.0.1:11434` indicates, including the meanings of the address and port.
Why it matters: That output tells you the service is ready to receive requests on your computer.
Key terms: ollama serve, terminal window, Ollama service, listening on 127.0.0.1:11434, localhost, port number
3.4.2 Verifying the service
This section presents two ways to check Ollama and distinguishes binary access from a live service health check.
- Ollama service verification methods: Describe the terminal and browser checks, and explain what a successful result from each establishes.
Why it matters: These checks help you tell whether Ollama is accessible and whether its service is responding.
Key terms: Ollama binary, health check, service
3.4.3 What happens at startup
Explains the startup sequence when `ollama serve` begins accepting requests.
- Ollama startup sequence: Trace what Ollama does when `ollama serve` starts: it checks the available hardware and acceleration options, then opens a port to listen for requests.
Why it matters: This sequence explains what Ollama does before other programs can send it requests.
Key terms: ollama serve, GPU, Neural Engine, port 11434
3.4.4 Stopping the service
This section shows how to stop the Ollama service and confirm that it has stopped.
- Stopping and verifying Ollama: Describe how to stop the Ollama service with Ctrl-C in the terminal where it is running, then verify the stop by refreshing http://localhost:11434 and seeing that the browser cannot connect.
Why it matters: You can shut down Ollama and check that it is no longer serving requests.
Key terms: Ollama service, Ctrl-C, http://localhost:11434
3.4.5 Troubleshooting common problems
This section explains how to recognize and fix three common problems when starting or accessing Ollama.
- Address already in use: Explain that an “address already in use” error means Ollama is already running, and describe how to stop the existing process before starting it again.
Why it matters: This error may mean Ollama is already working, rather than that it failed to install. - Missing Ollama command: Describe what “command not found: ollama” means and the two fixes this section recommends.
Why it matters: These checks can restore access to the command without immediately reinstalling Ollama. - Browser connection failure: Explain how to check an “unable to connect” browser message, including when the desktop app may make a manual service start unnecessary.
Why it matters: Checking whether the service is running addresses the connection problem without confusing it with a missing command.
Key terms: address already in use, Activity Monitor, pkill ollama, command not found, brew link ollama, symbolic link, unable to connect, ollama serve, Ollama desktop app
3.5 Exercises
3.6 Summary
Where this is used later
- Downloading your first model (chapter 4) · Downloading the first model uses Ollama’s model-download capability.
- (chapter intro) (chapter 7) · The reader has been introduced to Ollama as a way to run local models.
- The model ecosystem (chapter 12) · Introduces Ollama as the tool for running local models.
- Running the pull command (chapter 4) · The reader downloads a first model with the pull command.
- Model management commands (chapter 4) · The reader manages downloaded models.
- Your first Ollama Python script (chapter 7) · The reader starts connecting a Python script to Ollama.
- Local AI data flow (chapter 14) · The reader examines local AI data flow in more detail.
- The simplest AI program (chapter 7) · A Python script sends requests to Ollama.
Concepts explained in this chapter
- OllamaOllama is a tool for downloading, running, and serving language models locally.
- ollama serveA command that starts the Ollama service and keeps it running while listening for requests.
- cloud-based AI serviceA service that provides AI capabilities through remotely operated servers.
- local aiLocal AI is artificial intelligence whose models or computations run on a user's own device rather than on remote infrastructure.
- large language modelA machine-learning model trained on large amounts of text to process and generate language.
- parameter countModel size is a measure of a language model's scale, commonly expressed by its number of learned parameters.
- GemmaGemma is a family of open language models developed by Google.
- LlamaA family of large language models developed by Meta.
- MistralA family of large language models developed by Mistral AI for natural-language processing and generation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
