DEVELOPMENT TECHNOLOGIES

Self-Hosted LLMs (Llama, Ollama, vLLM): Architecture and Ollama vs vLLM

How self-hosted open-weight language models run on your own infrastructure with Ollama and vLLM, what teams use them for, and how they compare with hosted APIs.
Ollama logo

What Is a Self-Hosted LLM?

A self-hosted LLM is an open-weight language model, such as Meta’s Llama family, Qwen, or Mistral, running on infrastructure you control instead of a third-party API. You download the weights and run them in your own cloud account, on-premises servers, or a workstation with a dedicated inference server.

Two tools are especially widely used. Ollama is a platform for running open models locally or in the cloud, packaging weights, configuration, and a runner into one command-line workflow so developers can test models on a laptop or single server in minutes. Its model registry is on the Ollama website.

For high-concurrency production, teams use dedicated serving engines. vLLM is an open-source inference library and server that started at UC Berkeley’s Sky Computing Lab and now has more than 2,000 contributors, documented in the vLLM documentation.

Pairing open weights with these runtimes keeps prompts, embeddings, and completions inside your own security boundary and replaces per-token billing with infrastructure you control.

How a Self-Hosted LLM Works

A self-hosted stack has three core parts: model weights in full or compressed precision, an inference runtime such as vLLM, Ollama, or llama.cpp that manages GPU memory and token generation, and an HTTP or gRPC gateway. The gateway routes each prompt to the engine, which tokenizes it, computes attention across tokens on the GPU, and streams generated tokens back.

Models generate one token at a time, and each step depends on attention keys and values for all previous tokens. Storing these in GPU memory is the KV cache. Without careful management it fragments memory and limits concurrency. vLLM solves this with PagedAttention, continuous batching that mixes new requests into running ones at token level, chunked prefill, and prefix caching for shared system prompts.

The runtime choice matters. Comparing Ollama with llama.cpp, llama.cpp is the low-level C/C++ engine for GGUF models on CPUs, Apple Silicon, and GPUs, while Ollama adds a higher-level CLI, REST API, and model management. Comparing Ollama vs vLLM, Ollama favors quick setup and developer workflows, and vLLM favors multi-user production serving with distributed inference.

vLLM supports more than 200 model architectures, many quantization formats, and OpenAI-compatible, Anthropic Messages, and gRPC endpoints. The stack layers are summarized in the table below.

Stack layerResponsibilityTypical mechanisms
Weights and quantizationStore parameters at a precision that fits the GPUs.FP8, INT8, INT4, GPTQ/AWQ, GGUF.
Memory and schedulingAllocate KV cache memory and batch concurrent requests.PagedAttention, continuous batching, prefix caching.
Distributed executionSplit large models across GPUs or nodes.Tensor, pipeline, data, and expert parallelism.
API gatewayExpose standard endpoints to applications and agents.OpenAI-compatible API, Anthropic Messages API, gRPC.
Engineer's Take

We recommend self-hosted LLMs for sustained, predictable token volume, strict data residency, or narrow tasks where a fine-tuned small model beats a frontier model on speed and cost. The usual production failure is underestimating KV cache growth: a model that fits one GPU in a single-user test runs out of memory when twenty users send long prompts. We use engines with continuous batching and paged memory, cap context length at the gateway, and load-test with realistic prompts.

Diatom Enterprises favicon
Diatom engineering team
Self-Hosted LLMs at a Glance
Type

Open-weight models on your own infrastructure

Models

Llama, Qwen, Mistral, and other open weights

Runtimes

Ollama, vLLM, llama.cpp

Strengths

Data control, fixed costs at scale, pinned versions

Compared with
Need a reliable tech partner?
20+

Years in business

80+

Senior engineers

200+

Projects delivered

What Self-Hosted LLMs Are Used For

Teams self-host LLMs when data rules forbid external API calls, when high token volume makes APIs expensive, or when they need low latency and fixed model versions.

Private RAG over Regulated Records

Banks, healthcare providers, and law firms build internal assistants over contracts, patient notes, or audit logs, hosting both embedding and generation models so personal data and trade secrets never leave their network.

High-Volume Document Extraction

Logistics, insurance, and e-commerce platforms process millions of invoices, customs forms, and tickets, extracting structured JSON around the clock for a fixed hardware cost instead of per-token fees.

Code Completion and Developer Tools

Companies with strict IP controls run coding models inside their network for IDE completion, pull-request review, and test generation, keeping proprietary code off public endpoints.

Air-Gapped and Fine-Tuned Systems

Plants, defense sites, and remote facilities run compact quantized models locally without internet access, and teams fine-tune open weights with LoRA for proprietary DSLs, legacy SQL dialects, or medical taxonomies.

vLLM and Ollama vs Hosted APIs

