Chapter 1: Getting started with local AI
The chapter introduction frames a private, Mac-based voice chat application, its high-level components, and the choice of Python for the project.
After this chapter you will be able to
- Voice chat application pipeline. Describe the application at a high level: speech is transcribed, a local language model produces a response, and a web interface presents the interaction.
- Local assistant privacy benefits. Explain why the introduction favors building a local assistant over relying solely on a hosted chatbot, particularly for private or sensitive uses.
- Text and voice privacy. Explain how running AI locally keeps typed input and voice audio on your computer, in contrast to sending input to a cloud service.
- Situational model tradeoffs. Explain why neither cloud nor local AI is always the better choice: local models are improving and narrowing the quality gap, while cloud models tend to be more current because providers update them continuously.
- Prompt travel boundary. Trace the basic prompt-and-response flow shared by cloud and local AI, and distinguish where the prompt goes in each case.
- Cloud and local AI choices. Distinguish situations that favor cloud AI from those that favor local AI, and explain why someone might use both.
- Local chat user experience. Describe how a person uses the finished app: open a local browser page, speak using the microphone or type a message, and receive a streaming text response offline.
- High-level voice response path. Trace, at a high level, how spoken input becomes a displayed answer: browser audio capture, MLX Whisper transcription, an Ollama LLM response, and streaming through Python to Streamlit.
- Mac requirements and specification check. State the minimum macOS, memory, and free-storage requirements, and describe where to check those specifications on a Mac.
- LLM Training and Learning. Explain that an LLM is trained on large amounts of text and that training adjusts internal numerical patterns rather than giving it human understanding.
- Text Prediction and Hallucinations. Describe how an LLM generates text piece by piece from learned word relationships, and explain why this can produce confident-sounding but inaccurate answers that should be checked.
- Terminal purpose and importance. Explain what the terminal is and why learning to use it comes first in this book.
- GUI and CLI interaction. Distinguish using a graphical user interface from using a command-line interface, and identify a terminal as the application that provides the text-based interface.
- Commands rather than natural language. Explain why typing at a terminal prompt differs from writing a prompt to an AI model.
- GUI and CLI comparison. Distinguish how the GUI and CLI communicate with the same operating system: the GUI uses pointing and clicking, while the CLI uses typed instructions. Explain that the command line is the standard interface for development tools used in the book.
- Practical command-line advantages. Explain how the CLI can provide speed, precision, automation, and portability compared with working through GUI menus.
- Text-based interface for AI agents. Explain why the CLI suits AI coding agents better than a GUI and how that makes CLI skills useful when working with an agent.
- Opening Terminal through Finder. Describe how to open Terminal using Finder, and state how this method compares with Spotlight for daily use.
- Terminal theme customization. Describe how to change the macOS Terminal app’s appearance by opening Terminal > Settings, selecting Profiles, and choosing a theme such as Pro. Explain that a dark background with light text can reduce eye strain during long sessions.
- Terminal command syntax conventions. Explain that terminal commands are case-sensitive, may include space-separated options or flags, and need quoted paths when folder or file names contain spaces.
- Current directory with pwd. Explain that typing `pwd` and pressing Enter displays your current location in the filesystem.
- Home directory path structure. Describe how `/Users/yourname` identifies a personal folder inside `Users` at the filesystem root.
- Current directory listing. Explain that `ls` lists the contents of the current directory and that familiar folders in its output are the same folders visible in Finder.
- Detailed and hidden listings. Explain what `ls -la` adds to a listing: `-l` shows file details, while `-a` includes hidden dot-prefixed items. Describe `-la` as two flags combined after one hyphen.
- Changing folders with cd. Explain that cd changes the current folder and must come before the folder path. Describe how to respond when a folder name is not found.
- Parent and home shortcuts. Distinguish cd .. from cd ~ or cd alone, and explain how ~ can be used within a path.
- Project folder setup. Describe how to create a folder with `mkdir`, verify that it was created, and move into it for the AI project.
- Command execution sequence. Trace what happens after you type `ls` and press Enter: the terminal passes the input to the shell, the program runs, its output appears, and a fresh prompt returns.
- Safety of basic commands. Explain why pwd, ls, cd, and mkdir are safe commands for a beginner to practice: they look around or create folders without deleting or overwriting existing content.
Section by section
Introduction
The chapter introduction frames a private, Mac-based voice chat application, its high-level components, and the choice of Python for the project.
- Voice chat application pipeline: Describe the application at a high level: speech is transcribed, a local language model produces a response, and a web interface presents the interaction.
Why it matters: This gives you a picture of what the separate tools will accomplish together. - Local assistant privacy benefits: Explain why the introduction favors building a local assistant over relying solely on a hosted chatbot, particularly for private or sensitive uses.
Why it matters: Keeping the interaction on your Mac is a central reason to build this assistant. - Python first Mac approach: Explain why this Mac-first project uses Python rather than Swift or SwiftUI.
Why it matters: The language choice supports an approachable, reproducible path to building the application.
Key terms: speech recognition, language model inference, live web interface, streaming AI response, local assistant, hosted chatbot, privacy, Mac-first, Python, Swift
1.1 Why run AI locally?
This section gives privacy, freedom, and hands-on understanding as reasons to run AI on your own computer rather than rely entirely on cloud services.
- Text and voice privacy: Explain how running AI locally keeps typed input and voice audio on your computer, in contrast to sending input to a cloud service.
Why it matters: Keeping both text and voice on your Mac is a central reason to choose local AI. - Control over local AI: Explain why running AI on your own computer gives you more control than depending on a cloud service.
Why it matters: A local setup reduces your dependence on a provider’s changing service. - Understanding through setup: Explain how setting up AI yourself differs from only using an existing cloud AI service.
Why it matters: Building a local setup can turn AI use into practical learning.
Key terms: Privacy, Voice privacy, cloud AI service, locally, Freedom, cloud AI services, Understanding, architect
1.1.1 Cloud AI vs. local AI
This section compares cloud and local AI by their model-quality and currency tradeoffs and by where a prompt travels.
- Situational model tradeoffs: Explain why neither cloud nor local AI is always the better choice: local models are improving and narrowing the quality gap, while cloud models tend to be more current because providers update them continuously.
Why it matters: These tradeoffs help you choose an approach for a particular project rather than assuming one is always best. - Prompt travel boundary: Trace the basic prompt-and-response flow shared by cloud and local AI, and distinguish where the prompt goes in each case.
Why it matters: Where the prompt travels is the fundamental boundary separating the two setups.
Key terms: cloud AI, local AI, quality gap, training cutoff date, prompt, external server
1.1.2 When to use cloud AI vs. local AI
This section explains when cloud or local AI is a better fit and why the book focuses on local AI.
- Cloud and local AI choices: Distinguish situations that favor cloud AI from those that favor local AI, and explain why someone might use both.
Why it matters: Choosing based on the task helps you use each approach where it fits best. - Local AI for learning: Explain why this book chooses local AI for its projects.
Why it matters: The book’s choice of local AI supports hands-on learning rather than claiming cloud AI has no uses.
Key terms: cloud AI, local AI, under the hood
1.2 The local chat application you will build
This section sketches the local voice-chat app’s user experience and the high-level path from spoken input to an AI response.
- Local chat user experience: Describe how a person uses the finished app: open a local browser page, speak using the microphone or type a message, and receive a streaming text response offline.
Why it matters: This is the experience the later application-building steps are working toward. - High-level voice response path: Trace, at a high level, how spoken input becomes a displayed answer: browser audio capture, MLX Whisper transcription, an Ollama LLM response, and streaming through Python to Streamlit.
Why it matters: The high-level path shows how the app’s separate pieces fit together without requiring their implementation details yet.
Key terms: voice-enabled local AI chat application, local URL, streaming text, Web Audio API, MLX Whisper, Ollama LLM, Python, Streamlit
1.3 What you’ll need
This section explains the Mac, memory, storage, connectivity, and background needed to follow the book, including what to expect from Apple Silicon and Intel Macs.
- Mac requirements and specification check: State the minimum macOS, memory, and free-storage requirements, and describe where to check those specifications on a Mac.
Why it matters: Checking these specifications helps you tell whether your Mac is ready before downloading large models. - Apple Silicon and Intel expectations: Distinguish why an M-series Mac is well suited to running AI models from what an Intel Mac can still do, including its limitations.
Why it matters: Your Mac’s chip affects performance and which model sizes are practical, not whether you can follow along at all. - Download access and Python preparation: Explain when an internet connection is needed and what Python background is helpful before the coding stages.
Why it matters: You can plan for downloads up front without assuming the finished local application always needs internet access.
Key terms: macOS Ventura (13), RAM, free disk space, About This Mac, M-series Apple Silicon, unified memory architecture, Neural Engine, Intel, MLX Whisper, stable internet connection
1.4 What is a large language model?
This section explains what an LLM is, how it produces text, why its answers need checking, and what prompts and APIs mean.
- LLM Training and Learning: Explain that an LLM is trained on large amounts of text and that training adjusts internal numerical patterns rather than giving it human understanding.
Why it matters: This gives you a grounded way to think about what the model has learned. - Text Prediction and Hallucinations: Describe how an LLM generates text piece by piece from learned word relationships, and explain why this can produce confident-sounding but inaccurate answers that should be checked.
Why it matters: Understanding prediction helps you use useful answers without assuming every confident answer is correct. - Common LLM Tasks: State several kinds of work an LLM can do, such as answering questions, summarizing, translating, and writing code.
Why it matters: These examples show why an LLM is useful beyond a simple question-and-answer chat. - Meaning of a Prompt: Explain that a prompt is the input given to an AI model and identify examples of what that input can be.
Why it matters: Knowing what counts as a prompt makes later examples of interacting with a model easier to follow. - Purpose of an API: Explain that an application programming interface is a way for one program to communicate with another.
Why it matters: This definition prepares you to recognize how an application can communicate with a local model.
Key terms: large language model (LLM), training, internal numerical patterns, relationships between words, predicts the most likely next word, hallucination, LLM, prompt, application programming interface (API)
1.5 Using the terminal to interact with your computer
Introduces the terminal as the text-based way to give the computer instructions and explains why it is the first skill needed for the book’s projects.
- Terminal purpose and importance: Explain what the terminal is and why learning to use it comes first in this book.
Why it matters: The terminal is the starting point for working with the tools used throughout the book.
Key terms: terminal, Ollama, Python, Streamlit
1.5.1 Two ways to talk to your computer
The section contrasts graphical and command-line interaction, introduces the macOS Terminal, and explains what its prompt means and what kind of input it expects.
- GUI and CLI interaction: Distinguish using a graphical user interface from using a command-line interface, and identify a terminal as the application that provides the text-based interface.
Why it matters: This distinction makes it clear why working in Terminal feels different from using familiar Mac windows and menus. - Terminal prompt components: Describe what the terminal prompt indicates and what its example username, computer name, home-directory marker, and prompt symbol represent.
Why it matters: Reading the prompt helps you recognize where you are and when the terminal is ready for a command. - Commands rather than natural language: Explain why typing at a terminal prompt differs from writing a prompt to an AI model.
Why it matters: This prevents you from expecting the terminal to interpret an everyday-language request as an AI model might.
Key terms: graphical user interface (GUI), command-line interface (CLI), terminal, prompt, username, computer’s name, home directory, prompt symbol, commands, natural language
1.5.2 CLI vs. GUI: A comparison
This section compares the GUI and CLI as two ways to communicate with the same operating system and explains why the CLI matters for development tools.
- GUI and CLI comparison: Distinguish how the GUI and CLI communicate with the same operating system: the GUI uses pointing and clicking, while the CLI uses typed instructions. Explain that the command line is the standard interface for development tools used in the book.
Why it matters: This explains why you will type commands even though you can also use a graphical interface on your Mac.
Key terms: GUI, CLI, operating system, command line
1.5.3 Why use the command line?
This section explains why the command line is useful for everyday development and why its text-based interface suits AI coding agents.
- Practical command-line advantages: Explain how the CLI can provide speed, precision, automation, and portability compared with working through GUI menus.
Why it matters: These advantages explain why the book uses the CLI for its development tools. - Text-based interface for AI agents: Explain why the CLI suits AI coding agents better than a GUI and how that makes CLI skills useful when working with an agent.
Why it matters: Learning the CLI also prepares you to collaborate with an agent on development tasks.
Key terms: CLI, speed, precision, automation, portability, AI coding agents, command line, text in, text out, GUI
1.6 Opening the terminal on macOS
This introduction frames the terminal as a tool used throughout the book and previews two ways to open it.
1.6.1 Method 1: Spotlight search (recommended)
1.6.2 Method 2: Applications folder
Shows how to open Terminal from the Applications folder and how to keep it in the Dock for frequent use.
- Opening Terminal through Finder: Describe how to open Terminal using Finder, and state how this method compares with Spotlight for daily use.
Why it matters: This gives you another way to open Terminal when you need it. - Keeping Terminal in Dock: Describe how to keep Terminal in the Dock if you expect to use it frequently.
Why it matters: Keeping its icon in the Dock makes Terminal easier to find again.
Key terms: Finder, Applications > Utilities, Terminal, Spotlight, Dock, Control-click, Options > Keep in Dock
1.6.3 Customizing the appearance
This subsection shows how to change the macOS Terminal app’s theme to make long sessions more comfortable.
- Terminal theme customization: Describe how to change the macOS Terminal app’s appearance by opening Terminal > Settings, selecting Profiles, and choosing a theme such as Pro. Explain that a dark background with light text can reduce eye strain during long sessions.
Why it matters: A comfortable Terminal theme can make longer sessions easier on your eyes.
Key terms: Terminal, Settings, Profiles, Pro
1.7 Essential commands
Introduces basic conventions for typing terminal commands before the individual commands are taught.
- Terminal command syntax conventions: Explain that terminal commands are case-sensitive, may include space-separated options or flags, and need quoted paths when folder or file names contain spaces.
Why it matters: These conventions help you type commands in a form the terminal can interpret.
Key terms: commands, options, flags, path
1.7.1 Where am I?
Introduces `pwd` for finding your current folder and explains how to read the displayed home-directory path.
- Current directory with pwd: Explain that typing `pwd` and pressing Enter displays your current location in the filesystem.
Why it matters: It gives you a quick way to check where you are before working with files and folders. - Home directory path structure: Describe how `/Users/yourname` identifies a personal folder inside `Users` at the filesystem root.
Why it matters: Reading the path helps you understand where your personal files are located.
Key terms: pwd, print working directory, directory, home directory, path, root, Users
1.7.2 What is here?
This section shows how to list the current directory’s contents and interpret several useful variations of the listing.
- Current directory listing: Explain that `ls` lists the contents of the current directory and that familiar folders in its output are the same folders visible in Finder.
Why it matters: It lets you check what files and folders are in your current location. - Detailed and hidden listings: Explain what `ls -la` adds to a listing: `-l` shows file details, while `-a` includes hidden dot-prefixed items. Describe `-la` as two flags combined after one hyphen.
Why it matters: These options help you reveal hidden items and inspect more information about listed files. - Dot entries and hidden files: Distinguish ordinary hidden dot-prefixed files and folders from the special `.` and `..` navigation entries.
Why it matters: It prevents you from mistaking navigation shortcuts for ordinary hidden files. - Optional listing display options: Describe how `-1` and `-p` alter the appearance of an `ls` listing without changing what is being listed.
Why it matters: These options can make a listing easier to scan without changing its contents.
Key terms: ls, current directory, home directory, Finder, ls -la, flag, option, long format, hidden files, .
1.7.3 Moving around
This subsection shows how to move between folders in the terminal and explains what clearing the screen does to earlier output.
- Changing folders with cd: Explain that cd changes the current folder and must come before the folder path. Describe how to respond when a folder name is not found.
Why it matters: Using cd with the exact folder name helps you reach the files you intend to work with. - Parent and home shortcuts: Distinguish cd .. from cd ~ or cd alone, and explain how ~ can be used within a path.
Why it matters: These shortcuts let you navigate without repeatedly typing full folder paths. - Clearing visible terminal output: Explain what happens to earlier output when the terminal screen is cleared.
Why it matters: You can tidy a cluttered terminal without losing the output you just saw.
Key terms: cd, change directory, path, ls, parent directory, cd .., cd ~, home directory, ~, clearing the terminal screen
1.7.4 Creating folders
This section introduces creating a project folder in the terminal, checking that it exists, and moving into it as a workspace for the book.
- Project folder setup: Describe how to create a folder with `mkdir`, verify that it was created, and move into it for the AI project.
Why it matters: The project folder gives your work a place to live as you build the application.
Key terms: mkdir, directory, folder
1.7.5 What happens when you type a command
This section traces what happens when a terminal command runs, explains how the shell finds its program, and shows how to interrupt a command that is still running.
- Command execution sequence: Trace what happens after you type `ls` and press Enter: the terminal passes the input to the shell, the program runs, its output appears, and a fresh prompt returns.
Why it matters: This sequence makes a command’s output and the return of the prompt easier to interpret. - Shell and PATH roles: Distinguish the terminal window from the shell running inside it, and explain that the shell searches the directories in PATH to find the program named by a command.
Why it matters: It clarifies why typing a command name can start a program without specifying its location. - Running command interruption: Explain why an unresponsive-looking command might still be running and how Ctrl-C can stop it.
Why it matters: It gives you a way to regain control when a command appears stuck.
Key terms: command, ls, output, prompt, terminal, shell, Zsh, PATH, Ctrl-C, interrupt signal
1.7.6 Common fears and realities
Reassures beginners that the four terminal commands taught so far will not delete or overwrite their files.
- Safety of basic commands: Explain why pwd, ls, cd, and mkdir are safe commands for a beginner to practice: they look around or create folders without deleting or overwriting existing content.
Why it matters: You can practice these first terminal commands without worrying that they will erase your files.
Key terms: pwd, ls, cd, mkdir
1.8 Exercises
1.9 Summary
Where this is used later
- The voice AI pipeline (chapter 10) · The voice AI pipeline is developed in detail.
- Local AI data flow (chapter 14) · The book examines the local AI data flow behind the privacy claim.
- The simplest AI program (chapter 7) · The reader begins implementing AI interactions in a Python script.
- The hidden cost: Dependency (chapter 14) · The discussion of dependency expands on the risk of relying on a cloud provider.
- What is Ollama? (chapter 3) · The distinction between cloud AI and local AI.
- Why Ollama? (chapter 3) · The distinction between cloud and local AI.
- Cloud AI vs. local AI with Ollama (chapter 3) · The earlier introduction to cloud AI versus local AI.
- Cloud AI data flow (chapter 14) · Provides the basic cloud-side data flow for the later privacy analysis.
Concepts explained in this chapter
- TerminalTerminal is the macOS application for accessing a command-line interface.
- large language modelA machine-learning model trained on large amounts of text to process and generate language.
- command-line interfaceA command-line interface is an interaction interface in which users operate software by entering textual commands.
- local AI chat applicationThe book's locally run, voice-enabled chat application transcribes speech and returns AI responses.
- lsA command-line utility that lists the contents of a directory.
- 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.
- speech recognitionThe conversion of spoken audio into written text.
- privacyPrivacy is the protection of a person's information from unauthorized collection, retention, use, or disclosure.
- cd commandA command that changes the current working directory.
- MLX WhisperMLX Whisper is a speech-recognition implementation based on Whisper and optimized for Apple Silicon through MLX.
- OllamaOllama is a tool for downloading, running, and serving language models locally.
- PythonA high-level general-purpose programming language known for readable syntax and a broad software ecosystem.
- StreamlitStreamlit is a Python framework for creating interactive web applications from Python code.
- inferenceModel inference is the process of applying a trained model to input data to produce an output.
- pipelineA sequence of processing stages in which each stage feeds its output to the next.
- command search pathAn environment variable containing directories searched to locate executable commands.
- pwdA command that prints the path of the current working directory.
- HomebrewHomebrew is a package manager for installing and managing software on macOS and other Unix-like systems.
- Visual Studio CodeA source-code editor developed by Microsoft with extensibility for programming workflows.
- promptAn input instruction or request submitted to an AI model for processing.
- home directoryA filesystem directory assigned to a user for storing personal files and configuration data.
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.
