TExcelTAD

Choosing a Training Strategy

Twenty-six lessons, ten strategies. This lesson turns them into a decision: given a project, which strategy do you try first, what do you add, and what would make you change your mind? No flowchart replaces an experiment. What a good first choice buys you is a strong baseline in days instead of weeks, and a clear idea of which experiment to run next.

Six questions to ask first

Question Why it matters Points towards
Is there a pretrained model for a related task or modality? Reuse beats learning from zero when the features transfer yes: transfer learning; no: scratch or self-supervised pretraining
How many labelled examples, per class? Few labels cannot support many trainable parameters few: feature extraction; more: partial or full fine-tuning
How much unlabelled data, and can you pay for more labels? Raw data is cheap; labels are not semi-supervised, active learning
How big is the model compared with your memory and compute? Full fine-tuning of a 7B model needs over 100 GB LoRA, QLoRA, distributed training
Does the data arrive continuously, and does it change? A frozen model goes stale online learning, drift detection
How many tasks share the model, and how is it served? One backbone with many small heads or adapters is cheap to store and serve feature extraction, PEFT, adapters

Two more questions are not technical and come first in practice: may you use the pretrained weights (licence, and what data they were trained on), and may the data leave your premises (privacy, consent)? A model you may not ship is not an option, however accurate.

The decision flow

related pretrained model? no yes: 2 transfer 10k+ labels, or tabular? yes no 1 scratch big raw pool? (small model if no big raw pool) yes 6 self-supervised then fine-tune how many labels? how big is the model? fewer than ~500 labels4 feature extraction 500 to 5,000 labels5 partial fine-tuning 5,000+ labels3 full fine-tuning model too big3 LoRA, QLoRA, adapters then add, whatever the start, when it applies: unlabelled pool7 semi-supervised labelling budget8 active learning stream with drift9 online learning too slow or too big10 distributed

Read it top to bottom. The first question splits the course into its two halves: building a model's knowledge yourself (left) or reusing someone else's (right, which is what transfer learning means). The number of labels then decides how many parameters you can afford to train, from a linear head on frozen features to every weight. The bottom row is not an alternative to the top: semi-supervised, active, online and distributed training are added to whichever start you chose. The label thresholds (500, 5,000, 10,000) are rough orders of magnitude for a typical classification task, not rules; the number of classes, how close the pretrained domain is, and the model size all move them.

The same flow as code, applied to nine typical projects. Each answer is a first plan to validate, not a verdict:

python · try it yourself
def recommend(p):
    """A first plan from the decision flow; every answer is a starting point to validate, not a verdict."""
    plan = []
    if not p["pretrained"]:
        if p["labels"] >= 10_000 or p["tabular"]:
            plan.append("train from scratch")
        elif p["unlabelled"] >= 100_000:
            plan.append("self-supervised pretraining, then fine-tune")
        else:
            plan.append("train from scratch, small model")
    elif p["labels"] < 500:
        plan.append("feature extraction (frozen backbone + linear head)")
    elif p["params_m"] > 1000:
        plan.append("LoRA" if p["memory_ok"] else "QLoRA (4-bit base + LoRA)")
    elif p["labels"] < 5_000:
        plan.append("partial fine-tuning (top layers + head)")
    else:
        plan.append("full fine-tuning (small LR, warm-up, early stopping)")
    if 0 < p["labels"] < 5_000 and p["unlabelled"] > 10 * max(p["labels"], 1):
        plan.append("+ pseudo-labelling on the unlabelled pool")
    if p["label_budget"] > 0:
        plan.append("+ active learning for the next labels")
    if p["stream"]:
        plan.append("+ online updates with drift detection, replay and rollback")
    if p["gpu_days"] > 1:
        plan.append("+ distributed training (DDP; FSDP if it does not fit)")
    return "; ".join(plan)

base = dict(pretrained=True, tabular=False, labels=0, unlabelled=0, params_m=100, memory_ok=True,
            label_budget=0, stream=False, gpu_days=0)
projects = {
    "churn table, 200k rows":            dict(pretrained=False, tabular=True, labels=200_000),
    "300 X-rays, ImageNet CNN":          dict(labels=300, params_m=11),
    "support tickets, 2k labels, 7B LLM": dict(labels=2_000, params_m=7_000, memory_ok=False),
    "bird photos, 3k labels, ResNet-50":   dict(labels=3_000, params_m=25),
    "reviews, 50k labels, BERT-base":    dict(labels=50_000, params_m=110),
    "sensor signals, 1M unlabelled":     dict(pretrained=False, labels=800, unlabelled=1_000_000),
    "spam filter, live traffic":         dict(labels=20_000, params_m=22, stream=True),
    "defect photos, 150 labels, 40k raw, budget 500": dict(labels=150, unlabelled=40_000, label_budget=500, params_m=11),
    "web-scale pretraining":            dict(pretrained=False, labels=0, unlabelled=10**9, gpu_days=5000),
}
for name, override in projects.items():
    print(f"{name:48s} -> {recommend({**base, **override})}")
