Skip to content

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.

ModelProviderStrengthsContext
Claude Opus 4AnthropicComplex reasoning, coding200K tokens
Claude Sonnet 4AnthropicBalanced performance/cost200K tokens
Claude Haiku 4AnthropicHigh speed, low cost200K tokens
GPT-4oOpenAIMultimodal, general-purpose128K tokens
Gemini 2.0 FlashGoogleMultimodal, speed1M tokens
Llama 3.3MetaOpen-source, self-hosted128K 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:

TechniqueWhat it doesWhen to reach for itRelative cost
SFT (Supervised Fine-Tuning)Trains on labeled prompt/response pairs to teach a task or an output formatYou have curated examples of exactly what you want backHighest — full-weight training
LoRAFreezes the base weights and trains small low-rank adapter matrices insteadThe same goal as SFT at a fraction of the memory; adapters can be swapped per taskModerate
QLoRALoRA on top of a 4-bit quantized base modelFine-tuning a model on a single GPU that could not otherwise hold itLow
DPO (Direct Preference Optimization)Trains on chosen/rejected response pairs to align preference directly, with no separate reward modelOutput is already task-correct but the tone, safety, or style is wrongModerate

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 degradation

Recommended tools: llama.cpp, GPTQ, AWQ, bitsandbytes