Sub topic 4
Running your first model
This chapter assumes you have installed Ollama and the server is running, as covered in the previous chapter. You should be comfortable in a terminal and know roughly what a large language model is.
What happens when you run a model
The ollama run command does three jobs in one step. It checks whether the model is on disk, downloads it if it is missing, and opens an interactive chat. The CLI is only a client. It sends your messages to the local server, which loads the model weights into memory and generates the reply.
Download and chat
Pull the model first if you want to control when the download happens. Then start a chat.
ollama pull llama3.2
ollama run llama3.2The first run takes longer because the server must load the weights into memory. You will see a >>> prompt. Type a question and press Enter. The reply streams in word by word.
Useful chat commands
Inside the chat, lines that start with / are commands for the CLI. They are not sent to the model.
| Command | Effect |
|---|---|
| `/?` | List the available commands |
| `/show info` | Print details about the loaded model |
| `/clear` | Clear the conversation context |
| `/bye` | Leave the chat |
Use """ to start and end a multi-line message. You can also pass a prompt directly for a one-off answer:
ollama run llama3.2 "Explain what a context window is in one sentence."The model prints its reply and the command exits. This form works well in shell scripts.
Check what is loaded
While a model is in memory, open a second terminal and run ollama ps. It lists each loaded model, its size, and whether it runs on the GPU, the CPU, or a mix of both.
ollama psA model that is split between CPU and GPU runs more slowly. If you see that split, the model is too large for your GPU memory. A later chapter on hardware explains how to choose a smaller size.
Common errors
could not connect to ollama app: the server is not running. Start the desktop app, or runollama servein another terminal.pull model manifest: file does not exist: the model name or tag is wrong. Check the spelling against the library.- A very slow first reply: the model is loading from disk. Later replies in the same session are faster.
- The model forgets earlier messages: you used
/clear, or the conversation exceeded the context window.
Exercise
Exercise
You run ollama run llama3.2 and the reply is much slower than expected. Which command shows whether the model is running on the GPU, the CPU, or both, and what result would explain the slowness?
Show answer
Run ollama ps in a second terminal. If the processor column shows a CPU/GPU split or CPU only, the model does not fit fully in GPU memory, so part of it runs on the slower CPU. A smaller model or a more heavily quantized one would fix this.
Exercise
How do you get a single answer from a model in a shell script, without opening an interactive chat?
Show answer
Pass the prompt as an argument, for example ollama run llama3.2 "Your question". The command prints the reply and exits.