Part 9 of 15 in LLM fine-tuning techniques

Multi-task tuning trains one language model on a mixture of tasks, such as translation, summarization and classification, instead of one task at a time. It is a family of methods, not one paper: the three studies below, from Microsoft (MT-DNN, 2019), Google (T5, 2019) and the BigScience workshop (T0, 2021), each tested a different version of the idea and reported different results.

82.7%
GLUE score, MT-DNN
Liu et al., 2019, Table 2
9 of 11
held-out datasets where T0 matched or beat GPT-3
Sanh et al., 2021, Sec. 6
83.11 vs 83.28
GLUE avg, multi-task pre-train + fine-tune vs baseline
Raffel et al., 2019, Table 12

What is multi-task tuning?

Multi-task tuning is training a single model on examples from several tasks in the same run, so most or all parameters are shared across tasks. T5's authors describe it as training "on multiple tasks at a time", and note that in a text-to-text model it "simply corresponds to mixing data sets together" (Raffel et al., 2019, Sec. 3.5.2).

The idea is older than LLMs; T5 cites Caruana (1997) and Ruder (2017) for it. Three variants matter for LLM fine-tuning today:

VariantWhat gets mixedExample paper
Multi-task fine-tuning with task headsLabeled NLU tasks, each with its own output layer on a shared encoderMT-DNN (Liu et al., 2019)
Text-to-text multi-task trainingUnsupervised and supervised tasks as plain text with a task prefixT5 (Raffel et al., 2019)
Multitask prompted trainingMany datasets rewritten as natural-language prompts, tested on held-out tasksT0 (Sanh et al., 2021)

The third variant overlaps with instruction tuning (Part 8): both train on many tasks phrased in natural language so the model can do new ones zero-shot.

How does multi-task tuning work?

Multi-task tuning works by putting every task in one training stream and deciding how often to sample each task. In T5 every task becomes text in, text out, with a prefix naming the task; the open design choice is the mixing rate, because large datasets can crowd out small ones (Raffel et al., 2019, Sec. 3.5.2).

Diagram: four tasks written as text with task prefixes (translate, summarize, cola, stsb) feed a data mixer that caps large datasets at K, which trains one shared model; a table lists T5 GLUE averages for three training options

Step 1: put every task in the same format

T5 turns each task into a string with a prefix. From the paper's Figure 1: translate English to German: That is good. maps to Das ist gut., and cola sentence: The course is jumping well. maps to not acceptable. Even the regression task STS-B outputs a number as text (3.8). One model, one loss and one decoding procedure then serve every task (Raffel et al., 2019, Sec. 2.4).

MT-DNN does it differently. It keeps a shared lexicon encoder and Transformer encoder (initialized from BERT) and adds a task-specific output layer for each of four task types: single-sentence classification, pairwise text classification, text similarity scoring and relevance ranking (Liu et al., 2019, Sec. 2-3).

Step 2: choose a mixing rate

T5 compared three ways to set how often each task is sampled (Sec. 3.5.2):

  • Examples-proportional mixing. Sample each task in proportion to its size, but cap every dataset at an artificial limit K. The rate for task m is r_m = min(e_m, K) / Σ_n min(e_n, K), where e_n is the number of examples in task n. Without the cap, the unsupervised C4 data, "orders of magnitude larger" than every other task, would take nearly every batch.
  • Temperature-scaled mixing. Raise each rate to the power 1/T and renormalize. T = 1 equals examples-proportional mixing; larger T moves toward equal mixing.
  • Equal mixing. Sample every task with the same probability. The paper includes it "as a point of reference of what might go wrong".