churn table, 200k rows                           -> train from scratch
300 X-rays, ImageNet CNN                         -> feature extraction (frozen backbone + linear head)
support tickets, 2k labels, 7B LLM               -> QLoRA (4-bit base + LoRA)
bird photos, 3k labels, ResNet-50                -> partial fine-tuning (top layers + head)
reviews, 50k labels, BERT-base                   -> full fine-tuning (small LR, warm-up, early stopping)
sensor signals, 1M unlabelled                    -> self-supervised pretraining, then fine-tune; + pseudo-labelling on the unlabelled pool
spam filter, live traffic                        -> full fine-tuning (small LR, warm-up, early stopping); + online updates with drift detection, replay and rollback
defect photos, 150 labels, 40k raw, budget 500   -> feature extraction (frozen backbone + linear head); + pseudo-labelling on the unlabelled pool; + active learning for the next labels
web-scale pretraining                            -> self-supervised pretraining, then fine-tune; + distributed training (DDP; FSDP if it does not fit)

Some readings. The churn table goes straight to training from scratch: tabular data has no useful pretrained backbone, and gradient-boosted trees or a small MLP are the norm. The 300 X-rays get feature extraction, the cheapest strategy that can work with so few labels, with fine-tuning as the next experiment if it falls short. The 7-billion-parameter LLM on a machine that cannot hold it in 16-bit gets QLoRA. The defect photos combine three strategies: a frozen backbone, pseudo-labels on the 40,000 raw photos, and active learning to spend the budget of 500 new labels. Web-scale pretraining is self-supervised and distributed by necessity.

What each choice costs

The trainable parameters decide memory, training time and how much each extra task costs to store. For an encoder the size of BERT-base (110 million parameters, 12 layers, width 768):

python · try it yourself
# Trainable parameters and per-task storage for a BERT-base-sized encoder (12 layers, d = 768)
d, layers, total = 768, 12, 110_000_000
per_layer = 12 * d * d + 13 * d                 # attention (4 d x d) + MLP (2 x d x 4d) + biases and norms
head = d * 2 + 2                                # a 2-class linear head
lora_r = 8
options = {
    "full fine-tuning":                 total + head,
    "partial: top 2 layers + head":     2 * per_layer + head,
    "LoRA r=8 on W_q, W_v + head":      layers * 2 * lora_r * (d + d) + head,
    "prompt tuning, 20 virtual tokens": 20 * d + head,
    "feature extraction (head only)":   head,
}
print(f"{'strategy':34s} {'trainable':>12s} {'share':>8s} {'stored per task':>16s}")
for name, n in options.items():
    print(f"{name:34s} {n:12,d} {n / (total + head):8.3%} {n * 4 / 1e6:13.2f} MB")
strategy                              trainable    share  stored per task
full fine-tuning                    110,001,538 100.000%        440.01 MB
partial: top 2 layers + head         14,177,282  12.888%         56.71 MB
LoRA r=8 on W_q, W_v + head             296,450   0.269%          1.19 MB
prompt tuning, 20 virtual tokens         16,898   0.015%          0.07 MB
feature extraction (head only)            1,538   0.001%          0.01 MB

From full fine-tuning to a linear head the trainable parameters shrink by five orders of magnitude, and with them the storage per task: 440 MB for a full copy, about 1 MB for a LoRA adapter, kilobytes for a head. Accuracy does not shrink in proportion. On many tasks LoRA comes close to full fine-tuning, and feature extraction is competitive when the pretrained features already separate the classes (see peft-overview and the LoRA lessons). Training compute does not fall as much as the parameter count: LoRA and partial fine-tuning still run the full forward pass and most of the backward pass; feature extraction runs the backbone once and never again.

The strategies side by side

Strategy Labels Compute Strength Main risk Lessons
Scratch many high no inherited bias or licence; fits any input overfits small data workflow
Feature extraction few lowest fast, convex, one backbone for many tasks ceiling when the features do not fit the task frozen backbone, sentence embeddings, ResNet-18
Partial fine-tuning moderate medium adapts the top layers to the domain choosing what to freeze frozen and partial
Full fine-tuning moderate to many high best accuracy when data allows forgetting, instability, one full copy per task recipe, forgetting
PEFT: LoRA, QLoRA, adapters, prompts moderate low to medium big models on small hardware, tiny per-task files rank and placement choices; quantisation error overview, LoRA, PEFT library, QLoRA, adapters and prompts
Self-supervised pretraining none (then few) very high a backbone for a domain nobody has pretrained cost; pretext task must match the downstream need pretext and masked, contrastive
Semi-supervised few + unlabelled low to medium uses cheap raw data confirmation bias from wrong pseudo-labels pseudo-labelling, consistency, teacher-student
Active learning a budget low per round more accuracy per label biased labelled set; humans in the loop query strategies, labelling loop
Online learning a stream low per update stays current drift, forgetting, poisoned updates partial_fit, drift, replay and rollback
Distributed any many devices makes big runs feasible communication, failures, changed batch size data parallel, model, pipeline, tensor, DDP and checkpoints

