模型简介
模型特点
模型能力
使用案例
🚀 FLAN - T5 XXL模型卡片
FLAN - T5 XXL是基于T5模型进一步优化的语言模型,在更多任务和更多语言上进行了微调,能在零样本和少样本学习的NLP任务中表现出色,可用于推理、问答等多种研究场景。
🚀 快速开始
模型使用示例
以下是在transformers
库中使用该模型的示例脚本。
使用PyTorch模型
在CPU上运行模型
点击展开
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl")
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
在GPU上运行模型
点击展开
# pip install accelerate
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl", device_map="auto")
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
在GPU上使用不同精度运行模型
FP16
点击展开
# pip install accelerate
import torch
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl", device_map="auto", torch_dtype=torch.float16)
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
INT8
点击展开
# pip install bitsandbytes accelerate
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl", device_map="auto", load_in_8bit=True)
input_text = "translate English to German: How old are you?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
✨ 主要特性
支持的语言
该模型支持英语、德语、法语等多语言,具体包括英语(en)、法语(fr)、罗马尼亚语(ro)、德语(de)以及多语言(multilingual)。
支持的任务类型
- 翻译:如将英文句子翻译成德文。
- 问答:回答各类问题,如“谁将成为下一届金球奖得主”。
- 逻辑推理:对给定的逻辑问题进行推理,如判断布尔表达式的结果。
- 科学知识问答:回答科学相关的问题,如“氮气的沸点是多少”。
- 是非问题:通过推理回答是非问题,如“能否在一条推文中写完一首完整的俳句”。
- 数学推理:解决数学推理问题,如根据给定条件计算数学表达式的值。
- 前提与假设判断:判断前提是否能推出假设。
标签
支持文本到文本生成(text2text - generation)任务。
数据集
模型在多个数据集上进行训练,包括:
- svakulenk0/qrecc
- taskmaster2
- djaym7/wiki_dialog
- deepmind/code_contests
- lambada
- gsm8k
- aqua_rat
- esnli
- quasc
- qed
📦 安装指南
文档未提及具体安装步骤,可参考transformers
库的安装方式以及上述代码示例中依赖库的安装命令。
📚 详细文档
模型详情
模型描述
属性 | 详情 |
---|---|
模型类型 | 语言模型 |
支持语言(NLP) | 英语、德语、法语 |
许可证 | Apache 2.0 |
相关模型 | 所有FLAN - T5检查点 |
原始检查点 | 所有原始FLAN - T5检查点 |
更多信息资源 | 研究论文、GitHub仓库、Hugging Face FLAN - T5文档(类似于T5) |
模型用途
直接使用和下游使用
根据原论文的模型卡片,该模型的主要用途是语言模型研究,包括零样本NLP任务和上下文少样本学习NLP任务的研究,如推理和问答;推进公平性和安全性研究,以及了解当前大语言模型的局限性。更多详情可查看研究论文。
超出范围的使用
需要更多信息。
偏差、风险和局限性
伦理考量和风险
根据模型的官方模型卡片,语言模型(包括Flan - T5)有可能被用于有害的语言生成。Flan - T5在未过滤明确内容或评估现有偏差的大量文本数据语料库上进行了微调,因此模型本身可能容易生成不适当的内容或复制底层数据中固有的偏差。
已知局限性
Flan - T5尚未在实际应用中进行测试。
敏感使用
Flan - T5不应应用于任何不可接受的用例,例如生成辱骂性言论。
训练详情
训练数据
模型在多种任务的混合数据集上进行训练,包括原论文图2中描述的任务:
训练过程
根据原论文的模型卡片,这些模型基于预训练的T5(Raffel等人,2020),并使用指令进行微调,以获得更好的零样本和少样本性能。每个T5模型大小对应一个微调后的Flan模型。模型在TPU v3或TPU v4 Pod上使用t5x
代码库和jax
进行训练。
评估
测试数据、因素和指标
作者在涵盖多种语言(总共1836种)的各种任务上对模型进行了评估。以下是一些定量评估结果:
完整详情请查看研究论文。
评估结果
FLAN - T5 XXL的完整评估结果请查看研究论文中的表3。
环境影响
可以使用Lacoste等人(2019)提出的机器学习影响计算器来估算碳排放。
- 硬件类型:Google Cloud TPU Pods - TPU v3或TPU v4,芯片数量≥4。
- 使用时长:需要更多信息。
- 云服务提供商:GCP
- 计算区域:需要更多信息。
- 碳排放:需要更多信息。
引用
如果使用该模型,请使用以下BibTeX引用:
@misc{https://doi.org/10.48550/arxiv.2210.11416,
doi = {10.48550/ARXIV.2210.11416},
url = {https://arxiv.org/abs/2210.11416},
author = {Chung, Hyung Won and Hou, Le and Longpre, Shayne and Zoph, Barret and Tay, Yi and Fedus, William and Li, Eric and Wang, Xuezhi and Dehghani, Mostafa and Brahma, Siddhartha and Webson, Albert and Gu, Shixiang Shane and Dai, Zhuyun and Suzgun, Mirac and Chen, Xinyun and Chowdhery, Aakanksha and Narang, Sharan and Mishra, Gaurav and Yu, Adams and Zhao, Vincent and Huang, Yanping and Dai, Andrew and Yu, Hongkun and Petrov, Slav and Chi, Ed H. and Dean, Jeff and Devlin, Jacob and Roberts, Adam and Zhou, Denny and Le, Quoc V. and Wei, Jason},
keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Scaling Instruction-Finetuned Language Models},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}
📄 许可证
本模型使用Apache 2.0许可证。



