模型简介
模型特点
模型能力
使用案例
🚀 FLAN - T5基础模型卡
FLAN - T5 base是一款强大的语言模型,在多种自然语言处理任务上表现出色。它基于T5模型进行微调,支持多语言处理,可用于研究零样本和少样本学习等NLP任务。
🚀 快速开始
模型使用示例
以下是在transformers
库中使用该模型的示例脚本:
基础用法
# 使用Pytorch模型在CPU上运行
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-base")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base")
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-base")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base", 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-base")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base", 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-base")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base", 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]))
✨ 主要特性
- 多语言支持:支持英语、西班牙语、日语、波斯语、印地语等多种语言。
- 任务多样性:可用于翻译、问答、逻辑推理、科学知识问答等多种NLP任务。
- 少样本学习能力:经过微调后,在零样本和少样本学习任务上表现出色。
📦 安装指南
文档未提供具体安装步骤,可参考transformers
库的官方安装指南进行安装。
📚 详细文档
模型详情
模型描述
属性 | 详情 |
---|---|
模型类型 | 语言模型 |
支持语言(NLP) | 英语、西班牙语、日语、波斯语、印地语、法语、中文、孟加拉语、古吉拉特语、德语、泰卢固语、意大利语、阿拉伯语、波兰语、泰米尔语、马拉地语、马拉雅拉姆语、奥里亚语、旁遮普语、葡萄牙语、乌尔都语、加利西亚语、希伯来语、韩语、加泰罗尼亚语、泰语、荷兰语、印尼语、越南语、保加利亚语、菲律宾语、高棉语、老挝语、土耳其语、俄语、克罗地亚语、瑞典语、约鲁巴语、库尔德语、缅甸语、马来语、捷克语、芬兰语、索马里语、他加禄语、斯瓦希里语、僧伽罗语、卡纳达语、壮语、伊博语、科萨语、罗马尼亚语、海地语、爱沙尼亚语、斯洛伐克语、立陶宛语、希腊语、尼泊尔语、阿萨姆语、挪威语 |
许可证 | Apache 2.0 |
相关模型 | 所有FLAN - T5检查点 |
原始检查点 | 所有原始FLAN - T5检查点 |
更多信息资源 | 研究论文、GitHub仓库、Hugging Face FLAN - T5文档(类似于T5) |
使用场景
直接使用和下游使用
该模型的主要用途是进行语言模型的研究,包括零样本NLP任务和上下文少样本学习NLP任务的研究,如推理和问答;推动公平性和安全性研究,以及了解当前大型语言模型的局限性。更多详细信息请参考研究论文。
超出适用范围的使用
需要更多信息。
偏差、风险和局限性
伦理考量和风险
FLAN - T5在大量文本数据语料库上进行微调,这些数据未经过显式内容过滤或现有偏差评估。因此,该模型本身可能容易生成同样不适当的内容,或复制底层数据中固有的偏差。
已知局限性
FLAN - T5尚未在现实世界应用中进行测试。
敏感使用
FLAN - T5不应应用于任何不可接受的用例,例如生成辱骂性言论。
训练详情
训练数据
该模型在多种任务的混合数据上进行训练,包括下表(来自原论文图2)中描述的任务:
训练过程
这些模型基于预训练的T5(Raffel等人,2020),并使用指令进行微调,以获得更好的零样本和少样本性能。每个T5模型大小对应一个微调后的Flan模型。该模型在TPU v3或TPU v4 pod上进行训练,使用t5x
代码库和jax
。
评估
测试数据、因素和指标
作者在涵盖多种语言(总共1836种)的各种任务上对模型进行了评估。以下是一些定量评估结果:
完整详情请查看研究论文。
结果
FLAN - T5 - Base的完整评估结果请查看研究论文中的表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}
}
模型回收
以google/flan-t5-base
为基础模型,在36个数据集上进行评估,平均得分达到77.98,而google/t5-v1_1-base
的平均得分是68.82。截至2023年2月6日,该模型在所有测试的google/t5-v1_1-base
架构模型中排名第一。结果如下:
20_newsgroup | ag_news | amazon_reviews_multi | anli | boolq | cb | cola | copa | dbpedia | esnli | financial_phrasebank | imdb | isear | mnli | mrpc | multirc | poem_sentiment | qnli | qqp | rotten_tomatoes | rte | sst2 | sst_5bins | stsb | trec_coarse | trec_fine | tweet_ev_emoji | tweet_ev_emotion | tweet_ev_hate | tweet_ev_irony | tweet_ev_offensive | tweet_ev_sentiment | wic | wnli | wsc | yahoo_answers |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
86.2188 | 89.6667 | 67.12 | 51.9688 | 82.3242 | 78.5714 | 80.1534 | 75 | 77.6667 | 90.9507 | 85.4 | 93.324 | 72.425 | 87.2457 | 89.4608 | 62.3762 | 82.6923 | 92.7878 | 89.7724 | 89.0244 | 84.8375 | 94.3807 | 57.2851 | 89.4759 | 97.2 | 92.8 | 46.848 | 80.2252 | 54.9832 | 76.6582 | 84.3023 | 70.6366 | 70.0627 | 56.338 | 53.8462 | 73.4 |
更多信息请查看:模型回收
📄 许可证
本模型使用Apache 2.0许可证。



