Four operations, one theme: models are files on your disk
Every model you pull takes up real, permanent disk space until you remove it, unlike a cloud API, where "using a model" never costs you storage. This lesson covers the four operations that keep that under control, all available from Python even though you'd typically reach for the ollama CLI directly for most of them day to day.
`ollama.pull()`: rarely called at runtime
ollama.pull(THROWAWAY_MODEL)The Python equivalent of ollama pull on the CLI. This lesson calls it directly so there's a disposable model to safely delete later, but in a real program you'd almost never pull a model at runtime: it's a multi-hundred-megabyte-to-multi-gigabyte download, not something you want happening the first time a user makes a request.
`ollama.list()` vs `ollama.ps()`: on disk vs in memory
on_disk = [model.model for model in ollama.list().models]ollama.list(), from Lessons 1 and 2, reports everything ever pulled, sitting on disk, whether or not it's currently in use. That's the "installed" list.
loaded = ollama.ps().modelsollama.ps() (mirroring the Unix ps command for running processes) reports only what's currently loaded into memory or GPU VRAM right now, ready to answer instantly. Ollama automatically unloads a model after a few minutes of inactivity to free that memory back up, which is why expires_at shows up on each entry: it's when Ollama plans to unload it if nothing else asks for it first.
`ollama.delete()`: freeing disk space
ollama.delete(THROWAWAY_MODEL)The Python equivalent of ollama rm. Removes the model's weights from disk permanently, gone until you pull it again. This is the one operation genuinely worth knowing from Python: a long-running application that manages its own local models (Lesson 22 builds one that runs as a background service) may need to clean up old or unused models on its own, without a human running CLI commands.
Checkpoint
ollama.pull(): downloads a model's weights to disk, rarely called at runtime in a real program.ollama.list(): everything on disk, "installed."ollama.ps(): what's currently loaded in memory, "running," auto-unloaded after a few idle minutes.ollama.delete(): permanently frees disk space, the one operation worth calling from a real long-running program.
If anything here still feels unclear, ask before moving to Lesson 8.