Model Finetuning
Model Finetuning
Finetune pre-trained models on your own data to achieve high accuracy on your specific task. Start from a foundation model and adapt it to your domain.
What is Finetuning?
Finetuning takes a model that was pre-trained on a large dataset and continues training it on your smaller, task-specific dataset. This gives you:
- Better accuracy than training from scratch
- Less data required (hundreds instead of millions of examples)
- Faster training (minutes to hours instead of days)
- Domain expertise the base model didn’t have
graph LR
A[Pre-trained Model
General Knowledge] --> B[Your Dataset
Domain-Specific]
B --> C[Finetuned Model
Your Task Expert]
style A fill:#e0f2fe
style B fill:#fef3c7
style C fill:#d1fae5When to Finetune
| Scenario | Recommendation |
|---|---|
| Standard task, enough labeled data | Finetune a pre-trained model |
| Very specific domain (medical, legal) | Finetune with domain data |
| Limited labeled data (<100 examples) | Use few-shot or consider LLM |
| Need maximum accuracy | Finetune + hyperparameter tuning |
| Need fast inference | Finetune small model or distill |
Guide Sections
1. Prepare Data
2. Choose Base Model
3. Configure Training
4. Train & Monitor
5. Evaluate Results
6. Iterate & Improve
Quick Start
1. Prepare Your Dataset
from seeme import Client
client = Client()
## Create a dataset
dataset = client.create_dataset(
name="Product Defect Classifier",
task_type="image_classification"
)
version = client.create_dataset_version(
dataset_id=dataset.id,
name="v1"
)
# Create splits
train_split = client.create_split(version_id=version.id, name="train")
val_split = client.create_split(version_id=version.id, name="validation")
# Create labels
labels = ["good", "scratch", "dent", "discoloration"]
for label_name in labels:
client.create_label(version_id=version.id, name=label_name)
# Upload and label data
for image_path, label in training_data:
item = client.create_dataset_item(
version_id=version.id,
split_id=train_split.id,
file_path=image_path
)
client.annotate(
dataset_id=dataset.id,
dataset_version_id=version.id,
annotation=Annotation(
item_id=item.id,
split_id=train_split.id,
label_id=label
)
)2. Start Training
# Create finetuning job
job = client.create_job(
dataset_id=dataset.id,
version_id=version.id,
name="Defect Classifier v1",
job_type="finetune",
config={
"base_model": "efficientnet_b0", # Pre-trained model
"epochs": 20,
"learning_rate": 0.001,
"batch_size": 32,
"image_size": 224,
"freeze_layers": "early", # Freeze early layers
"augmentation": {
"horizontal_flip": True,
"rotation": 15,
"brightness": 0.2
}
}
)
print(f"Training job started: {job.id}")3. Monitor Progress
import time
while job.status in ["pending", "running"]:
time.sleep(30)
job = client.get_job(job.id)
if job.metrics:
print(f"Epoch {job.metrics.get('epoch', '?')}: "
f"loss={job.metrics.get('loss', '?'):.4f}, "
f"accuracy={job.metrics.get('accuracy', '?'):.2%}")
print(f"Training complete: {job.status}")
if job.status == "completed":
model = client.get_model(job.model_id)
print(f"Model accuracy: {model.metrics['accuracy']:.2%}")Supported Task Types
| Task | Base Models | Data Required |
|---|---|---|
| Image Classification | EfficientNet, ResNet, MobileNet, ViT | 100-1000+ images per class |
| Object Detection | YOLOv4, YOLOv5, Faster R-CNN | 100-500+ annotated images |
| Text Classification | BERT, DistilBERT, RoBERTa | 100-1000+ examples per class |
| Named Entity Recognition | spaCy, BERT-NER | 500-2000+ annotated sentences |
| Tabular | XGBoost, LightGBM, CatBoost | 1000+ rows |
Finetuning vs. Other Approaches
| Approach | When to Use | Data Needed | Training Time |
|---|---|---|---|
| Finetuning | Task-specific accuracy needed | 100-10,000 | Minutes-Hours |
| Training from scratch | Unique architecture needed | 10,000+ | Hours-Days |
| Transfer learning | Similar task to base model | 50-500 | Minutes |
| Few-shot (LLM) | Very limited data | 5-50 | None |
| Distillation | Need smaller/faster model | Labeled by teacher | Hours |
Best Practices
- Start with a good base model - Choose one trained on similar data
- Use the right learning rate - Lower than training from scratch (0.0001-0.001)
- Freeze early layers - Keep general features, train task-specific ones
- Augment your data - Especially if dataset is small
- Monitor for overfitting - Watch validation loss diverge from training loss
- Save checkpoints - Keep models from different epochs
- Test on held-out data - Never evaluate on training data
Next Steps
Start with Prepare Data to get your dataset ready for finetuning.