Skip to content

Llama Guide — Meta's Open-Source LLMs for Engineers (2026)

This Llama guide covers everything a GenAI engineer needs to go from downloading model weights to running a production-grade open-source LLM deployment. You will learn how Llama 3.1, 3.2, and 3.3 compare, how to run models locally with Ollama and llama.cpp, how to fine-tune with LoRA and QLoRA, and how to host at scale with vLLM or Text Generation Inference.

Open-source LLMs crossed a threshold in 2024 that changed the economics of AI deployment. Llama 3.1 405B became the first open-source model to match GPT-4-class performance on reasoning benchmarks. Llama 3.3 70B matched Llama 3.1 405B on most tasks at one-sixth the parameter count. For the first time, the best open-source model was genuinely competitive with the best closed-source models for a wide range of production use cases.

If you are building a system where any of the following apply, Llama belongs in your evaluation:

  • Data privacy is a constraint — customer PII, financial records, or health data cannot be sent to a third-party API. Llama runs entirely in your infrastructure.
  • Inference cost at scale is a problem — at <$0.50/1M tokens on self-hosted GPU infrastructure, Llama dramatically undercuts per-token API pricing for high-volume workloads.
  • You need fine-tuning on proprietary data — closed-source fine-tuning APIs impose data sharing agreements and usage restrictions. With Llama you own the trained weights.
  • You want to understand how LLMs work at a deeper level — open weights mean you can inspect, modify, and experiment with the model in ways that closed APIs do not permit.

This guide assumes you are comfortable with Python and have some familiarity with LLM fundamentals. You do not need prior experience running local models.


Meta’s Llama 3 generation covers a wide range of deployment scenarios — from on-device inference on a smartphone to enterprise clusters running hundreds of billions of parameters. Understanding the variants before picking one saves time and avoids misconfigured deployments.

ModelParametersContext WindowKey Use CaseGPU VRAM (FP16)
Llama 3.2 1B1B128KOn-device, edge inference, embedded apps~2GB
Llama 3.2 3B3B128KOn-device with better quality, mobile~6GB
Llama 3.1 8B8B128KLocal dev, fine-tuning experiments, low-cost inference~16GB
Llama 3.1 70B70B128KProduction inference, strong reasoning, RAG backends~140GB
Llama 3.3 70B70B128KProduction inference, matches 3.1 405B quality~140GB
Llama 3.1 405B405B128KMaximum capability, research, hardest tasks~810GB

Model selection notes:

  • Llama 3.2 1B / 3B are designed for on-device deployment. Meta ships these with multimodal vision capability (3.2 11B and 90B for vision, though those are larger). The 1B and 3B instruction-tuned variants are suitable for embedded systems, browser-side inference via WebAssembly, and mobile apps.
  • Llama 3.1 8B is the practical default for experimentation and fine-tuning. It runs on a single consumer GPU (RTX 3090, RTX 4090) and is fast enough for interactive development. Quality is competitive with GPT-3.5 on most benchmarks.
  • Llama 3.3 70B is the current sweet spot for production deployments. Meta’s Llama 3.3 release achieved instruction-following and reasoning quality that matches Llama 3.1 405B on most standard benchmarks while using a fraction of the compute. For teams running self-hosted inference, this is the first choice.
  • Llama 3.1 405B is the maximum-capability open-source option as of early 2026. It requires significant infrastructure (multi-GPU setups or high-memory cloud instances) but delivers GPT-4-class quality.

Each size ships in two variants:

  • Base model (Meta-Llama-3.1-8B) — pretrained on raw text. Completes text but does not follow instructions reliably. Used as the starting point for fine-tuning.
  • Instruction-tuned model (Meta-Llama-3.1-8B-Instruct) — fine-tuned with RLHF to follow instructions and have a chat interface. Use this for any application that involves a user or agent giving the model tasks.

For almost all production use cases, use the Instruct variant.


The choice between closed-source APIs (GPT-4o, Claude, Gemini) and open-source models (Llama, Mistral, Qwen) is fundamentally a cost, control, and privacy tradeoff. Understanding each dimension helps you make the right call for your specific deployment.

