模型简介
模型特点
模型能力
使用案例
🚀 FLAN - T5小模型卡片
FLAN - T5 small是一款语言模型,在相同参数数量下,相比其他模型在多任务处理和多语言支持上表现更优。它基于预训练的T5模型进行微调,能在零样本和少样本任务中展现出色性能,可用于推理、问答等多种自然语言处理任务。
🚀 快速开始
模型使用示例
以下是在transformers
库中使用该模型的示例脚本。
使用PyTorch模型
在CPU上运行模型
点击展开
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-small")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small")
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-small")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small", 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-small")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small", 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-small")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-small", 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]))
✨ 主要特性
- 多语言支持:支持英语、西班牙语、日语、波斯语、印地语等多达180多种语言。
- 多任务处理:可用于翻译、问答、逻辑推理、科学知识问答、数学推理等多种自然语言处理任务。
- 零样本和少样本学习:基于预训练的T5模型进行微调,能在零样本和少样本任务中展现出色性能。
📦 安装指南
文档未提及具体安装命令,暂不提供安装指南。
📚 详细文档
模型详情
模型描述
属性 | 详情 |
---|---|
模型类型 | 语言模型 |
支持语言 (NLP) | 英语、西班牙语、日语、波斯语、印地语、法语、中文、孟加拉语、古吉拉特语、德语、泰卢固语、意大利语、阿拉伯语、波兰语、泰米尔语、马拉地语、马拉雅拉姆语、奥里亚语、旁遮普语、葡萄牙语、乌尔都语、加利西亚语、希伯来语、韩语、加泰罗尼亚语、泰语、荷兰语、印尼语、越南语、保加利亚语、菲律宾语、高棉语、老挝语、土耳其语、俄语、克罗地亚语、瑞典语、约鲁巴语、库尔德语、缅甸语、马来语、捷克语、芬兰语、索马里语、他加禄语、斯瓦希里语、僧伽罗语、卡纳达语、壮语、伊博语、科萨语、罗马尼亚语、海地语、爱沙尼亚语、斯洛伐克语、立陶宛语、希腊语、尼泊尔语、阿萨姆语、挪威语 |
许可证 | Apache - 2.0 |
相关模型 | [所有FLAN - T5检查点](https://huggingface.co/models?search=flan - t5) |
原始检查点 | [所有原始FLAN - T5检查点](https://github.com/google - research/t5x/blob/main/docs/models.md#flan - t5 - checkpoints) |
更多信息资源 | 研究论文、[GitHub仓库](https://github.com/google - research/t5x)、Hugging Face FLAN - T5文档 (类似于T5) |
模型用途
直接使用和下游使用
根据原始论文的模型卡片,该模型的主要用途是语言模型研究,包括零样本自然语言处理任务和上下文少样本学习自然语言处理任务的研究,如推理和问答;推进公平性和安全性研究,以及了解当前大语言模型的局限性。更多详情请参阅研究论文。
超出适用范围的使用
需要更多信息。
偏差、风险和局限性
本节信息摘自模型的官方模型卡片。
伦理考量和风险
FLAN - T5在未过滤明确内容或评估现有偏差的大量文本数据上进行了微调。因此,该模型本身可能容易生成同样不适当的内容,或复制底层数据中固有的偏差。
已知局限性
FLAN - T5尚未在现实世界应用中进行测试。
敏感使用
FLAN - T5不应应用于任何不可接受的用例,例如生成辱骂性言论。
训练详情
训练数据
该模型在多种任务的混合数据集上进行训练,包括下表(来自原始论文,图2)中描述的任务:
训练过程
根据原始论文的模型卡片:这些模型基于预训练的T5(Raffel等人,2020),并使用指令进行微调,以获得更好的零样本和少样本性能。每个T5模型大小对应一个微调后的Flan模型。该模型在TPU v3或TPU v4集群上使用[t5x
](https://github.com/google - research/t5x)代码库和jax
进行训练。
评估
测试数据、因素和指标
作者在涵盖多种语言(总共1836种)的各种任务上对模型进行了评估。以下表格展示了一些定量评估结果:
完整详情请查看研究论文。
评估结果
FLAN - T5 - Small的完整评估结果请参阅研究论文中的表3。
环境影响
可以使用机器学习影响计算器(来自Lacoste等人(2019))来估算碳排放。
- 硬件类型:谷歌云TPU集群 - 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。



