1 Building Your Own AI — Getting Started
This opening chapter introduces the book’s overall goal: helping you build a private, voice-enabled AI chat application that runs entirely on your Mac. The finished app will let you speak into a microphone, transcribe your voice locally, send the text to a local language model, and display a streaming response in a web interface. The main tools are macOS Terminal, Homebrew, VS Code, Python, Ollama, MLX Whisper, and Streamlit, with Python chosen because it is practical, beginner-friendly, and well supported by today’s local AI ecosystem.
The chapter explains why running AI locally is valuable, especially for privacy, voice privacy, offline access, cost control, customization, and learning. Cloud AI can offer more powerful and current models, but it sends prompts and possibly sensitive data to external servers. Local AI keeps prompts, voice recordings, transcripts, and responses on your machine, making it well suited for personal assistants, private note-taking, workplace prototypes, and experiments where you want control. The chapter also introduces large language models as systems trained on huge amounts of text that generate responses by predicting likely next words, while cautioning that they can produce confident but inaccurate answers.
The final part prepares you for hands-on work by introducing the terminal as the essential interface for installing tools, running Python scripts, launching Ollama, and starting the web app. It contrasts graphical interfaces with command-line interfaces and explains why developers use the command line for speed, precision, automation, portability, and compatibility with modern AI coding agents. You learn how to open Terminal on macOS, recognize the prompt, understand the role of the shell, and practice safe foundational commands such as pwd, ls, cd, and mkdir. The chapter closes by reassuring beginners that basic navigation commands are safe, errors are normal feedback, and these first CLI skills form the foundation for the rest of the book.
Cloud AI (right) sends your prompt across the internet to a hosted inference service, and your data may be stored on the company's servers. Local AI (left) keeps the prompt, the model, and the response inside your machine -- no network hop, no external server, no data leaving your control.
Overview of the voice chat application. Your Mac runs three pieces locally: a Streamlit web app in the browser captures your voice and renders the chat, MLX Whisper transcribes your speech to text, and Ollama runs the LLM that generates the streaming reply. The dashed boundary marks "your machine" -- nothing crosses it.
The GUI and the CLI offer different features, but both communicate with the computer's operating system. Clicking in the GUI and typing in the CLI ultimately reach the same destination.
Exercises
- Navigate your home directory. Open the terminal and use pwd to confirm you are in your home directory. Use ls to see all your folders. Navigate into Documents using cd Documents, list its contents, and return home using cd ~.
- Create a project structure. Starting from your home directory, create the following folder structure using only mkdir and cd:
- After creating each folder, use pwd to verify your location and ls to confirm the folder was created.
- Explore hidden files. Run ls -la in your home directory. Count how many hidden files and folders (those starting with .) you see. Pick one and guess what it might be for.
- Speed comparison. Time yourself performing these tasks, first using Finder, then using the terminal:
- Navigate to your Documents folder
- Create a new folder called test_folder
- Go inside the new folder
- Go back to your home directory
- Practice `clear` and `cd`. Navigate to three different folders (Desktop, Documents, Downloads), run ls in each one, then use clear to clean the screen. Finally, return home with cd ~ and run pwd to confirm.
- Reflect on your AI use. Think about the last three times you used a cloud AI service (ChatGPT, Gemini, Claude, or similar). For each interaction, consider: Did it contain private information? Did you need an internet connection? Could a local model have handled the task? Write down your answers. You will revisit this reflection after completing Chapter 4.
FAQ
What application will I build in this book?
You will build a voice-enabled local AI chat application that runs entirely on your Mac. You will speak into your microphone, have your voice transcribed into text, and receive a streaming AI response through a web interface. The finished app can also accept typed input.
Which tools does the project use?
The main path uses macOS, Terminal, Homebrew, VS Code, Python, Ollama, MLX Whisper, and Streamlit. Ollama runs local language models, MLX Whisper transcribes speech locally, Python connects the pieces, VS Code is used for editing code, and Streamlit provides the web interface.
Why run AI locally instead of using a hosted chatbot?
Local AI keeps your data on your own machine, works offline after setup, avoids subscription fees, and gives you more control over model selection and behavior. For a voice application, local AI is especially valuable because your audio never leaves your Mac.
How does local AI compare with cloud AI?
Cloud AI often provides the most powerful and current models, but your prompts are sent to company servers and an internet connection is required. Local AI runs on your own computer, keeps data private, works offline, and gives you full control, though models may be smaller and frozen at their training cutoff date.
When should I use cloud AI, and when should I use local AI?
Use cloud AI when you need top-quality complex reasoning, real-time information, the latest models, and the content is not sensitive. Use local AI when privacy matters, you want to work offline, you want full control, you want to avoid subscriptions, or you want to understand how AI works under the hood.
What hardware and software do I need?
You need a recent Mac running macOS Ventura 13 or later, at least 8 GB of RAM, and at least 20 GB of free disk space. Apple Silicon Macs such as M1 or later are ideal because they are efficient for AI workloads, but Intel Macs can still follow along with smaller models and slower performance.
What is a large language model?
A large language model, or LLM, is an AI model trained on enormous amounts of text. It generates responses by predicting the most likely next word or piece of text, one step at a time. Because it predicts from patterns rather than truly understanding like a human, it can sometimes produce confident but inaccurate answers called hallucinations.
What is the difference between a GUI and a CLI?
A GUI, or Graphical User Interface, lets you interact with your computer visually by clicking icons, folders, buttons, and menus. A CLI, or Command Line Interface, lets you interact by typing commands into a terminal. Both communicate with the same operating system, but the CLI is especially important for development tools.
How do I open Terminal on macOS?
The recommended method is to press Command + Space to open Spotlight Search, type Terminal, and press Enter. You can also open Finder and go to Applications > Utilities > Terminal.
What basic terminal commands are introduced in this chapter?
The chapter introduces four essential commands: pwd shows your current location, ls lists files and folders, cd changes directories, and mkdir creates a new folder. It also introduces clear, which gives the terminal a clean visual slate without deleting previous output.
Build Applications with Local AI Models on a Mac ebook for free