The Ollama vs vLLM choice separates developer simplicity from production throughput, while hosted APIs such as OpenAI and Anthropic trade data control and fixed costs for zero infrastructure. Because vLLM exposes OpenAI- and Anthropic-compatible APIs, teams can compare options without SDK lock-in.

Criteriontech logo vllmvLLM (self-hosted)tech logo ollamaOllama (self-hosted)tech logo openaiHosted APIs (OpenAI, Anthropic)
Best forMulti-user production serving.Local development and single-node use.Fast start with no infrastructure.
Data privacyPrompts and outputs stay in your network.Prompts and outputs stay on your machine or server with local models; Ollama’s cloud models send prompts out.Data goes to the vendor; zero-retention agreements needed.
Cost modelFixed GPU cost; cheaper per token at high utilization.Fixed hardware cost; limited concurrency.Pay per token, nothing when idle.
Throughput controlBatching, quantization, prefix caching, distributed inference.Simple configuration with less tuning.Shared capacity and vendor rate limits.
Model versionsPinned weights and server versions.Pinned model files.Vendors retire and update models.
OperationsHigh: GPUs, drivers, autoscaling, monitoring.Low to moderate.Minimal: API keys and fallbacks.
Swipe the table to compare →

When to Choose a Self-Hosted LLM

Self-host when regulations or client contracts forbid sending sensitive data to external processors, or when your API bill exceeds the cost of dedicated GPUs running at steady utilization. It also fits products that need fixed model behavior over years, very low latency through local placement and prefix caching, or custom fine-tuned and quantized weights.

When a Self-Hosted LLM Is Not the Right Fit

Avoid self-hosting during early product discovery, before you know prompt volume, context lengths, and required capability. Spiky traffic with long idle periods makes idle GPUs more expensive than per-token pricing. Small teams without Kubernetes and GPU operations experience, or use cases that need the broadest frontier reasoning, are better served by hosted APIs.

How We Approach Self-Hosted LLM Projects

We build self-hosted LLM platforms that start from real workloads, run on production-grade serving engines, and plug into applications through standard APIs.

Model and Quantization Selection

Candidate open-weight models are evaluated on real production prompts, comparing full precision with FP8, INT8, INT4, GPTQ/AWQ, or GGUF to balance accuracy against GPU memory before any hardware is committed.

Production Serving on vLLM

Serving runs on vLLM with PagedAttention, continuous batching, chunked prefill, and prefix caching, with tensor or pipeline parallelism for larger models. Context limits are enforced at the gateway and load tests use realistic prompt mixes.

OpenAI-Compatible Integration

Applications talk to the cluster through OpenAI-compatible endpoints from the first commit, so developers can use Ollama locally while staging and production run vLLM, and switching to or from hosted APIs needs no code rewrite.

Sound like the right partner?

Tell us about your project. We'll get back to you within 1 business day.

Frequently Asked Questions

Direct answers to common engineering, licensing, and hardware questions about private LLM deployments.

What is the difference between Ollama and vLLM for production?

Ollama is built for quick local and cloud setup and developer workflows. vLLM is a high-throughput inference server for multi-user production, using PagedAttention, continuous batching, chunked prefill, and prefix caching to keep GPUs busy when dozens or hundreds of requests arrive at once.

Should I use Ollama or llama.cpp for local LLMs?

Use Ollama for a ready-made CLI, background server, and model registry with minimal configuration. Use llama.cpp directly when embedding inference in a native desktop, mobile, or edge application without a separate daemon, or when you need low-level control over GGUF quantization and CPU threading.

How much GPU memory do I need to self-host an LLM?

It depends on the model’s parameter count and precision, the KV cache needed for your maximum concurrent context, and activation overhead. Quantization such as FP8, INT8, or INT4 shrinks the weights, PagedAttention keeps the KV cache from fragmenting memory, and tensor or pipeline parallelism splits larger models across GPUs.

Does self-hosting an LLM make a company GDPR compliant?

It removes third-party transfer risk by keeping personal data on your own infrastructure, which simplifies residency and sub-processor questions. It does not make an application compliant by itself: you still need a lawful basis, access controls, encryption, protection against data leaking between users, and erasure across vector databases and logs.

Can companies in the EU use Meta Llama models commercially?

It depends on the license for the specific Llama release, the company’s user count, and any regional restrictions Meta applies to certain models. Some releases and capabilities have been restricted for organizations based in the EU, so your legal team should check the license in the official repository for the exact model before production use.

Is a self-hosted LLM cheaper than the OpenAI or Anthropic API?

Only when token volume is high and steady enough to keep the GPUs busy. Hosted APIs charge per token and nothing when idle, so they are cheaper for early products and spiky traffic. At sustained high volume, fixed GPU costs with batching and quantization bring the cost per token below API prices.

The People Behind

A team of skilled engineers, architects, and delivery managers, dedicated to making every engagement a success.

Let's discuss your project