The chapter introduction frames a private, Mac-based voice chat application, its high-level components, and the choice of Python for the project.
1.1 Why run AI locally? · 1.1.1 Cloud AI vs. local AI · 1.1.2 When to use cloud AI vs. local AI · 1.2 The local chat application you will build · 1.3 What you’ll need · 1.4 What is a large language model? · 1.5 Using the terminal to interact with your computer · 1.5.1 Two ways to talk to your computer · 1.5.2 CLI vs. GUI: A comparison · 1.5.3 Why use the command line? · 1.6 Opening the terminal on macOS · 1.6.1 Method 1: Spotlight search (recommended) · 1.6.2 Method 2: Applications folder · 1.6.3 Customizing the appearance · 1.7 Essential commands · 1.7.1 Where am I? · 1.7.2 What is here? · 1.7.3 Moving around · 1.7.4 Creating folders · 1.7.5 What happens when you type a command · 1.7.6 Common fears and realities · 1.8 Exercises · 1.9 Summary
Introduces Ollama as the tool for downloading and running large language models directly on a Mac, while previewing the chapter’s setup steps.
3.1 What is Ollama? · 3.1.1 Why Ollama? · 3.1.2 How Ollama works · 3.2 Cloud AI vs. local AI with Ollama · 3.3 Installing Ollama · 3.3.1 Step 1: Update Homebrew · 3.3.2 Step 2: Install Ollama · 3.3.3 Step 3: Verify the installation · 3.4 Starting the Ollama service · 3.4.1 Starting the service · 3.4.2 Verifying the service · 3.4.3 What happens at startup · 3.4.4 Stopping the service · 3.4.5 Troubleshooting common problems · 3.5 Exercises · 3.6 Summary
The introduction establishes that Ollama is running but still needs a model, and tells the reader to keep the service running while using a second terminal for the chapter’s commands.
4.1 Downloading your first model · 4.1.1 Choosing a starting model · 4.1.2 Running the pull command · 4.1.3 Understanding the model name format · 4.2 Interactive chat · 4.2.1 Starting interactive chat mode · 4.2.2 A sample conversation · 4.2.3 Exiting chat mode · 4.3 Understanding model sizes and parameters · 4.3.1 What are parameters? · 4.3.2 The size, capability, and memory tradeoff · 4.3.3 What “quantization” means · 4.4 Model comparison: Choosing the right model · 4.4.1 The major model families · 4.4.2 Downloading a second model · 4.4.3 A quick model comparison test · 4.5 Model management commands · 4.5.1 Listing downloaded models · 4.5.2 Checking running models · 4.5.3 Viewing model details · 4.5.4 Removing a model · 4.6 Exercises · 4.7 Summary
The chapter introduction explains why building an AI application requires moving beyond terminal chats to Python code and a code editor.
5.1 What is VS Code? · 5.2 Installing VS Code · 5.2.1 Step 1: Install with Homebrew · 5.2.2 Step 2: Verify the installation · 5.2.3 Step 3: Open VS Code · 5.3 Installing Python 3.13 · 5.4 Installing the Python extension · 5.4.1 Installation steps · 5.4.2 What you will see in practice · 5.5 Using the integrated terminal · 5.5.1 Opening the terminal · 5.5.2 Verifying your tools · 5.6 Creating your project folder · 5.6.1 Setting up the workspace · 5.6.2 Creating and running your first file · 5.6.3 Project structure preview · 5.7 Exercises · 5.8 Summary
Introduces Python packages as reusable code and explains why virtual environments are a foundational practice before installing packages for the chatbot project.
6.1 Why virtual environments matter · 6.2 Creating a virtual environment · 6.2.1 Navigate to your project folder · 6.2.2 Create the virtual environment · 6.2.3 Understanding the venv command · 6.2.4 What is inside the venv folder? · 6.3 Activating and deactivating a virtual environment · 6.3.1 Activating the virtual environment · 6.3.2 Verifying activation · 6.3.3 Deactivating the virtual environment · 6.4 Installing packages with pip · 6.4.1 What is pip? · 6.4.2 Installing the Ollama Python package · 6.4.3 Installing Streamlit · 6.4.4 Checking the installed packages · 6.5 Freezing and restoring dependencies · 6.5.1 Creating the requirements.txt file · 6.5.2 Restoring an environment from requirements.txt · 6.5.3 Keeping requirements.txt updated · 6.5.4 The complete virtual environment workflow · 6.6 Exercises · 6.7 Summary
The chapter introduces Python control of a local LLM and gives the checks needed before running its scripts.
7.1 Your first Ollama Python script · 7.1.1 The simplest AI program · 7.1.2 Breaking down the code · 7.2 Understanding the message format · 7.2.1 The three LLM message roles · 7.2.2 Adding a system message · 7.2.3 Experimenting with different system messages · 7.3 Streaming responses for real-time output · 7.3.1 The problem with waiting for the model’s response · 7.3.2 Implementing streaming · 7.3.3 Understanding the code · 7.3.4 The streaming communication flow · 7.4 Maintaining conversation history · 7.4.1 The LLM’s memory problem · 7.4.2 Building a conversation loop · 7.4.3 Running the conversation · 7.4.4 How the history list grows · 7.4.5 The complete conversation flow · 7.5 Exercises · 7.6 Summary
This introduction previews adding microphone recording and speech transcription to the existing text-based AI application as a foundation for a voice-enabled chatbot.
9.1 What is speech recognition? · 9.2 Why use MLX Whisper on Apple silicon? · 9.3 Installing MLX Whisper · 9.4 Understanding digital audio · 9.4.1 Audio sample rate · 9.4.2 Audio channels · 9.4.3 Sample bit depth and data type · 9.5 Recording from the microphone · 9.5.1 sd.rec(): The recording call · 9.5.2 Squeezing the channel dimension · 9.5.3 Converting to int16 for WAV · 9.6 Your first transcription · 9.7 Choosing the right Whisper model · 9.7.1 Which model should you use? · 9.7.2 Trying a larger model · 9.8 Building a reusable transcription script · 9.9 Troubleshooting · 9.9.1 “No default input device” · 9.9.2 Audio is captured but Whisper returns empty text · 9.9.3 “Cannot import mlx_whisper” · 9.9.4 The first download is slow · 9.9.5 “File not found” for ffmpeg · 9.10 Exercises · 9.11 Summary
The introduction explains why a local voice chat app is more complex than a text chatbot: it connects audio capture, speech recognition, and language model inference in a pipeline.
10.1 The voice AI pipeline · 10.2 Setting up the voice chat application project · 10.3 Building the application step by step · 10.3.1 Stage 1: Transcription in Streamlit · 10.3.2 Why use a temporary WAV file? · 10.3.3 Stage 2: Connecting transcription to the LLM · 10.3.4 Stage 3: The complete application · 10.4 The complete voice chat application · 10.4.1 Running the application · 10.4.2 Updating the Ollama model menu · 10.5 Understanding the complete voice chat application code · 10.5.1 Browser page configuration · 10.5.2 The sidebar: Controlling two models · 10.5.3 transcribe_audio(): The bridge between Streamlit and MLX Whisper · 10.5.4 stream_response(): A reusable streaming function · 10.5.5 handle_user_message(): The unified entry point · 10.5.6 Dual input: Voice and text · 10.6 Running and testing the application · 10.6.1 Startup checklist · 10.6.2 Testing checklist · 10.6.3 Troubleshooting · 10.7 Understanding the latency budget · 10.8 Exercises · 10.9 Summary
The introduction identifies the context-window limit as a reason a long chatbot conversation may become slower and less coherent.
11.1 The problem: LLMs are stateless · 11.2 Understanding Streamlit session state · 11.2.1 The script rerun problem · 11.2.2 Session state in action · 11.2.3 What you can store in session state · 11.2.4 When session state resets · 11.3 How LLMs use conversation history · 11.4 Context window management · 11.4.1 What happens when you exceed the context window · 11.4.2 Implementing history trimming · 11.4.3 The limited history tradeoff · 11.5 Adding a reset button · 11.6 Other useful session state patterns · 11.7 The complete chat application data flow · 11.8 Exercises · 11.9 Summary
Introduces the challenge of choosing among Ollama models and gives a way to check current model availability before selecting one.
12.1 Model families and their strengths · 12.1.1 Llama (Meta) · 12.1.2 Gemma (Google) · 12.1.3 Qwen (Alibaba Cloud) · 12.1.4 Mistral (Mistral AI) · 12.1.5 DeepSeek (DeepSeek AI) · 12.1.6 The model ecosystem · 12.2 Model size vs. quality tradeoffs · 12.2.1 Model comparison quick reference · 12.2.2 Understanding tokens per second · 12.2.3 Benchmarks: What they tell you (and what they don’t) · 12.2.4 The RAM reality check · 12.3 Multilingual capabilities · 12.3.1 Language strengths by model family · 12.3.2 A side-by-side experiment · 12.3.3 Multilingual recommendation summary · 12.4 Switching models in your chatbot · 12.4.1 Step 1: Download the new model · 12.4.2 Step 2: Change one line of chat application code · 12.4.3 Step 3: Add a Model Selector in the Streamlit UI · 12.4.4 Managing your model collection · 12.4.5 A quick model comparison script · 12.5 The 2026 revolution: Frontier open models · 12.5.1 The mixture of experts revolution · 12.5.2 Model 1: Zhipu GLM-5 · 12.5.3 Model 2: Alibaba Qwen3-Coder-Next · 12.5.4 Model 3: MiniMax M2.5 · 12.5.5 The February 2026 benchmark landscape · 12.5.6 The new model comparison table · 12.5.7 What this means for you · 12.6 Exercises · 12.7 Summary
Introduces the chatbot’s current generic behavior and previews ways the chapter will customize its personality and response style.
13.1 System prompts explained · 13.2 Example system prompts: Personality presets · 13.2.1 Preset 1: The professional consultant · 13.2.2 Preset 2: The patient study buddy · 13.2.3 Preset 3: The pirate tutor · 13.2.4 Preset 4: The strict coding mentor · 13.2.5 Preset 5: The concise expert · 13.3 LLM temperature and creative parameters · 13.3.1 What temperature does · 13.3.2 Other important parameters · 13.4 Creating custom models with Ollama Modelfiles · 13.4.1 The Modelfile format · 13.4.2 Key Modelfile instructions · 13.4.3 Building a custom model step by step · 13.4.4 Managing custom models · 13.5 Adding customization controls to the Streamlit UI · 13.5.1 The enhanced chatbot · 13.5.2 How the system prompt affects the pipeline · 13.6 Exercises · 13.7 Summary
The introduction establishes that the Ollama-based chatbot works at full capability without internet access and previews the chapter’s examination of why that matters.
14.1 Verifying offline chatbot operation: The airplane mode test · 14.2 AI privacy and security analysis · 14.2.1 Cloud AI data flow · 14.2.2 Local AI data flow · 14.2.3 Why privacy matters: Concrete scenarios · 14.3 AI cost analysis · 14.3.1 Cloud AI costs · 14.3.2 Local AI costs · 14.3.3 The hidden cost: Dependency · 14.3.4 When cloud AI is worth the cost · 14.3.5 The long-term perspective on costs · 14.4 Use cases where local AI excels · 14.4.1 Healthcare · 14.4.2 Legal practice · 14.4.3 Education · 14.4.4 Creative work · 14.4.5 Journalism and research · 14.4.6 Personal finance and mental health · 14.4.7 Enterprise and corporate use · 14.4.8 Offline and remote environments · 14.4.9 Use case decision framework · 14.5 Exercises · 14.6 Summary
This introduction reframes programming errors as useful diagnostic information and emphasizes diagnosing and fixing them rather than avoiding them.
15.1 Common errors and solutions · 15.1.1 Error: Model not found · 15.1.2 Error: Connection refused · 15.1.3 Error: Out of memory · 15.1.4 Error: Port already in use · 15.1.5 Error: Streamlit ModuleNotFoundError · 15.1.6 Error: Python version problems · 15.2 Reading error messages effectively · 15.3 Debugging techniques · 15.3.1 Using try/except blocks · 15.3.2 Step-by-step verification · 15.3.3 Print debugging · 15.3.4 Logging · 15.4 The troubleshooting roadmap · 15.4.1 Four levels of troubleshooting · 15.4.2 A note on asking for help · 15.5 Exercises · 15.6 Summary
The chapter introduces advanced directions that build on the existing chatbot, including RAG, Open WebUI, agents, and fine-tuning.
16.1 RAG: Retrieval-augmented generation · 16.1.1 What is RAG? · 16.1.2 How vectors and embeddings work · 16.1.3 A simple RAG implementation · 16.1.4 Loading real documents for RAG · 16.2 Using Open WebUI for a ChatGPT-like experience · 16.2.1 Using Open WebUI with Docker · 16.2.2 Key features of Open WebUI · 16.3 Custom model creation with Modelfiles · 16.3.1 Creating a Modelfile · 16.3.2 Advanced Modelfile options · 16.4 LangChain integration · 16.4.1 Installing LangChain · 16.4.2 Basic LangChain with Ollama · 16.4.3 Creating a chain · 16.4.4 Why LangChain matters · 16.5 Agentic AI patterns · 16.5.1 A simple agent concept · 16.5.2 The agent pattern: Evaluate and act · 16.5.3 Real-world agent use cases · 16.5.4 OpenClaw: The autonomous agent that drew major GitHub attention · 16.5.5 PicoClaw: An agent that fits in your pocket · 16.5.6 The API cost revolution: Why open models matter for agents · 16.6 Fine-tuning overview · 16.6.1 When to fine-tune (and when not to) · 16.6.2 The GGUF format for quantized models · 16.6.3 Fine-tuning workflow (high level) · 16.6.4 Unsloth: The fine-tuning accelerator · 16.6.5 GGUF quantization deep dive · 16.7 Project ideas and learning resources · 16.7.1 Ten project ideas · 16.7.2 Learning resources · 16.8 Exercises · 16.9 Summary
The introduction frames February 2026 as a turning point when several open-source AI models matched or exceeded leading proprietary systems.
17.1 February 2026: A turning point · 17.2 GLM-5 · 17.2.1 Architecture · 17.2.2 Trained on Huawei chips · 17.2.3 Benchmark results · 17.2.4 License · 17.3 Qwen3-Coder-Next · 17.3.1 Ultra-Sparse MoE architecture · 17.3.2 Coding agent focus · 17.4 MiniMax M2.5 · 17.4.1 SWE-bench parity · 17.4.2 Cost advantage · 17.5 The benchmark picture · 17.6 The economics of open models · 17.6.1 Agent cost analysis · 17.6.2 Why local agents change what is possible · 17.7 The Unsloth-to-Ollama pipeline · 17.7.1 The complete custom model workflow · 17.7.2 Why customization matters now · 17.8 What this means for you · 17.8.1 How to try these models · 17.8.2 Practical next steps · 17.9 Further learning · 17.10 Beyond individual models: The rise of orchestration · 17.11 Exercises · 17.12 Summary
The introduction marks the reader’s progress from basic programming to a local AI chatbot and frames choosing a next project as the first step forward.
18.1 What you have accomplished · 18.2 Your learning roadmap · 18.2.1 Level 1: Foundation (what this book covered) · 18.2.2 Level 2: Intermediate (the next 3–6 months) · 18.2.3 Level 3: Advanced (6–12+ months) · 18.3 Final thoughts · 18.4 Exercises
fine-tuningFine-tuning is the process of further training a pretrained model on selected examples to adapt its behavior or capabilities.
retrieval-augmented generationRetrieval-augmented generation is a technique that retrieves relevant information from an external knowledge source and supplies it to a language model alongside a question or instruction.
GGUFA file format for storing machine-learning model tensors and metadata for inference, including quantized models.
PythonA high-level general-purpose programming language known for readable syntax and a broad software ecosystem.
command-line interfaceA command-line interface is an interaction interface in which users operate software by entering textual commands.
LangChainLangChain is a software framework for building applications with language models by connecting them to data sources and composable components.
parameter countModel size is a measure of a language model's scale, commonly expressed by its number of learned parameters.
local AI chat applicationThe book's locally run, voice-enabled chat application transcribes speech and returns AI responses.
mixture of expertsA neural network architecture that routes inputs through selected expert subnetworks rather than activating every parameter for every input.
context windowContext length is the maximum number of tokens a language model can consider at once.
session contextSession state is application data associated with a user's session and retained across interactions or reruns.
Open WebUIOpen WebUI is an open-source web interface for interacting with locally hosted language models and related services.
privacyPrivacy is the protection of a person's information from unauthorized collection, retention, use, or disclosure.
temperatureA language-model generation setting that controls the randomness of token selection.
inferenceModel inference is the process of applying a trained model to input data to produce an output.
AI agentAn AI agent is a software system that perceives information, reasons about tasks, and takes actions to accomplish goals, including software-development tasks.
Visual Studio CodeA source-code editor developed by Microsoft with extensibility for programming workflows.
cloud-based AI serviceA service that provides AI capabilities through remotely operated servers.
mlx_whisper.transcribeAn MLX Whisper function that transcribes audio from a file path or audio array.
airplane mode testAn airplane mode test is a procedure that verifies whether an application continues operating when a device has no network connectivity.
isolationThe separation of a project's packages and runtime from those of other projects or the host system.
costThe monetary expense of operating an AI system, including service charges and local operating expenses.
cd commandA command that changes the current working directory.
UnslothA software library that accelerates and streamlines fine-tuning of language models while aiming to reduce memory use.
MistralA family of large language models developed by Mistral AI for natural-language processing and generation.
embeddingAn embedding is a numerical vector representation of an item, such as text, positioned to capture aspects of its meaning or features.
requirements.txtA requirements.txt file is a dependency specification file that lists packages and the versions required by a Python project.
ollama.chat()A function in the Ollama Python library that sends conversational messages to a specified model and returns its response.
package managerA software tool that installs, updates, removes, and manages software packages and their dependencies.
web applicationAn application whose user interface and functionality are delivered through a web browser.
vector databaseA vector database stores vector representations and supports searching for vectors that are similar or close to a query vector.
ollama serveA command that starts the Ollama service and keeps it running while listening for requests.
macOSApple's desktop operating system for Mac computers.
stack traceA Python diagnostic report showing the sequence of calls leading to an exception and where it occurred.
QwenQwen is a family of language models developed by Alibaba Cloud.
model familyA group of related language models that share a common architecture, training lineage, or design.
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.
dialogueThe example chatbot's ordered exchange of messages between a user and an AI assistant.
Chroma DBChromaDB is an open-source vector database for storing, querying, and managing embeddings and associated data.
ollama listAn Ollama command that lists the models available locally.
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.