# T5v1.1

## 概述

T5v1.1 由 Colin Raffel 等人发布在 [google-research/text-to-text-transfer-transformer](https://github.com/google-research/text-to-text-transfer-transformer/blob/main/released_checkpoints.md#t511) 仓库中。它是原始 T5 模型的改进版本。该模型由 [patrickvonplaten](https://huggingface.co/patrickvonplaten) 贡献。原始代码可在[此处](https://github.com/google-research/text-to-text-transfer-transformer/blob/main/released_checkpoints.md#t511)找到。

## 使用技巧

可以直接将 T5v1.1 的权重加载到 T5 模型中，如下所示：

```python
from transformers import T5ForConditionalGeneration

model = T5ForConditionalGeneration.from_pretrained("google/t5-v1_1-base", device_map="auto")
```

T5 1.1 版本相较于原始 T5 模型包含以下改进：

- 前馈隐藏层使用 GEGLU 激活函数，而非 ReLU。参见 [这篇论文](https://huggingface.co/papers/2002.05202)。

- 在预训练阶段，Dropout 被关闭（以提升质量）。在微调阶段，应重新启用 Dropout。

- 仅在 C4 上进行预训练，未混合下游任务。

- 嵌入层和分类器层之间没有参数共享。

- “xl”和“xxl”取代了“3B”和“11B”。模型的形状略有不同——`d_model`更大，而`num_heads`和`d_ff`更小。

注意：T5 Version 1.1 仅在 [C4](https://huggingface.co/datasets/allenai/c4) 上进行预训练，未包含任何有监督训练。因此，与原始 T5 模型不同，该模型在用于下游任务之前必须先进行微调。由于 t5v1.1 是无监督预训练的，在单任务微调期间使用任务前缀并没有实际优势。如果您正在进行多任务微调，则应使用前缀。

Google 发布了以下变体：

- [google/t5-v1_1-small](https://huggingface.co/google/t5-v1_1-small)

- [google/t5-v1_1-base](https://huggingface.co/google/t5-v1_1-base)

- [google/t5-v1_1-large](https://huggingface.co/google/t5-v1_1-large)

- [google/t5-v1_1-xl](https://huggingface.co/google/t5-v1_1-xl)

- [google/t5-v1_1-xxl](https://huggingface.co/google/t5-v1_1-xxl).

有关所有 API 参考、技巧、代码示例和笔记本，请参阅 [T5 的文档页面](t5)。

