t5_xl-xsum
google/t5-xl-lm-adapt (LM-adapted T5 v1.1 xl) fully fine-tuned on XSum with torchdistill.
It reproduces the supervised fine-tuning stage of GKD
(Agarwal et al., ICLR 2024, Appendix A.2). It is the supervised fine-tuned teacher for the T5 knowledge distillation (KD) experiments, where T5-small, T5-base and T5-large students are distilled from it: every KD config loads this checkpoint (run name t5_xl_fsdp2) as the teacher.
Model details
| Base model | google/t5-xl-lm-adapt (3B parameters, T5 v1.1 encoder-decoder, 24 encoder + 24 decoder layers) |
| Fine-tuning | Full-parameter supervised fine-tuning, cross-entropy on the reference summaries |
| Training data | EdinburghNLP/xsum, first 99% of the train split |
| Language | English |
| Lengths used in training | input up to 1,024 tokens, summary up to 64 tokens |
| Input format | summarize: <document> |
| Weights | model.safetensors, float32 |
| License | Apache 2.0 (see License) |
Usage
The model was trained on inputs prefixed with summarize: and evaluated with greedy decoding of up to 64 new
tokens. Pass both explicitly: the bundled generation_config.json sets no length, so generate would otherwise stop
at the library default of 20 tokens, and the tokenizer's model_max_length (512) is shorter than the 1,024 input
tokens used in training.
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
model_id = 'yoshitomo-matsubara/t5_xl-xsum'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id, dtype='bfloat16', device_map='auto')
document = 'The full text of a news article ...'
inputs = tokenizer(
f'summarize: {document}', max_length=1024, truncation=True, return_tensors='pt'
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=64, do_sample=False, num_beams=1)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
For batches, pass a list of inputs with padding=True. Unlike a decoder-only model, T5 needs no left padding: the
padded encoder positions are masked out, and the decoder starts from its own start token.
Use bf16 or fp32. T5 overflows in fp16.
Training data and split
EdinburghNLP/xsum has train (204,045 examples), validation (11,332) and test (11,334) splits. They are used
as follows, with the datasets split syntax:
| Split | Use |
|---|---|
train[:99%] | Training |
train[99%:] | "Monitor" split: perplexity after each epoch, for monitoring only |
validation | Reported ROUGE (the paper's reporting split) |
test | Reported ROUGE |
The paper reports the validation split and selects no checkpoint, so this run keeps the last checkpoint
(ckpt_selection: 'last'). Neither reported split, nor the monitor split, is used for any decision. The training run
did not pin a dataset revision.
Each example maps the document field, prefixed with summarize: (the T5 convention; the paper does not state its
input format), to the summary field as the target.
Training procedure
The paper fine-tunes T5-XL for 8,000 steps and gives no other SFT hyperparameters, so the run reuses those of its distillation runs (Table A.1: Adafactor, batch size 32, input/output length 1024/64, learning rate per Appendix A.3), with warmup and cooldown at the same proportions of the run (5% and the last 25%).
Dropout is the one deviation: T5 v1.1's default 0.1 instead of Table A.1's 0.0. With 0.0, plain fine-tuning overfits (T5-base: monitor perplexity 5.2 after epoch 1, 52 after epoch 8) and falls short of the paper's ROUGE-2.
| Hyperparameter | Value |
|---|---|
| Steps | 8,000 optimizer steps (2 epochs, the last one partial) |
| Optimizer | Adafactor (scale_parameter=False, relative_step=False, warmup_init=False), lr 3e-4 |
| Schedule | Warmup-stable-decay: linear warmup over 400 steps, constant, linear decay to 0 over the last 2,000 steps |
| Batch size | 4 per device x 2 devices x gradient accumulation 4 = 32 |
| Dropout | 0.1 |
| Gradient clipping | none |
| Gradient checkpointing | yes |
| Precision | fp32 master weights, bf16 autocast |
| Hardware | 2x 24 GB GPUs, FSDP2 (T5Block auto-wrap, reshard after forward, full state dict), gradient checkpointing, bf16 mixed precision |
| Training time | ~16 h 55 min for the first epoch, ~22 h 21 min in total |
| Seed | 42 |
The full torchdistill config, CLI arguments and per-step metrics are in logs/: config.yaml,
args.json, metrics.json and trackio/summary.csv.
The run used the config under its earlier name, t5_xl_fsdp2.yaml, which is the name recorded in logs/ (config header, args.json, run name t5_xl_fsdp2). In torchdistill it is now configs/sample/xsum/fine_tuning/t5_xl.yaml, so reproduce the run with:
CUDA_VISIBLE_DEVICES=0,1 uv run accelerate launch --num_processes 2 --mixed_precision bf16 \
--use_fsdp --fsdp_version 2 --fsdp_reshard_after_forward true \
--fsdp_auto_wrap_policy TRANSFORMER_BASED_WRAP --fsdp_transformer_layer_cls_to_wrap T5Block \
--fsdp_state_dict_type FULL_STATE_DICT --fsdp_cpu_ram_efficient_loading false \
examples/hf_transformers/summarization.py \
--config configs/sample/xsum/fine_tuning/t5_xl.yaml \
--run_log log/xsum/fine_tuning/t5_xl.txt \
--seed 42
FP32 weights and gradients of ~3B parameters alone take ~24 GB, so the run shards them over two GPUs. It uses FSDP2 rather than FSDP1 because FSDP1 shows the optimizer every parameter as a flattened 1D shard, so Adafactor never factors its second moments and clips each update by the RMS of a shard instead of the whole tensor. FSDP2 keeps parameter shapes, and torchdistill's DTensor-aware HFAdafactor then behaves as on a single device, as for the students. CPU-RAM-efficient loading is turned off (--fsdp_cpu_ram_efficient_loading false); with FSDP1 it hung on T5's shared embeddings.
This is the best of the three XL fine-tuning runs (one seed each, same recipe otherwise):
| XL run | Dropout | Validation / test ROUGE-2 |
|---|---|---|
| FSDP1 (unfactored Adafactor) | 0.0 | 21.15 / 21.06 |
| FSDP1 (unfactored Adafactor) | 0.1 | 21.34 / 21.24 |
| FSDP2 (released) | 0.1 | 21.37 / 21.40 |
The differences are within plausible seed noise.
Evaluation
ROUGE F-measure (x100) of greedy decoding (up to 64 new tokens) on the released, last checkpoint:
| Split | ROUGE-1 | ROUGE-2 | ROUGE-L |
|---|---|---|---|
| Validation (11,332) | 44.89 | 21.37 | 36.79 |
| Test (11,334) | 44.82 | 21.40 | 36.72 |
The paper reports a ROUGE-2 of 22 on the validation split after this stage. Both splits are held out from training and were not used to select the checkpoint. The scores come from the 2-process distributed evaluation of the training run.
Perplexity over the summary tokens of the monitor split, measured after each epoch:
| Epoch | Monitor perplexity |
|---|---|
| 1 | 3.9807 |
| 2 (released) | 3.8002 |
The monitor perplexity was lowest at the final epoch.
Limitations
- XSum's reference summaries often contain information that is not in the article, and models fine-tuned on it are known to hallucinate such content (Maynez et al., 2020). Summaries may be fluent but unfaithful.
- Trained on English BBC news articles; quality on other domains and languages is not measured.
- Inputs longer than 1,024 tokens were truncated in training; summaries are single sentences of up to 64 tokens.
- No downstream evaluation beyond ROUGE on XSum (e.g. factual-consistency metrics or human evaluation) has been run.
- Intended for research, in particular as a reference point for knowledge-distillation experiments.
- About 0.6 ROUGE-2 below the paper's teacher (22). Neither dropout nor the optimizer variant closed the gap; the paper's figure is rounded, and its SFT learning rate and schedule for XL are not stated.
License
The weights are released under the Apache License 2.0
(LICENSE).
This model is a modification of google/t5-xl-lm-adapt by Google, which is licensed under the Apache License 2.0. The modification is full-parameter fine-tuning on the data described above.
The training data, XSum, consists of BBC articles collected by Narayan et al. (2018) for research and carries no explicit license on the Hugging Face Hub. Users are responsible for making sure their use of the model is consistent with the terms of the underlying data.
Citation
If you use this model, please cite torchdistill, as well as GKD, T5 and XSum:
@inproceedings{matsubara2021torchdistill,
title={torchdistill: A Modular, Configuration-Driven Framework for Knowledge Distillation},
author={Matsubara, Yoshitomo},
booktitle={International Workshop on Reproducible Research in Pattern Recognition},
pages={24--44},
year={2021},
organization={Springer}
}
@inproceedings{matsubara2023torchdistill,
title={{torchdistill Meets Hugging Face Libraries for Reproducible, Coding-Free Deep Learning Studies: A Case Study on NLP}},
author={Matsubara, Yoshitomo},
booktitle={Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023)},
publisher={Empirical Methods in Natural Language Processing},
pages={153--164},
year={2023}
}
@inproceedings{agarwal2024onpolicy,
title={On-Policy Distillation of Language Models: Learning from Self-Generated Mistakes},
author={Rishabh Agarwal and Nino Vieillard and Yongchao Zhou and Piotr Stanczyk and Sabela Ramos Garea and Matthieu Geist and Olivier Bachem},
booktitle={The Twelfth International Conference on Learning Representations},
year={2024}
}
@article{raffel2020t5,
title={Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer},
author={Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu},
journal={Journal of Machine Learning Research},
volume={21},
number={140},
pages={1--67},
year={2020}
}
@inproceedings{lester2021power,
title={The Power of Scale for Parameter-Efficient Prompt Tuning},
author={Brian Lester and Rami Al-Rfou and Noah Constant},
booktitle={Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing},
pages={3045--3059},
year={2021}
}
@inproceedings{narayan2018xsum,
title={Don't Give Me the Details, Just the Summary! Topic-Aware Convolutional Neural Networks for Extreme Summarization},
author={Shashi Narayan and Shay B. Cohen and Mirella Lapata},
booktitle={Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing},
pages={1797--1807},
year={2018}
}