Worked example (our arithmetic, using T5's formula). Mix a 116,722-example summarization set (trl-lib/tldr) with a 7,473-example math set (GSM8K):

RuleSummarization shareMath share
Proportional, no cap116,722 / 124,195 = 94.0%6.0%
Proportional, K = 16,38416,384 / 23,857 = 68.7%31.3%
Equal mixing50%50%

The cap is what lets the small task get seen. T5 found that for most tasks there is a "sweet spot" for K, with worse results above or below it.

Step 3: train, and optionally fine-tune per task

MT-DNN's Algorithm 1 packs each dataset into mini-batches, merges and shuffles all of them each epoch, and updates the model on one task's mini-batch at a time with that task's loss, which "approximately optimizes the sum of all multi-task objectives" (Liu et al., 2019, Sec. 3.1). It then fine-tunes on each GLUE task. T5 tested the same "multi-task pre-train, then fine-tune" recipe and used it for its final models (Sec. 3.7).

When was multi-task tuning introduced, and by whom?

Multi-task learning dates back at least to Caruana (1997), as T5 notes. For Transformer language models, the three papers most cited for it are:

PaperAuthorsFirst on arXivVenue
Multi-Task Deep Neural Networks for Natural Language UnderstandingXiaodong Liu, Pengcheng He, Weizhu Chen, Jianfeng Gao (Microsoft)Jan. 31, 2019ACL 2019
Exploring the Limits of Transfer Learning with a Unified Text-to-Text TransformerColin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu (Google)Oct. 23, 2019JMLR 21 (2020)
Multitask Prompted Training Enables Zero-Shot Task GeneralizationVictor Sanh, Albert Webson and 39 co-authors, ending with Alexander M. RushOct. 15, 2021ICLR 2022 (spotlight)

MT-DNN extends an earlier multi-task model by Liu et al. (2015) by adding BERT as the shared encoder (abstract).

What results did the multi-task papers report?

They point in different directions, so each claim below is tied to its own paper.

MT-DNN: multi-task learning beat single-task BERT. MT-DNN set new state-of-the-art results on ten NLU tasks, including SNLI, SciTail and eight of nine GLUE tasks, and lifted the GLUE benchmark to 82.7%, which the authors call a 2.2% absolute improvement over BERT-large (Liu et al., 2019, Table 2). The gains were largest on small tasks. In domain adaptation with 0.1% of SNLI's training data (549 examples), MT-DNN reached 82.1% accuracy against BERT's 52.5% (Table 4).

T5: multi-task training alone did worse; adding fine-tuning closed the gap. "In general, we find that multi-task training underperforms pre-training followed by fine-tuning on most tasks" (Raffel et al., 2019, Sec. 3.5.2). The numbers from Table 12:

Training strategy (T5 baseline model)GLUECNN/DMSQuADSuperGLUEEn-De
Unsupervised pre-training + fine-tuning83.2819.2480.8871.3626.98
Multi-task training81.4219.2479.7867.3025.21
Multi-task pre-training + fine-tuning83.1119.1280.2671.0327.08
Leave-one-out multi-task training81.9819.0579.9771.6826.93
Supervised multi-task pre-training79.9318.9677.3865.3626.81

Equal mixing did worst of the mixing rules: 76.13 GLUE against 83.28 for the baseline (Table 11). Among temperature settings, T = 2 "performing the best in most cases". The "leave-one-out" row matters for transfer: training on every task except the target one, then fine-tuning on it, was "only slightly worse", which the authors read as evidence that multi-task pre-training "might not result in a dramatic task interference".

T0: multitask prompted training generalized zero-shot. T0 starts from the 11B-parameter LM-adapted T5 and trains on 62 datasets across 12 tasks written as prompts from P3, a collection of 2,073 prompts for 177 datasets (Sanh et al., 2021, Sec. 3-5). With four task types held out entirely (natural language inference, coreference, sentence completion, word sense disambiguation), T0 "matches or exceeds the performance of all GPT-3 models on 9 out of 11 held-out datasets", despite being about 16x smaller than the 175B GPT-3. It improved over a large baseline language model on 13 of 14 BIG-bench tasks. Training used batches of 1,024 sequences, Adafactor and a learning rate of 1e-3; all runs took about 270 hours on a v3-512 Cloud TPU device (Sec. 5 and appendix).

How is multi-task tuning different from instruction tuning and federated tuning?

Multi-task tuning is about which tasks go into one training run; instruction tuning is about phrasing those tasks as instructions so the model follows new ones; federated tuning is about where the data sits. T0 sits on the line between the first two: it is multi-task training with prompts, evaluated zero-shot (Sanh et al., 2021).

Multi-task tuningInstruction tuningFederated tuning
Main questionWhich tasks, mixed how?How are tasks phrased?Where does training happen?
Typical dataLabeled datasets, often with task prefixes or headsMany tasks written as natural-language instructionsData held privately by many clients
Goal tested in the papersBetter per-task scores (MT-DNN, T5) or zero-shot transfer (T0)Zero-shot on unseen tasksUse data that cannot be pooled
Weights trainedUsually all (MT-DNN, T5, T0 fine-tune the full model)Usually allOften only adapters such as LoRA

Multi-task tuning is also not a parameter-efficient method by itself. It can be combined with one, such as LoRA or prompt tuning.

Which libraries support multi-task tuning?

No library ships a dedicated "multi-task trainer", because in the text-to-text setup multi-task tuning is a data-mixing step followed by ordinary fine-tuning (Raffel et al., 2019, Sec. 3.5.2). Two official Hugging Face pieces cover both steps:

  • Hugging Face Datasets provides interleave_datasets, which builds one dataset from several sources, sampling "from a random source at a time according to the provided probabilities". Its stopping_strategy is first_exhausted by default (stop when one source runs out), or all_exhausted (oversample until every source has been seen once), or all_exhausted_without_replacement.
  • TRL provides SFTTrainer (TRL v1.19.0), which accepts prompt-completion datasets and, by default, computes the loss on completion tokens only.
  • T0 code and prompts are released at bigscience-workshop/t-zero and promptsource, per the paper's abstract.

How do you use multi-task tuning in code?

This snippet applies T5's examples-proportional mixing with a cap K to two tasks, then fine-tunes one model on the mixture. Every name is checked against the Datasets v5.2.0 and TRL SFTTrainer v1.19.0 reference pages.

from datasets import load_dataset, interleave_datasets
from trl import SFTConfig, SFTTrainer

tldr = load_dataset("trl-lib/tldr", split="train")            # prompt / completion
gsm = load_dataset("openai/gsm8k", "main", split="train")     # question / answer
gsm = gsm.map(lambda x: {"prompt": "solve: " + x["question"], "completion": " " + x["answer"]},
              remove_columns=gsm.column_names)                 # task prefix, T5-style

K = 2**14                                                      # artificial size cap (T5 Sec. 3.5.2)
capped = [min(len(tldr), K), min(len(gsm), K)]
rates = [c / sum(capped) for c in capped]                     # about 0.687 and 0.313

mixture = interleave_datasets([tldr, gsm], probabilities=rates, seed=42)
trainer = SFTTrainer(
    model="Qwen/Qwen3-0.6B",
    args=SFTConfig(output_dir="qwen3-multitask"),
    train_dataset=mixture,
)
trainer.train()

With the default first_exhausted strategy, the mixture ends when the smaller GSM8K stream runs out. Use stopping_strategy="all_exhausted" to keep going until every source has been seen at least once; the Datasets docs warn that this can make the mixed dataset "enormous" when some probabilities are low.

Common pitfalls

  • Uncapped proportional mixing. Sampling by raw size lets the biggest dataset dominate; T5 added the K cap for this reason (Sec. 3.5.2).
  • Equal mixing. T5 measured 76.13 GLUE with equal mixing against 83.28 for its baseline and lists overfitting on small tasks and undertraining on large ones as likely causes (Table 11).
  • Negative transfer. T5 names "task interference" or "negative transfer", where doing well on one task hurts another, as a known risk (Sec. 3.5.2).
  • Very large tasks need more weight. WMT English to French "always benefits from a higher mixing proportion" in T5's sweep, so one K does not fit every task (Sec. 3.5.2).
  • Overfitting small tasks during per-task fine-tuning. T5 cut the fine-tuning batch size to 8 sequences and saved checkpoints every 1,000 steps for small GLUE and SuperGLUE tasks (Sec. 3.7).

FAQ

Is multi-task tuning one specific method?

No. It is a family of methods. MT-DNN shares a BERT encoder with task-specific heads, T5 mixes text-to-text tasks with a sampling rule, and T0 trains on many prompted datasets to generalize zero-shot. Each paper reports its own results.

Is multi-task training better than fine-tuning on one task?

It depends on the setup. MT-DNN beat BERT-large on GLUE (82.7%, +2.2 points). T5 found multi-task training alone underperformed pre-train-then-fine-tune on most tasks (GLUE 81.42 vs 83.28), while multi-task pre-training plus fine-tuning was comparable (83.11).

How do you balance tasks of very different sizes?

T5 caps each dataset at a limit K before sampling in proportion to size, or uses temperature scaling (T = 2 worked best in most of its tests). Equal mixing gave the worst results in T5's comparison.

What is the difference between multi-task tuning and instruction tuning?

Multi-task tuning is about training on many tasks at once. Instruction tuning phrases tasks as natural-language instructions so a model can follow unseen ones. T0's multitask prompted training is an example of both.

Did T0 beat GPT-3?

On its zero-shot benchmark, T0 (11B) matched or exceeded all GPT-3 models on 9 of 11 held-out datasets despite being about 16x smaller than the 175B GPT-3. The two exceptions were Winogrande and HellaSwag.

Does multi-task tuning cause negative transfer?

It can. T5 lists "task interference" or "negative transfer" as a known risk. In its leave-one-out test, a model pre-trained on all other tasks was only slightly worse on the held-out task, which the authors read as no dramatic interference.

Sources

Series: ← Prev: Instruction Tuning · All 15 techniques · Next: Federated Tuning →

  • #llm-fine-tuning
  • #multi-task-tuning
  • #data-strategy
  • #t5
  • #t0