tensorturnBETA
Home › Machine Learning Tasks

How to Fine-Tune a Pretrained Model on Your Own Data

To fine-tune a pretrained model, you start from weights already trained on a large dataset (ImageNet for vision backbones, large text corpora for BERT-style transformers, COCO for YOLO), replace the output layer for your classes, and continue training on your labeled data with a small learning rate. On TensorTurn you describe this in chat and it generates and runs the fine-tuning notebook in PyTorch, Keras, Ultralytics YOLO or Hugging Face transformers on a cloud GPU or your own GPU. Fine-tuning usually beats training from scratch whenever your dataset is in the hundreds or low thousands of examples.

What fine-tuning actually does

A pretrained network has already learned general features: edges, textures and shapes for images, grammar and word meaning for text, objectness for detectors. Fine-tuning keeps those features and adapts them to your task. You swap the final layer (the 'head') for one with your number of classes, then train either just that head or the whole network for a few epochs. Because the model is not learning everything from zero, it needs far less data and compute, and it converges in minutes to hours instead of days.

Fine-tune or train from scratch?

SituationBetter choiceWhy
A few hundred to tens of thousands of labeled images or documentsFine-tunePretrained features fill the gap your data cannot
Natural photos, everyday objects, general-domain textFine-tuneClose to what the backbone was pretrained on
Very different domain (radar, spectrograms, microscopy) with lots of dataTry bothPretrained features transfer less well, but still often help as initialisation
Tabular data (rows and columns)Train from scratchGradient boosting such as XGBoost or LightGBM usually wins; there is no general pretrained tabular backbone to fine-tune
Millions of labeled examples and a custom architectureTrain from scratch is viableEnough data to learn features directly
Tight inference budget on small devicesFine-tune a small modelStart from a compact pretrained model rather than shrinking a large one

Which pretrained models to start from

Fine-tuning strategies and learning rates

The learning rate is the setting that most often makes or breaks a fine-tune. Too high and you destroy the pretrained features in the first epoch, a failure known as catastrophic forgetting. Too low and the head never adapts. The table gives common starting points, not guarantees; tune from there.

StrategyWhat is trainedTypical learning rateUse when
Feature extraction (linear probe)Only the new head; backbone frozen1e-3 with AdamVery small dataset, or a quick baseline
Partial fine-tuneHead plus the last few blocks1e-4 for unfrozen blocks, 1e-3 for the headModerate data, domain somewhat different
Full fine-tune (CNN or ViT)All layers1e-4 to 1e-5 with Adam or AdamWEnough data and a GPU
Full fine-tune (BERT-style)All layers2e-5 to 5e-5 with AdamW, linear warmupText classification, NER, sentiment
YOLO fine-tuneWhole detector from COCO weightsUltralytics defaults are a good startCustom object detection

Two habits help almost every fine-tune: a short warmup so early large gradients do not wreck the weights, and lower learning rates for earlier layers than for later ones (discriminative learning rates). Use early stopping on validation loss, because small datasets overfit quickly, often within 3 to 10 epochs.

How much data do you need?

There is no fixed number, but useful rules of thumb exist. For image classification, a few hundred well-labeled images per class usually gives a working model when fine-tuning, and accuracy keeps improving into the thousands. For YOLO, aim for a few hundred labeled instances per class with varied backgrounds, lighting and scale. For text classification, a few hundred examples per class is a reasonable start for a fine-tuned transformer. Balance matters as much as size: ten examples of a rare class will be learned poorly whatever the backbone.

Common fine-tuning mistakes

How to fine-tune a model on TensorTurn

TensorTurn does not offer a dedicated large language model fine-tuning product. Because every run is generated Python, standard libraries such as Hugging Face transformers can be used inside the notebook, but plan GPU memory accordingly for large models.

Start building free

Frequently asked questions

What is the difference between fine-tuning and transfer learning?

Transfer learning is the general idea of reusing knowledge from one task on another. Fine-tuning is the most common way to do it: you continue training some or all of a pretrained model's layers on your own labeled data, usually with a small learning rate.

What learning rate should I use for fine-tuning?

Common starting points are 2e-5 to 5e-5 with AdamW for BERT-style transformers, 1e-4 to 1e-5 for fully fine-tuning a CNN or ViT, and around 1e-3 when only training a new head on a frozen backbone. Use warmup and early stopping, then tune from there.

Can I fine-tune YOLO on my own images?

Yes. Upload images with bounding-box labels, ask for a YOLO fine-tune in chat, and TensorTurn runs Ultralytics training starting from pretrained weights, then reports mAP. You can deploy the result as a /predict endpoint.

Can I fine-tune a large language model on TensorTurn?

There is no dedicated LLM fine-tuning feature. The notebooks are generated Python, so Hugging Face transformers can be used inside them, which suits BERT-style models well; very large models are limited by the GPU memory available to the run.

Should I freeze layers when fine-tuning?

With very little data, freeze the backbone and train only the head first. With more data, unfreeze the later layers or the whole model at a lower learning rate. Gradual unfreezing is a safe default when you are unsure.