T5(Text-to-Text Transfer Transformer)将所有 NLP 任务统一为"文本到文本"格式,基于编码器-解码器架构处理翻译、分类、摘要、问答等任务。
核心设计
| 特性 | 说明 |
|---|
| 架构 | 标准 Transformer 编码器-解码器 |
| 统一格式 | 所有任务转为 text-to-text |
| 输入 | 任务特定格式文本(如 “translate English to French: This is a book”) |
| 输出 | 目标文本 |
论文:Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
T5 1.1 版本改进
| 改进 | 说明 |
|---|
| 相对位置编码 | 更高效的位置编码方式 |
| 训练优化 | 增强模型稳定性和优化效率 |
| 预训练目标 | span-masked denoising |
xxl 模型
| 规格 | 说明 |
|---|
| 参数量 | 超过 110 亿 |
| 适用场景 | 自然语言生成、文本摘要、问答系统、对话生成 |
加载配置
1
2
3
4
5
6
7
| from transformers import T5EncoderModel
model = T5EncoderModel.from_pretrained(
"google/t5-v1_1-xxl",
max_length=256,
torch_dtype=torch.bfloat16
).to(device)
|
| 参数 | 说明 |
|---|
google/t5-v1_1-xxl | Hugging Face 模型路径 |
max_length | 文本序列最大长度(64/128/256/512) |
torch_dtype=torch.bfloat16 | 高效数据类型(A100 等现代 GPU) |
.to(device) | 加载到指定设备 |
应用场景
Comments