Model Selection & Tuning
Selecting the right LLM for the purpose, plus fine-tuning and quantization strategies
Model Selection Framework
flowchart TD
A["Requirements analysis"] --> B{"Data security"}
B -->|"Internal data cannot leave"| C["Self-hosted<br/>open-source model"]
B -->|"External API allowed"| D{"Task complexity"}
D -->|"Simple classification/summarization"| E["Small model<br/>Claude Haiku / GPT-4o-mini"]
D -->|"Complex reasoning"| F["Large model<br/>Claude Opus / GPT-4o"]
D -->|"Domain-specific"| G["Consider fine-tuning"]
style A fill:#1E3A5F,stroke:#1E3A5F,color:#fff
style C fill:#EA580C,stroke:#C2410C,color:#fff
style E fill:#16A34A,stroke:#15803D,color:#fff
style F fill:#2563EB,stroke:#1D4ED8,color:#fff
style G fill:#7C3AED,stroke:#6D28D9,color:#fff
Major LLM Comparison (2025)
For real-time, objective metrics on performance, cost, and latency, see the AI Model Benchmarking page.
| Model | Provider | Strengths | Context |
|---|---|---|---|
| Claude Opus 4 | Anthropic | Complex reasoning, coding | 200K tokens |
| Claude Sonnet 4 | Anthropic | Balanced performance/cost | 200K tokens |
| Claude Haiku 4 | Anthropic | High speed, low cost | 200K tokens |
| GPT-4o | OpenAI | Multimodal, general-purpose | 128K tokens |
| Gemini 2.0 Flash | Multimodal, speed | 1M tokens | |
| Llama 3.3 | Meta | Open-source, self-hosted | 128K tokens |
Tuning Strategy Comparison
Prompt Engineering
- Best fit: rapid prototyping, small data volumes
- Cost: Low
- Effect: Moderate
RAG (Retrieval-Augmented Generation)
- Best fit: incorporating up-to-date information, injecting domain knowledge
- Cost: Moderate
- Effect: High (knowledge accuracy)
Fine-Tuning
- Best fit: specific style/format, large-scale repetitive tasks
- Cost: High (upfront investment)
- Effect: High (style consistency)
Fine-tuning is not a single technique. Which one applies depends on what you are trying to move — the task, or the preference:
| Technique | What it does | When to reach for it | Relative cost |
|---|---|---|---|
| SFT (Supervised Fine-Tuning) | Trains on labeled prompt/response pairs to teach a task or an output format | You have curated examples of exactly what you want back | Highest — full-weight training |
| LoRA | Freezes the base weights and trains small low-rank adapter matrices instead | The same goal as SFT at a fraction of the memory; adapters can be swapped per task | Moderate |
| QLoRA | LoRA on top of a 4-bit quantized base model | Fine-tuning a model on a single GPU that could not otherwise hold it | Low |
| DPO (Direct Preference Optimization) | Trains on chosen/rejected response pairs to align preference directly, with no separate reward model | Output is already task-correct but the tone, safety, or style is wrong | Moderate |
A workable order of escalation: exhaust prompt engineering, then RAG, and only then fine-tune — SFT or LoRA/QLoRA to teach the task, DPO on top to shape preference. QLoRA depends on the quantization choices below, so treat those two decisions as one.
Quantization
Quantization strategies for reducing VRAM usage when self-hosting open-source models:
FP32 → FP16: 50% VRAM reduction, negligible performance loss
FP16 → INT8: another 50% VRAM reduction, minor performance degradation
INT8 → INT4: another 50% VRAM reduction, caution — noticeable performance degradationRecommended tools: llama.cpp, GPTQ, AWQ, bitsandbytes