Sub topic 2
What Ollama does: a local server, a CLI, and a model store
This chapter assumes you are comfortable in a terminal, know basic HTTP and JSON, and have a general idea of what a large language model is. You do not need to have installed anything yet. The next chapter covers installation.
The three parts
Ollama is a program that downloads open-weight models and runs them on your machine. It has three parts that work together.
- The server. A background process that loads models into memory and runs inference. It listens on
http://localhost:11434by default. - The CLI. The
ollamacommand. It does not run models itself. It sends requests to the server. - The model store. A directory on disk where downloaded models are kept as files, so each model is downloaded once and reused.
The key point is that the CLI is a client of the server. Anything the CLI can do, your own scripts can do over HTTP.
The server
The server accepts HTTP requests, loads the requested model into RAM or GPU memory, generates text, and returns it. By default it accepts connections only from your own computer, so nothing leaves your machine.
A model is loaded when it is first needed and stays in memory for a while after the last request. It is then unloaded to free memory. Later chapters cover the REST API and the settings that control this behavior.
The CLI
The CLI gives you short commands for common tasks. These are the ones used most often.
ollama pull llama3.2
ollama run llama3.2
ollama list
ollama ps
ollama show llama3.2
ollama rm llama3.2| Command | What it does |
|---|---|
| `ollama pull` | Downloads a model into the model store |
| `ollama run` | Starts an interactive chat, loading the model if needed |
| `ollama list` | Lists models in the model store |
| `ollama ps` | Shows models currently loaded in memory |
| `ollama show` | Prints details about a model |
| `ollama rm` | Deletes a model from disk |
Note the difference between list and ps. list reports what is on disk. ps reports what is in memory right now.
The model store
When you pull a model, Ollama saves it locally. A model consists of its weights (the learned numbers) plus metadata such as the prompt template and default parameters. Weights are large, often several gigabytes, so the store can use a lot of disk space.
Because models are stored once and referenced by name, running the same model from the CLI and from a script does not download it twice.
Why this design matters
Separating the server from the CLI has practical effects.
- You can build applications on top of Ollama using plain HTTP, with no special library.
- Several programs can share one loaded model instead of each loading its own copy.
- You can move the server to another machine and point clients at it, which later chapters show.
Exercise
You run ollama list and see llama3.2, but ollama ps shows nothing. What does this tell you about the model?
Show answer
The model is downloaded and stored on disk, but it is not currently loaded in memory. It will be loaded the next time a request needs it, and it may have been unloaded after sitting idle.
Exercise
A teammate says the ollama command runs the model itself. What is wrong with that statement?
Show answer
The CLI is only a client. The server process loads the model and generates the text. The CLI sends requests to the server, which is why scripts can use the same server over HTTP.