How to run the decision as experiments

  1. Fix the evaluation first: the split that matches deployment, the metric, a baseline (majority class, a simple model), and a test set you will look at once. Without it no comparison below means anything.
  2. Start with the cheapest strategy that could work. Usually feature extraction with a linear head; for tabular data, a boosted tree from scratch. It takes minutes and sets the bar.
  3. Plot a label curve (accuracy against the number of labels, as in the introduction). Still rising steeply? More labels, active learning or semi-supervised learning will pay. Flat? Labels are not the bottleneck; a stronger strategy or model is.
  4. Move one step up in cost only if the validation gap to your target justifies it: partial fine-tuning or LoRA, then full fine-tuning. Keep the cheaper model as the fallback.
  5. Decide on operations before you ship: how the model is updated (retrain on a schedule, or online with drift detection), how a bad update is rolled back, and what it costs to run.

The exercises practise these decisions across the whole course, and the mini project runs steps 1 to 4 on one task: training from scratch, feature extraction and LoRA compared on the same split.

Pitfalls

  • Choosing by fashion. A 7B-parameter LLM with LoRA for a problem a logistic regression on TF-IDF solves at 0.95 is cost without benefit. Always run the cheap baseline.
  • Comparing strategies on different splits or on the test set. Every comparison in this course used the same validation data for all candidates and touched the test set once.
  • Ignoring noise. On 100 test examples, one prediction is a whole point. Repeat with a few seeds, or use cross-validation, before you declare a winner.
  • Treating the thresholds as rules. 500 labels for 2 classes is plenty; for 200 classes it is 2.5 per class.
  • Forgetting the domain gap. Transfer from ImageNet to medical scans or from web text to legal text helps less; when it fails, negative transfer is possible and scratch or self-supervised pretraining wins.
  • Forgetting the life after training. A model trained once on last year's data, with no plan for drift, will be wrong next year.

Practice

  1. A hospital has 1,200 labelled ECG recordings (5 classes), 80,000 unlabelled ones, and no public model for ECG signals. It may not send data outside. Sketch a strategy.
  2. A company wants 40 text classifiers (one per department) on top of one 3-billion-parameter language model, each with 1,000 to 3,000 labels. Which strategy keeps storage and serving manageable?
  3. Feature extraction with a linear head gives 0.81 validation accuracy; the label curve is still rising steeply at your 400 labels. What next?
  4. Why does the decision flow put distributed training in the "add" row rather than among the starting strategies?
Answers
  1. No pretrained model and too few labels for a large network from scratch, but a large unlabelled pool: self-supervised pretraining on the 80,000 recordings (for example masked modelling or contrastive learning), then fine-tune on the 1,200 labels; add pseudo-labelling, and active learning if cardiologists can label more. Everything runs on-premises.
  2. Parameter-efficient fine-tuning: one shared base model and one LoRA adapter (or adapter module) per department, a few megabytes each. Serving loads the base once and swaps adapters per request; full fine-tuning would need 40 full copies.
  3. Labels are still the bottleneck: get more of them, efficiently. Active learning picks the most informative examples to label, and semi-supervised learning can use the unlabelled pool. Moving to fine-tuning is the other experiment, but with 400 labels it risks overfitting.
  4. Distributed training does not change what is learned, only how fast and how big. It is added to whichever strategy needs more compute or memory than one device has.

Test yourself

You have 150 labelled images and a pretrained CNN for a similar kind of photo. What is the natural first experiment?

  1. Full fine-tuning of every layer
  2. Training a new CNN from scratch
  3. Feature extraction: frozen backbone and a linear classifier
  4. Distributed training

Which strategies are usually added on top of a starting strategy rather than chosen instead of it?

  1. Scratch and fine-tuning
  2. Semi-supervised, active, online and distributed training
  3. Feature extraction and LoRA
  4. Only distributed training

Twenty tasks share one large pretrained model. Why is LoRA attractive compared with full fine-tuning?

  1. It is always more accurate
  2. Each task stores only a small adapter (megabytes) instead of a full copy of the model
  3. It needs no labels
  4. It removes the need for a validation set

Your label curve is flat: going from 1,000 to 2,000 labels changed validation accuracy by 0.2 points. What does that suggest?

  1. Label many more examples
  2. Labels are not the bottleneck; try a stronger strategy or model, or look at label quality
  3. Switch to online learning
  4. Stop using a validation set