Techniques

Fine-Tuning

Tinh chỉnh mô hình (Fine-tuning)

Continued training of a pretrained model on a smaller, domain-specific dataset to adapt its behavior.

Fine-tuning takes a large pretrained model and continues training it — typically with a much smaller, curated dataset — to shift its behavior toward a specific task, style, or domain.

**How it works**

A foundation model (like GPT-3.5 or Llama 3) already understands language broadly. Fine-tuning updates the model's weights by running additional gradient descent steps on your examples. The result is a model that retains general language understanding but exhibits the specific behaviors you reinforced.

**Common use cases**

- *Style adaptation*: Train a model to always respond in your brand's tone. - *Task specialization*: Train a model to produce structured JSON output reliably, or to classify emails into categories. - *Domain knowledge*: Train on medical, legal, or technical documents so the model uses correct terminology and conventions. - *Instruction following*: RLHF (Reinforcement Learning from Human Feedback) is a form of fine-tuning used to make models helpful, harmless, and honest.

**Fine-tuning vs RAG**

RAG is faster to set up and keeps knowledge separate from the model. Fine-tuning bakes knowledge and behaviors into weights, making inference faster (no retrieval step) but updates require retraining. They're often combined: fine-tune for style, RAG for factual grounding.

**Pitfalls**

Fine-tuning on small datasets causes overfitting — the model memorizes training examples and fails on slightly different inputs. It can also cause catastrophic forgetting, where the model loses capabilities it had before. And it's expensive: compute, data curation, and iteration all cost time and money.