Component brief / Infrastructure

Ollama: run AI models on your own computer.

Published
Updated
Last verified
Reading time
4 minutes
Topics
ollama / local-ai / inference

What it is

Ollama is software for Windows, macOS and Linux that downloads and runs AI models. The model is the trained software that produces the answers; Ollama handles loading it and passing requests to it. The downloaded model files are sometimes called model artefacts.

When the model processes your input and produces an answer, that is called inference. Your application can request this through Ollama's HTTP API, normally at http://localhost:11434/api. Here, localhost means the computer running your application.

A Modelfile is a configuration file that chooses a model and its settings. It can include standing instructions such as “Answer briefly in Danish”. It can also set a prompt template: the rules for arranging instructions and conversation messages into the format the model expects. You do not need to write one to use a downloaded model.

Where it fits

For example, a support application could send an error report to a local model and ask for a short summary. Ollama runs the model and returns its answer. Your application decides which text to send, displays the result and saves it if needed.

Some models support tool calling: they can ask your application to run a function, such as looking up a support ticket. Your application checks permissions and arguments, runs the function and sends the result back to the model.

Ollama also supports embeddings, which turn text into lists of numbers representing its meaning. Your application can compare these to find related documents even when they use different words. Storing and searching those numbers requires additional application code or a database.

When to use it

Ollama is a useful starting point when:

  • you want to add AI features to an application through HTTP requests;
  • the text should be processed on a computer you control;
  • you need to work offline after downloading the model; or
  • you want to compare models on your own hardware.

For a shared service, test how it behaves with several users at once. Ollama queues requests or rejects them when overloaded; a successful test on one laptop does not establish capacity for a team.

Trade-offs

Your computer does the work. Model size, available memory and processor speed affect how quickly you get an answer. Quantisation stores a model's numbers with less precision so it uses less memory, but this can affect answer quality. Larger inputs and several simultaneous requests also need more memory; see Ollama's hardware and memory guidance.

Local and cloud are different choices. Ollama also offers cloud models, where another company's computers process the text. According to its privacy guidance, Ollama does not receive your text when you run a local model. Check which model you selected and whether your application calls other online services. The API listens only on the local computer by default; exposing it to other computers requires access controls.

A correctly formatted answer can still be wrong. Structured output lets you specify a JSON structure, such as a ticket category and summary. That helps your code read the answer, but does not prove that the category or summary is correct. Test the model on examples from your actual work.

Keep a record of the model version and settings you tested. Review the model's licence before using it in a product.

Alternatives

  • llama.cpp also runs models locally, with command-line tools, a server and a C/C++ library for developers who want to integrate it directly.
  • vLLM is another option for running models behind an API on servers you manage.
  • Hugging Face Inference Endpoints runs models on managed cloud infrastructure, so you do not have to operate the machines yourself. Your requests leave your computer.

Integration example

With Ollama installed and running, this PowerShell example downloads a model and sends it a request through the local chat API:

ollama pull llama3.2

$requestBody = @{
    model = "llama3.2"
    messages = @(@{
        role = "user"
        content = "Summarise in one sentence: The database backup failed during validation."
    })
    stream = $false
} | ConvertTo-Json -Depth 4

$response = Invoke-RestMethod -Method Post `
    -Uri "http://localhost:11434/api/chat" `
    -ContentType "application/json" `
    -Body $requestBody

$response.message.content

The download needs internet access. The request then runs locally using the downloaded model. stream = $false asks Ollama to return one complete answer rather than send it in pieces. Your application still needs to handle failed requests and check the answer before acting on it.

AI Disclosure

Researched and drafted with AI assistance, then reviewed by Søren Dalby. Sources are linked; errors may remain, and corrections are welcome.

Sources