Methodology

Fine-tuning

Why Fine-tuning Is Needed

A general-purpose LLM is like a "jack of all trades" — it can write, translate, code, and chat, but in your specific business scenario, its performance may fall short:

  • It doesn't understand your industry jargon and internal abbreviations
  • Its response style doesn't match your brand voice
  • You always need to pack the Prompt with background context to get acceptable results
  • Accuracy on certain tasks (classification, extraction, judgment) isn't high enough

Fine-tuning solves this: using your data to train a general model into "your own specialist model."


What Is Fine-tuning

One-line definition: Fine-tuning is the technique of continuing to train an already-trained large model on domain-specific or task-specific data, so the model performs better in that scenario.

Analogy: A general model is like a fresh graduate — has the basics but isn't specialized in anything. Fine-tuning is "onboarding training" — using your company's cases, standards, and processes to train it into a ready-to-work employee.

Fine-tuning vs. Prompt Engineering:

DimensionPrompt EngineeringFine-tuning
MethodGive instructions and examples in the inputTrain the model itself with data
What changesThe input the model seesThe model's parameter weights
PersistenceMust write the Prompt every timeOne-time training, permanent effect
CostZero, adjust anytimeRequires training resources and data
Use caseRapid iteration, lightweight adjustmentsDeep customization, high-frequency tasks

Simple rule: try Prompt Engineering first, resort to Fine-tuning only when that's not enough.


Main Fine-tuning Approaches

Full Fine-tuning

Updates all model parameters with your data. Best results, but highest cost — requires massive GPU memory, typically only feasible for large organizations.

LoRA / QLoRA (Parameter-Efficient Fine-tuning)

Only trains a small "adapter" layer of parameters while freezing the original model. Results are close to full fine-tuning, but at a fraction of the cost — a single consumer GPU can handle it.

This is currently the most common Fine-tuning approach.

RLHF (Reinforcement Learning from Human Feedback)

Humans rank and score model outputs, and reinforcement learning teaches the model to produce "what humans consider good answers." ChatGPT's alignment with human preferences relies on RLHF.


How to Do It: When to Use Fine-tuning

Scenarios suited for Fine-tuning:

  • Domain-specific text understanding (medical, legal, financial terminology)
  • Specific output formats (always following a template or JSON schema)
  • Consistent style (brand tone, customer service scripts, terminology habits)
  • High-frequency tasks needing higher accuracy (classification, entity extraction, sentiment analysis)
  • Needing to compress model size (train a small model using data from a large model)

Scenarios not needing Fine-tuning:

  • General Q&A and conversation — Prompt Engineering is enough
  • Infrequently used tasks — writing a good Prompt is more cost-effective than training a model
  • Too little data (fewer than a few hundred examples) — Fine-tuning may not help and can cause overfitting

Common pitfalls:

  • Data quality matters more than quantity: 100 high-quality examples > 10,000 noisy ones
  • More tuning isn't always better: excessive Fine-tuning causes the model to "forget" general capabilities (catastrophic forgetting)
  • Need an evaluation framework: without metrics, you can't tell if tuning improved anything
  • Fine-tuning can't solve everything: if Prompt Engineering + RAG works, you don't need Fine-tuning

Typical Fine-tuning Workflow

1. Collect data: Prepare "input → expected output" paired examples
    ↓
2. Clean data: Deduplicate, remove noise, standardize formats
    ↓
3. Choose base model: Select based on task complexity and budget
    ↓
4. Train: Fine-tune with LoRA or full fine-tuning
    ↓
5. Evaluate: Validate on test set, compare against Prompt Engineering approach
    ↓
6. Deploy: Replace original model or serve as a specialized model

Remember this: Fine-tuning is "training your model with your data" — when Prompt Engineering isn't enough, it turns a general model into a domain expert.

Related terms: Prompt Engineering · Embedding · Token