API pricing for closed-source models is measured in dollars per million tokens. At low volumes this is negligible. At production scale — millions of requests per day — it compounds quickly.

A team processing 10 million tokens per day on GPT-4o spends roughly $25,000/month (at $2.50/1M input tokens). The same workload on self-hosted Llama 3.3 70B running on two A100 80GB GPUs costs approximately $3,000-$5,000/month in cloud GPU costs — a 5-8x reduction. The break-even point where self-hosting becomes cheaper than API usage varies by model and infrastructure provider, but for most teams it lands between 1 and 5 million tokens per day.

Sending data to a third-party API means that data leaves your infrastructure, passes through their servers, and is subject to their data processing agreements. For use cases involving:

  • Healthcare data — HIPAA-regulated patient records
  • Financial data — non-public transaction records, trading signals
  • Legal documents — privileged client communications
  • Proprietary internal data — code, strategy documents, customer databases

…a closed-source API may be legally or contractually prohibited. Llama running on your own infrastructure keeps all data within your perimeter. This is not a hypothetical edge case — data residency and privacy are the primary driver of open-source model adoption in regulated industries.

Closed-source APIs offer fine-tuning for some models, but with important limitations: you share your training data with the provider, you are restricted to the provider’s infrastructure, and you get an opaque model whose behavior you cannot fully inspect. With Llama, fine-tuning on proprietary data produces weights you fully own, and the relationship between your training data and the model’s behavior is transparent and auditable.

For a comparison of fine-tuning versus retrieval-based customization, see Fine-Tuning vs RAG.


The fastest path to a working local Llama deployment is Ollama. For more control over quantization and inference parameters, llama.cpp is the foundation that Ollama builds on.

Ollama wraps llama.cpp with a management layer that handles model downloads, serves an OpenAI-compatible REST API, and runs as a background service:

Terminal window
# Install Ollama (macOS / Linux)
curl -fsSL https://ollama.ai/install.sh | sh
# Pull the Llama 3.1 8B instruction-tuned model (~4.7GB GGUF)
ollama pull llama3.1
# Interactive chat in the terminal
ollama run llama3.1
# Pull a larger model for better quality
ollama pull llama3.3
ollama run llama3.3

Ollama serves an OpenAI-compatible API at http://localhost:11434. You can drop it into any existing OpenAI SDK integration by changing the base URL:

from openai import OpenAI
# Point the OpenAI client at your local Ollama instance
client = OpenAI(
base_url="http://localhost:11434/v1",
api_key="ollama", # Required by the SDK but not used by Ollama
)
response = client.chat.completions.create(
model="llama3.1",
messages=[
{
"role": "system",
"content": "You are a senior software engineer. Give concise, accurate answers.",
},
{
"role": "user",
"content": "Explain the difference between a mutex and a semaphore.",
},
],
max_tokens=512,
)
print(response.choices[0].message.content)

For direct Python integration using Ollama’s native client:

import ollama
# Simple generation
response = ollama.chat(
model="llama3.1",
messages=[
{"role": "user", "content": "What is transformer self-attention?"}
],
)
print(response["message"]["content"])
# Streaming response
for chunk in ollama.chat(
model="llama3.3",
messages=[{"role": "user", "content": "Explain RAG in 3 paragraphs."}],
stream=True,
):
print(chunk["message"]["content"], end="", flush=True)

llama.cpp is the C++ inference engine behind Ollama, with Python bindings available via llama-cpp-python. Use it directly when you need fine-grained control over quantization, sampling parameters, or embedding extraction:

Terminal window
# Install with GPU support (CUDA)
CMAKE_ARGS="-DGGML_CUDA=on" pip install llama-cpp-python
# Or CPU-only
pip install llama-cpp-python
from llama_cpp import Llama
# Load a GGUF model file (download from Hugging Face)
llm = Llama(
model_path="./models/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf",
n_ctx=4096, # Context window size
n_gpu_layers=35, # Number of layers to offload to GPU (-1 for all)
n_threads=8, # CPU threads for layers not on GPU
verbose=False,
)
# Chat completion
response = llm.create_chat_completion(
messages=[
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Write a Python function to parse JWT tokens."},
],
max_tokens=512,
temperature=0.1, # Lower = more deterministic
top_p=0.95,
)
print(response["choices"][0]["message"]["content"])
# Text embeddings (for RAG pipelines)
embedding = llm.create_embedding("What is vector similarity search?")
print(embedding["data"][0]["embedding"][:5]) # First 5 dims

