← Back to articles
AI-generated image

Local LLMs: running a model on your own machine

What a local LLM is and how it differs from a cloud API. Estimate memory, understand quantization, run a model with Ollama, and know where it fits.

Written by AI · 8 min · Enough if you can use a terminal
Local LLMOllamaQuantization
What this article covers

A local LLM keeps the model weights on your own machine and runs them there. The memory you need is roughly parameters × bytes per parameter, and quantization shrinks it.

What a local LLM is

Running a local LLM means downloading the model's weights (the parameters learned in training) and doing inference on your own computer. A cloud API such as Claude's sends your input to the provider's servers and returns the result. With a local model, input and output stay on your machine. The mechanism is the same either way: choose the next token by probability, over and over (see How LLMs work for the basics). What differs is where the computation happens.

Where the data flows: cloud API vs. local LLMCLOUD APIYour PCProvider cloudthe model runs heresend inputresult returnsYour input is sent to the providerLOCAL LLMAppchat, etc.Inference enginesuch as OllamaModel weightsloaded in memoryInput and output never leave the PC
Figure 1 The mechanism is the same; where the computation happens differs. Locally, input and output stay inside the PC.

Available models and their performance change quickly, so this article names no specific models and gives no benchmark numbers. When you choose one, check the model's official page and its license.

Cloud vs. local

AspectCloud APILocal
Where data goesSent to the provider's serversStays on your machine
CostPay per token usedNo per-use charge once you have the hardware
Capability ceilingLarge models availableLimited to what fits in your memory
OfflineNeeds a connectionWorks once the model is downloaded
UpkeepThe provider updates itYou manage updates, settings and disk space

Neither is better in general; choose by use case. Local fits when you don't want sensitive documents to leave the machine, when you work without a network, or when you want to call a model many times while experimenting. Cloud is more realistic when you need the best quality or lack the hardware. Many people use both.

Estimating the memory you need

The first limit you hit locally is memory. The weights must fit in memory, and their size is roughly parameters × bytes per parameter. At 16 bits (2 bytes) per parameter, a 7-billion-parameter model (7B) takes about 14 GB. The code below prints the estimate for each size and precision. The JavaScript and Python versions print the same output (checked by running both with Node.js and Python 3).

memory.py
# Weight memory in GB = parameters (billions) × bytes per parameter
def gb(billions, bits):
    return (billions * 1e9 * bits / 8) / 1e9

for size in [7, 14, 32, 70]:
    row = [f"{bits}bit {gb(size, bits):.1f} GB" for bits in [16, 8, 4]]
    print(f"{size}B:", " / ".join(row))
Output
7B: 16bit 14.0 GB / 8bit 7.0 GB / 4bit 3.5 GB
14B: 16bit 28.0 GB / 8bit 14.0 GB / 4bit 7.0 GB
32B: 16bit 64.0 GB / 8bit 32.0 GB / 4bit 16.0 GB
70B: 16bit 140.0 GB / 8bit 70.0 GB / 4bit 35.0 GB
Which memory the weights sit in, by setupWith a GPU (such as NVIDIA)Main memoryVideo memory (VRAM)Fast if the weights fit in VRAMApple SiliconUnified memory (shared by CPU and GPU)CPU onlyMain memory (works, but slower than a GPU)OS and other appsModel weightsConversation cache (KV)
Figure 2 What “memory” means depends on the setup. In every setup, the weights and the cache must fit in what is available. Proportions are illustrative, not real values.

To try whether a model fits your memory, use the Local LLM Memory Estimator in the app. Pick the parameters, precision and memory to see the weights' size and a rough verdict.

These figures cover weights only. In practice you also need room for the cache that grows with conversation length (the KV cache), plus the OS and other apps, so leave headroom beyond the table.

Which "memory" this means depends on how you run the model.

  • With a GPU (such as NVIDIA): video memory (VRAM). If the weights fit in VRAM, it runs fast. Some tools can spill the rest into main memory, but it becomes much slower
  • On Apple Silicon: the CPU and GPU share one memory (unified memory). There is no separate video memory; ordinary memory serves the model too. The OS needs a share, so not all of it is available to the model
  • On the CPU only: main memory. It works, but is slower than on a GPU

Shrinking it with quantization

As the table shows, fewer bits per parameter means proportionally less memory. That is quantization: you trade some precision to run the same model in less memory. Many published models come in versions quantized to around 4 bits.

  • Fewer bits make the model lighter, but answer quality drops a little at a time
  • A larger model at 4 bits is often said to beat a smaller one at high precision, but it depends on the model and task, so compare on your own machine
  • Judge the quality difference on the tasks you plan to run, not on general numbers alone

Running a model with Ollama

The easy way to start is a tool like Ollama. It handles downloading models, running them in quantized formats, and serving a local API. Others include LM Studio (with a GUI) and llama.cpp, which many of these tools build on.

Example commands
# Download a model and start chatting (pick <model-name> from the Ollama library)
ollama run <model-name>

# List the models you have downloaded
ollama list

Once running, Ollama listens for API requests on your own machine (localhost), and your programs query it over HTTP. Choose the first model by the size that fits your free memory according to the estimate above. Commands and API details can change, so check the official documentation.

Where it fits, and its limits

  • Fits: summarizing or classifying sensitive documents, offline use, bulk drafting and reformatting, experiments to learn how models work
  • Limits: it may be less capable than the largest models, long contexts and complex reasoning can be less stable, and speed depends on your hardware
  • Caution: a local model still makes mistakes. Local or cloud, check the output before you rely on it

Checklist before you start

  • Is a smaller model enough for the task?
  • Do the weights plus headroom for the cache fit in free memory?
  • Does the model's license allow your use (such as commercial use)?
  • Do you have enough disk space (models run from a few GB to tens of GB)?
  • Have you compared output quality on your own task?

For big models, several users or long contexts, see the follow-up, Running local LLMs seriously.

Official references

Ollama — Documentation ↗llama.cpp (GitHub) ↗LM Studio — Docs ↗
PAIBOT / DEVELOPMENT JOURNALBack to articles →

Find what you need

Searches titles, tags and body text esc to close