# Mac exercise for mission 10.1: From ollama run to the API, part 1

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/mac-10-1

About 12 minutes at your computer · Type this address: **llm.yoga/en/mac-10-1**

In the mission, you sorted the three layers. Here you see them on your Mac: Ollama is the server, llama.cpp computes underneath, and the chat in the terminal is the interface. This is the first part of the exercise from chapter 10; you do the second part, the APIs, in the exercise for 10.3.

**Before you start**

You need **Ollama** in the terminal. Ollama comes as an app: download it from ollama.com/download and drag it into your Applications folder. On first launch, the app asks permission, if needed, to set up the `ollama` terminal command. It requires macOS 14 or newer. More on this in [chapter 10](https://llm.yoga/en/10-lokale-modelle-4.md). Check:

```
ollama --version
```

**Output (Measured on an M4 Mac (24 GB) on November 25, 2026)**

```
ollama version is 0.40.16
```

### 1. Ask the server whether it’s running

The app starts a server on port 11434 in the background. A simple call shows whether it answers:

```
curl -s http://localhost:11434
```

**Output (Measured on an M4 Mac (24 GB) on November 25, 2026)**

```
Ollama is running
```

### 2. Download a small model

qwen3:1.7b is 1.4 GB and can be tried even with 8 GB on a supported Apple Silicon Mac, provided enough memory is available.

```
ollama pull qwen3:1.7b
```

### 3. Ask and read the measurements

Unless told otherwise, Qwen3 thinks first; `--think=false` turns that off, and `--verbose` shows timings and speed afterward. The prompt is in German, as in the measurement: „Erkläre in zwei Sätzen, was Inferenz ist.“ (explain in two sentences what inference is).

```
ollama run qwen3:1.7b --verbose --think=false "Erkläre in zwei Sätzen, was Inferenz ist."
```

**Output, shortened (Measured on an M4 Mac (24 GB) on November 25, 2026, under load)**

```
Inferenz ist der Prozess, bei dem aus bereits bekannten Informationen oder Prämissen neue, unbekannte Fakten oder Schlussfolgerungen abgeleitet werden.

total duration:       1.940512458s
load duration:        1.311199792s
prompt eval count:    30 token(s)
prompt eval duration: 62.31ms
prompt eval rate:     481.46 tokens/s
eval count:           42 token(s)
eval duration:        563.875ms
eval rate:            74.48 tokens/s
```

The answer describes inference as logical deduction. That is another meaning of the term. This course uses it for a trained model computing an output (chapter 1). The prompt does not specify that context, so the answer alone does not establish a factual error by the model. `load duration` is loading into memory, `eval rate` the writing speed.

### 4. Check who’s computing

```
ollama ps
```

**Output (Measured on an M4 Mac (24 GB) on November 25, 2026)**

```
NAME          ID              SIZE      PROCESSOR    CONTEXT    RUNNER      UNTIL
qwen3:1.7b    8f68893c685c    1.5 GB    100% GPU     4096       llamacpp    4 minutes from now
```

The RUNNER column shows the engine: `llamacpp`. PROCESSOR says that everything is on the GPU. UNTIL is the keep-alive time: by default, after five minutes without a request, the server takes the model out of memory.

### 5. Read the model card

```
ollama show qwen3:1.7b
```

**Output, shortened (Measured on an M4 Mac (24 GB) on November 25, 2026)**

```
  Model
    architecture        qwen3
    parameters          2.0B
    context length      40960
    quantization        Q4_K_M
  Capabilities
    completion
    tools
    thinking
```

The model could handle 40,960 tokens of context, but it was loaded with 4,096. The exercise for 10.2 explains why.

### 6. Let the page check it

Paste the output from step 3. The page compares your writing speed with the roughly estimated ceiling for this model on an M4: 120 GB/s of bandwidth divided by 1.4 GB, about 86 tokens per second (chapter 6).

The check needs JavaScript. Without it: 74.48 tokens per second is 87 percent of 86.

On the test Mac, the result was 74 tokens per second with less other work running; the day before, under heavy load, it was 7.4. Output length and other conditions also differed. The contribution of load to this difference was not isolated. An M4 Pro or Max has more bandwidth, so the ceiling is higher there, and the check may report “above the limit”.

### 7. Clean up

Take the model out of memory. Keep it if you’re still doing the exercises for 10.2 and 10.3.

```
ollama stop qwen3:1.7b
```

If you don’t need it at all anymore:

```
ollama rm qwen3:1.7b
```

Prefer windows to the terminal? LM Studio shows the same layers: model search, chat window and a local server with the same kind of API. (Checked against the documentation, not run here)

#### On the DGX Spark

On the Spark, the layers often sit in one container. The playbook “Chat with LLMs Using Open WebUI and Ollama” starts the Docker image `ghcr.io/open-webui/open-webui:ollama`, which bundles Open WebUI and Ollama, with `--gpus=all` on port 8080. As example models it names gpt-oss:20b and qwen3.6:35b-a3b. You run steps 3 to 5 inside the container there; you calculate the ceiling for the writing speed with 273 GB/s instead of 120. (Checked against the documentation, not run here)
