Skip to content

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.

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.

  1. Open a terminal.
  2. Run a single command.
  3. Have a real conversation with the model.
  4. Exit cleanly.

That is the entire practice. No file to edit, no project to clone.

Terminal window
# Windows: search "PowerShell 7" in the Start menu
# macOS: open Terminal
# Linux: open your favourite terminal

You 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”
Terminal window
ollama run llama3.1:8b

What this command does, in plain words:

  • if the model llama3.1:8b is 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).

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:

  1. The model remembers the previous turns. The full conversation history is kept in memory inside the ollama run session.
  2. 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.

>>> /bye

Or 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.

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.

SymptomLikely causeFix
Error: could not connect to ollama app, is it running?Ollama service not startedOpen Ollama from the Start menu (Windows) or run ollama serve
Error: model 'llama3.1:8b' not foundModel not pulledThe ollama run command should auto-pull. If not: ollama pull llama3.1:8b
>>> prompt freezes mid-replyOut of memory (model bigger than RAM/VRAM)Try a smaller model: ollama run gemma3:4b — see practice 3
Replies are nonsense or repetitiveSampling parameters degraded a prior runJust exit (/bye) and re-enter — parameters reset to defaults

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.

Practice 2 — Slash commands inside ollama run