Practice 1 — First contact with `ollama run`
Duration: ~10 min Prerequisites: chapter 06 (Ollama installed and running)
This is the simplest possible interaction with a local LLM: one command, a chat in your terminal, end of story. The next three practices build on it. Together they make sure you have felt Ollama in your fingers before any Python code enters the picture.
Why no Python yet
Section titled “Why no Python yet”The demos in chapter 07 and beyond all wrap Ollama in Python. Before learning a wrapper, you should know what is being wrapped. Five extra minutes spent talking to Ollama directly — with nothing in between — make every demo afterwards make more sense.
What you will do
Section titled “What you will do”- Open a terminal.
- Run a single command.
- Have a real conversation with the model.
- Exit cleanly.
That is the entire practice. No file to edit, no project to clone.
Step 1 — Open a fresh PowerShell window
Section titled “Step 1 — Open a fresh PowerShell window”# Windows: search "PowerShell 7" in the Start menu# macOS: open Terminal# Linux: open your favourite terminalYou do not need to be in a specific directory. Any working directory is fine.
Step 2 — Start the model in interactive mode
Section titled “Step 2 — Start the model in interactive mode”ollama run llama3.1:8bWhat this command does, in plain words:
- if the model
llama3.1:8bis not yet downloaded, it downloads it first (~4.7 GB, one-time); - if it is already there, it loads it into memory (RAM or VRAM, see annex 05e);
- it gives you a
>>>prompt where you can type.
The first run may take 3 to 8 minutes depending on your bandwidth. Subsequent runs are nearly instant (a few seconds to load weights).
Step 3 — Have a real conversation
Section titled “Step 3 — Have a real conversation”Type a question after the >>> prompt. Press Enter. Watch the model answer token by token (you can see the words appearing one at a time — that is streaming in action).
Try this sequence:
>>> Hello, who are you?I am Llama 3.1, an AI assistant trained by Meta...
>>> What did I just ask you?You asked me who I am. I am Llama 3.1...
>>> And before that?You first greeted me and asked who I am, and then you asked me to recall...Notice two things:
- The model remembers the previous turns. The full conversation history is kept in memory inside the
ollama runsession. - The streaming is real. The text appears progressively, not all at once. This is the same streaming you will see in demo 0 written in Python.
Step 4 — Try the limits we discussed in chapter 02
Section titled “Step 4 — Try the limits we discussed in chapter 02”This is the moment to feel in the body what chapter 02 (what an LLM cannot do) was about.
>>> What is today's date?I do not have real-time access to today's date...
>>> Compute 17 multiplied by 234 step by step.[the model may produce 3978 (correct) or a confidently wrong number]
>>> What is the weather in Paris right now?I do not have real-time access to weather data...The model is helpful and reasonable, but it has no clock, no calculator, and no internet. These are exactly the gaps that tools (chapter 03) and agents (demos 3 and 4) will fill.
Step 5 — Exit cleanly
Section titled “Step 5 — Exit cleanly”>>> /byeOr Ctrl+D on Linux/macOS, Ctrl+C once on Windows.
The >>> prompt closes and you are back in PowerShell. The model is unloaded from memory.
What you just proved
Section titled “What you just proved”Without a single line of Python:
- Ollama is a complete chat REPL on its own. You did not need a UI, a framework, or a wrapper to talk to a local LLM.
- A conversation is just a sequence of turns the model receives and answers, one at a time.
- The model has built-in memory inside one session but no external knowledge of today’s world.
- Streaming is the default user experience, not a feature you add later.
When demo 0 wraps this same primitive in 50 lines of Python in chapter 07, you will recognise everything that happens — because you have already done it here, by hand, in a terminal.
Quick troubleshooting
Section titled “Quick troubleshooting”| Symptom | Likely cause | Fix |
|---|---|---|
Error: could not connect to ollama app, is it running? | Ollama service not started | Open Ollama from the Start menu (Windows) or run ollama serve |
Error: model 'llama3.1:8b' not found | Model not pulled | The ollama run command should auto-pull. If not: ollama pull llama3.1:8b |
>>> prompt freezes mid-reply | Out of memory (model bigger than RAM/VRAM) | Try a smaller model: ollama run gemma3:4b — see practice 3 |
| Replies are nonsense or repetitive | Sampling parameters degraded a prior run | Just exit (/bye) and re-enter — parameters reset to defaults |
Next: explore the control panel
Section titled “Next: explore the control panel”You have used ollama run in its simplest mode. The same >>> prompt accepts slash commands that let you inspect the model and tweak its behaviour live. That is the next practice.