GGUF quantization formats (covered in detail in Section 8):

  • Q4_K_M — 4-bit quantization, medium quality, best balance of size and accuracy. Start here.
  • Q5_K_M — 5-bit, better quality than Q4, slightly larger. Use when you can afford 20% more VRAM.
  • Q8_0 — 8-bit, near FP16 quality. Use when quality matters most and you have the memory.
  • F16 — Full 16-bit float. Highest quality, highest VRAM requirement. Use for fine-tuning.

The diagram below shows the key layers of a self-hosted Llama deployment — from your application code down to the model weights on disk.

Llama Self-Hosted Deployment Stack

Requests flow through each layer. The inference engine layer is swappable — the same application code works with Ollama, vLLM, or TGI.

Application Layer
Python / Node.js / REST — your RAG pipeline, chatbot, or batch job
API Interface
OpenAI-compatible REST API — drop-in replacement for hosted API calls
Inference Engine
Ollama (dev/single-node) · vLLM (production throughput) · TGI (enterprise)
Quantization Layer
GGUF (llama.cpp) · GPTQ · AWQ · BitsAndBytes — trades quality for VRAM
Model Weights
Llama 3.1 / 3.2 / 3.3 — downloaded from Meta via Hugging Face Hub
Hardware
NVIDIA GPU (A100/H100 for production, RTX 4090 for dev) · Apple Silicon · CPU
Idle

Key insight: The OpenAI-compatible API surface means your application code does not change when you switch inference engines. Moving from Ollama (development) to vLLM (production) is a base URL change, not a code rewrite.


Fine-tuning is where open-source models earn their production value. By adapting Llama to your domain, you get a model that understands your terminology, follows your output format conventions, and avoids behaviors irrelevant to your use case — all without sharing your data with a third party.

Full fine-tuning of a 70B model requires terabytes of GPU memory and weeks of compute. LoRA (Low-Rank Adaptation) and QLoRA (Quantized LoRA) make fine-tuning practical on a single GPU.

How LoRA works: Instead of updating all model weights (billions of parameters), LoRA freezes the base model and adds small trainable matrices alongside specific weight layers. These “adapter” matrices have a rank r (typically 8-64) much smaller than the original weight dimensions. At inference time, the adapter weights are merged with the base model, producing zero additional latency.

QLoRA extends this: The base model is loaded in 4-bit quantized form (saving ~4x VRAM), and LoRA adapters are trained in 16-bit precision on top. This allows fine-tuning Llama 3.1 8B on a single RTX 3090 (24GB VRAM) and Llama 3.1 70B on 2-4 A100 GPUs.

Terminal window
pip install transformers peft trl datasets accelerate bitsandbytes
import torch
from datasets import load_dataset
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
TrainingArguments,
)
from peft import LoraConfig, get_peft_model, TaskType
from trl import SFTTrainer
# --- 1. Load model in 4-bit (QLoRA) ---
model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
)
model = AutoModelForCausalLM.from_pretrained(
model_id,
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.pad_token = tokenizer.eos_token
# --- 2. Configure LoRA adapters ---
lora_config = LoraConfig(
task_type=TaskType.CAUSAL_LM,
r=16, # Rank of adapter matrices
lora_alpha=32, # Scaling factor (typically 2x rank)
lora_dropout=0.05,
target_modules=[ # Which weight matrices to adapt
"q_proj", "k_proj", "v_proj",
"o_proj", "gate_proj", "up_proj", "down_proj",
],
bias="none",
)
model = get_peft_model(model, lora_config)
model.print_trainable_parameters()
# Output: trainable params: 41,943,040 || all params: 8,072,130,560 || trainable%: 0.52
# --- 3. Prepare dataset (example: instruction-following format) ---
dataset = load_dataset("json", data_files={"train": "training_data.jsonl"})
def format_prompt(example):
return {
"text": f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
{example['system']}<|eot_id|><|start_header_id|>user<|end_header_id|>
{example['user']}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
{example['assistant']}<|eot_id|>"""
}
dataset = dataset.map(format_prompt)
# --- 4. Train ---
training_args = TrainingArguments(
output_dir="./llama-finetuned",
num_train_epochs=3,
per_device_train_batch_size=2,
gradient_accumulation_steps=4, # Effective batch size = 2 * 4 = 8
learning_rate=2e-4,
fp16=False,
bf16=True,
logging_steps=10,
save_strategy="epoch",
warmup_ratio=0.05,
lr_scheduler_type="cosine",
)
trainer = SFTTrainer(
model=model,
train_dataset=dataset["train"],
args=training_args,
dataset_text_field="text",
max_seq_length=2048,
tokenizer=tokenizer,
)
trainer.train()
# --- 5. Save adapter weights ---
trainer.model.save_pretrained("./llama-lora-adapter")
tokenizer.save_pretrained("./llama-lora-adapter")

For deployment, merge the LoRA adapters back into the base model weights. The merged model loads faster and requires no PEFT dependency:

from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Meta-Llama-3.1-8B-Instruct",
torch_dtype=torch.float16,
device_map="auto",
)
model = PeftModel.from_pretrained(base_model, "./llama-lora-adapter")
merged_model = model.merge_and_unload()
# Save the merged model
merged_model.save_pretrained("./llama-merged-model")

For a thorough treatment of when to fine-tune versus using retrieval, see Fine-Tuning vs RAG and the dedicated Fine-Tuning guide.


Running Llama on a laptop is useful for development. Production workloads need a serving layer that handles concurrent requests, batches efficiently, and saturates available GPU compute. Two options dominate: vLLM and Text Generation Inference (TGI).

vLLM — High-Throughput Production Serving

Section titled “vLLM — High-Throughput Production Serving”

vLLM is the standard for high-throughput LLM inference. Its core innovation is PagedAttention — a memory management technique borrowed from OS virtual memory that dramatically reduces GPU memory fragmentation during inference, enabling higher concurrency on the same hardware.

Terminal window
pip install vllm
from vllm import LLM, SamplingParams
# Load model — vLLM handles tensor parallelism automatically
llm = LLM(
model="meta-llama/Meta-Llama-3.1-8B-Instruct",
tensor_parallel_size=1, # Set to 4 for 70B on 4x A100
gpu_memory_utilization=0.90, # Fraction of GPU VRAM to allocate
max_model_len=4096,
dtype="bfloat16",
)
sampling_params = SamplingParams(
temperature=0.1,
top_p=0.95,
max_tokens=512,
)
# Batched offline inference — processes all prompts in parallel
prompts = [
"Explain attention mechanisms in transformers.",
"What is the difference between RLHF and DPO?",
"How does PagedAttention reduce GPU memory fragmentation?",
]
outputs = llm.generate(prompts, sampling_params)
for output in outputs:
print(f"Prompt: {output.prompt[:50]}...")
print(f"Response: {output.outputs[0].text}\n")

vLLM OpenAI-compatible server (recommended for production):

Terminal window
# Start the vLLM API server
python -m vllm.entrypoints.openai.api_server \
--model meta-llama/Meta-Llama-3.1-8B-Instruct \
--tensor-parallel-size 1 \
--port 8000 \
--max-model-len 4096 \
--gpu-memory-utilization 0.90
# Query it with the OpenAI client (same code as any OpenAI API call)
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="none")
response = client.chat.completions.create(
model="meta-llama/Meta-Llama-3.1-8B-Instruct",
messages=[
{"role": "user", "content": "What is vLLM's PagedAttention?"}
],
max_tokens=256,
)
print(response.choices[0].message.content)

Hugging Face’s TGI is the other major production serving option. It supports continuous batching, flash attention, and has first-class support for GPTQ and AWQ quantized models. TGI ships as a Docker container — useful for containerized deployments:

Terminal window
# Pull and run TGI with Llama 3.1 8B
docker run --gpus all \
-v $PWD/models:/data \
-p 8080:80 \
ghcr.io/huggingface/text-generation-inference:latest \
--model-id meta-llama/Meta-Llama-3.1-8B-Instruct \
--max-input-length 2048 \
--max-total-tokens 4096 \
--quantize bitsandbytes-nf4

Self-hosting is not always the right choice. Several managed services run Llama without the infrastructure overhead:

ProviderModels AvailablePricing (approx.)Notes
Together AILlama 3.1 8B/70B/405B, 3.3 70B~$0.18-$0.88/1M tokensFast inference, OpenAI-compatible API
GroqLlama 3.1 8B/70B~$0.05-$0.59/1M tokensExtremely fast (LPU hardware)
ReplicateLlama 3.1, 3.2, 3.3Per-second GPU pricingGood for variable workloads
AWS BedrockLlama 3.1 8B/70B~$0.22-$0.99/1M tokensStays in AWS VPC, SOC 2 compliant
Fireworks AILlama 3.1, 3.3~$0.20-$0.90/1M tokensServerless, fast cold starts

For teams that need data residency but not full self-hosting overhead, AWS Bedrock or Azure AI Foundry versions of Llama are worth evaluating.


Quantization reduces the numeric precision of model weights, trading a small amount of quality for large reductions in memory and compute requirements. Understanding the formats helps you pick the right tradeoff for your hardware.

GGUF is the native format for llama.cpp and by extension Ollama. Files are named with the quantization level: Q4_K_M, Q5_K_M, Q8_0, etc.

FormatBits per weightVRAM for 8BQuality vs FP16Best for
Q2_K~2.6~3.5GB~85%Absolute minimum VRAM, significant quality loss
Q4_K_M~4.8~5.1GB~97%Best balance — default recommendation
Q5_K_M~5.7~5.7GB~98.5%Better quality when you have the extra VRAM
Q8_08~8.5GB~99.8%Near-lossless, practical ceiling for GGUF
F1616~16GB100%Training and full-precision inference

Download quantized GGUF models directly from Hugging Face (search for TheBloke or bartowski repositories):

Terminal window
# Pull specific quantization in Ollama
ollama pull llama3.1:8b-instruct-q5_K_M
# Or download GGUF directly for llama.cpp
wget https://huggingface.co/bartowski/Meta-Llama-3.1-8B-Instruct-GGUF/resolve/main/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf

GPTQ quantizes weights to 4-bit using a post-training quantization algorithm optimized for GPU inference. It runs natively in Transformers and TGI:

from transformers import AutoModelForCausalLM, AutoTokenizer
# Load a GPTQ-quantized model directly from Hugging Face
model = AutoModelForCausalLM.from_pretrained(
"TheBloke/Llama-3-8B-Instruct-GPTQ",
device_map="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained("TheBloke/Llama-3-8B-Instruct-GPTQ")

AWQ (Activation-Aware Weight Quantization)

Section titled “AWQ (Activation-Aware Weight Quantization)”

AWQ is a 4-bit quantization method that selects which weights to quantize based on activation magnitudes, preserving the weights most important to model quality. It generally outperforms GPTQ at the same bit width:

Terminal window
pip install autoawq
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer
model = AutoAWQForCausalLM.from_quantized(
"casperhansen/llama-3-8b-instruct-awq",
fuse_layers=True, # Kernel fusion for faster inference
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained("casperhansen/llama-3-8b-instruct-awq")

For most teams, the decision tree is:

  1. Running on CPU or Mac Apple Silicon → GGUF Q4_K_M via Ollama or llama.cpp
  2. Single GPU development → GGUF Q4_K_M (Ollama) or BitsAndBytes 4-bit (HF Transformers)
  3. Production GPU serving → AWQ or GPTQ via vLLM or TGI
  4. Fine-tuning → QLoRA (BitsAndBytes 4-bit base model + FP16 adapters)
  5. Maximum quality, cost secondary → FP16 or BF16 full precision on a multi-GPU setup

For evaluation of quantized model quality, run your specific downstream task benchmarks — general quality numbers do not always translate to task-specific performance.


Llama and open-source LLM deployment questions come up in GenAI engineering interviews in two contexts: model selection questions (when would you use open-source over closed-source?) and system design questions (how would you deploy a self-hosted LLM at scale?). Here are the answers that signal real deployment experience.

Q1: When would you choose Llama over GPT-4o or Claude for a production system?

The right answer covers three dimensions: data privacy (regulated data cannot leave your infrastructure), cost at scale (self-hosted inference costs 5-8x less per token at high volumes than API pricing), and customization (QLoRA fine-tuning on proprietary data produces a model you fully own). The wrong answer is just “when you need open-source” — that tells the interviewer you have not thought through the tradeoffs.

A strong answer: “I’d choose Llama over a closed-source API in three situations. First, if the use case involves regulated data (HIPAA, PII, financial records) that legally cannot be sent to a third-party server. Second, if the volume is high enough that per-token API costs dominate the infrastructure budget — the break-even for self-hosting is typically around 1-5 million tokens per day depending on the model and cloud provider. Third, if we need to fine-tune on proprietary domain data and cannot share that data externally. Outside those three, the operational overhead of self-hosting — provisioning GPUs, managing model updates, handling failover — often outweighs the savings.”

Q2: How would you serve Llama 3.3 70B in production with low latency and high throughput?

The answer should cover vLLM’s PagedAttention, tensor parallelism, and continuous batching. “I’d use vLLM with tensor parallelism across 4 A100 80GB GPUs. vLLM’s PagedAttention solves the memory fragmentation problem that limits concurrency with naive implementations — it manages KV cache pages in blocks, reusing memory from completed sequences for new ones. This typically gives 2-4x higher throughput than HuggingFace Transformers serving at equivalent hardware. I’d serve it behind an OpenAI-compatible API endpoint so application code doesn’t change if we later need to swap the serving backend.”

Q3: Explain the difference between LoRA and QLoRA, and when you’d use each.

“LoRA (Low-Rank Adaptation) freezes the base model weights and adds small trainable matrices alongside specific linear layers. The rank r controls the expressiveness of the adapters — higher rank means more parameters, better fit, but slower training and larger adapters. QLoRA extends this by loading the base model in 4-bit NormalFloat quantization via BitsAndBytes. The quantized base model requires ~4x less VRAM, making it possible to fine-tune 8B models on a 24GB consumer GPU and 70B models on 2-4 A100s. I’d use LoRA when I have FP16 VRAM budget and want maximum adapter quality. I’d use QLoRA for practical fine-tuning under VRAM constraints — which is most of the time.”

Q4: What quantization format would you choose for Llama running on a Mac with 16GB unified memory?

“GGUF Q4_K_M via Ollama or llama.cpp. Apple Silicon has unified CPU/GPU memory — the 16GB limit applies to the whole system, not just GPU VRAM. Llama 3.1 8B at Q4_K_M uses about 5.1GB, leaving enough headroom for the OS and application. The _K_M suffix means K-quants with medium precision — better quality than naive 4-bit by preserving important weight clusters. If quality is the priority and memory allows, Q5_K_M at 5.7GB is the next step up. I’d avoid Q8_0 (8.5GB) on a 16GB machine as it leaves too little headroom for a comfortable development workflow.”


This guide covered the full Llama 3 model family, local deployment with Ollama and llama.cpp, fine-tuning with QLoRA, production hosting with vLLM and TGI, and quantization tradeoffs. Here is where to go deeper:

DecisionRecommendation
Just want to try Llama locallyollama pull llama3.1 + ollama run llama3.1
Best model for local devLlama 3.1 8B Instruct (Q4_K_M GGUF)
Best model for production inferenceLlama 3.3 70B Instruct
Fine-tuning on a single GPUQLoRA with PEFT + TRL, rank 16
Production servingvLLM with OpenAI-compatible API
Quantization defaultGGUF Q4_K_M for CPU/Mac, AWQ for GPU
Cloud hosting without self-managing GPUsTogether AI or Groq for Llama
  • LLM Fundamentals — Understand how transformer models work before deploying them
  • Fine-Tuning LLMs — When and how to fine-tune, LoRA vs full fine-tuning, dataset preparation
  • Fine-Tuning vs RAG — Decision framework for customization approaches
  • LLM Evaluation — How to measure and compare model quality in your specific domain

Last updated: March 2026. Llama model releases and third-party hosting pricing change frequently. Verify current model availability and pricing at the official sources linked above before production capacity planning.

Frequently Asked Questions

What is Meta's Llama model?

Llama is Meta's family of open-source large language models released under a permissive license. Unlike GPT-4o or Claude, Llama weights are publicly downloadable, meaning you can run the model locally on your own hardware, fine-tune it on proprietary data, and deploy it without per-token API costs. The Llama 3 generation includes models ranging from 1B parameters (Llama 3.2) up to 405B parameters (Llama 3.1), covering use cases from on-device inference to enterprise-grade applications.

How does Llama compare to GPT-4 and Claude?

Llama 3.1 70B and 3.3 70B are competitive with GPT-4o-mini and Claude Haiku on many benchmarks but are not yet at GPT-4o or Claude Opus level on complex reasoning tasks. The key difference is not just quality — it is control. With Llama you own the model: no rate limits, no per-token costs at inference time, no data leaving your infrastructure, and full freedom to fine-tune on proprietary data.

How do I run Llama locally?

The easiest way to run Llama locally is with Ollama. Install Ollama from ollama.ai, then run 'ollama pull llama3.1' followed by 'ollama run llama3.1' for an interactive shell, or use the OpenAI-compatible API at http://localhost:11434. For lower-level control and CPU inference, llama.cpp supports GGUF-quantized models and runs on Mac, Linux, and Windows without a GPU.

Can I fine-tune Llama on my own data?

Yes, fine-tuning is one of Llama's main advantages over closed-source models. The most practical approach is QLoRA using the Hugging Face PEFT and TRL libraries. QLoRA fine-tunes a 4-bit quantized version of the model using low-rank adapter weights, which means you can fine-tune Llama 3.1 8B on a single 24GB GPU in a few hours.

What is the difference between Llama 3.1, 3.2, and 3.3?

Llama 3.2 includes smaller models (1B and 3B parameters) designed for on-device and edge inference with 128K context windows. Llama 3.1 covers 8B, 70B, and 405B parameter sizes for local development through maximum-capability research tasks. Llama 3.3 70B is the current production sweet spot — it matches Llama 3.1 405B quality on most benchmarks at one-sixth the parameter count.

What is vLLM and why is it used for Llama production hosting?

vLLM is a high-throughput inference engine for LLMs that uses PagedAttention to manage GPU memory efficiently. PagedAttention reduces memory fragmentation during inference, enabling 2-4x higher throughput than naive Transformers serving on the same hardware. vLLM provides an OpenAI-compatible API, making it a drop-in replacement for hosted API calls in production deployments.

What quantization format should I use for Llama?

For CPU or Apple Silicon, use GGUF Q4_K_M via Ollama or llama.cpp — it offers the best balance of size and accuracy at about 97% of FP16 quality. For production GPU serving, use AWQ or GPTQ via vLLM or TGI. For fine-tuning, use QLoRA with BitsAndBytes 4-bit base model plus FP16 adapters. See our fine-tuning vs RAG guide for when to use each approach.

How much does it cost to run Llama vs using GPT-4o API?

A team processing 10 million tokens per day on GPT-4o spends roughly $25,000/month at API pricing. The same workload on self-hosted Llama 3.3 70B running on two A100 80GB GPUs costs approximately $3,000-$5,000/month — a 5-8x reduction. The break-even point where self-hosting becomes cheaper varies but typically lands between 1 and 5 million tokens per day.

What is the difference between Llama base and instruction-tuned models?

Base models are pretrained on raw text and complete text but do not reliably follow instructions. Instruction-tuned (Instruct) models are further fine-tuned with RLHF to follow instructions and support a chat interface. For almost all production use cases, use the Instruct variant. Base models are primarily used as starting points for custom fine-tuning.

Can Llama be used for RAG applications?

Yes, Llama works well as the generation component in RAG pipelines. You can run Llama locally via Ollama or vLLM as the LLM backend, paired with an embedding model and vector database for retrieval. The 128K context window in Llama 3.x models supports long retrieved passages. Self-hosted Llama is especially valuable for RAG when data privacy prevents sending retrieved documents to third-party APIs.